0
$\begingroup$

I need to find a certain number of couples : $j2,j3,j5,j6$ (the number is defined in a variable), to give you an idea it is approximatively $3^4 =81$ that minimises the function :

$j2^2+j3^2+j5^2+j6^2$

But my variables follow this system of equation :

   {j2 -> ConditionalExpression[
   1 + C[1] + 2 C[2] + C[3] + C[4] + 
    C[5], (C[1] | C[2] | C[3] | C[4] | C[5]) ∈ Integers && 
    C[1] >= 0 && C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && C[5] >= 0], 
 j3 -> ConditionalExpression[
   1 + C[1] + C[2] + C[3] + 
    C[4], (C[1] | C[2] | C[3] | C[4] | C[5]) ∈ Integers && 
    C[1] >= 0 && C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && C[5] >= 0], 
 j5 -> ConditionalExpression[
   1 + C[1] + C[2] + 2 C[3] + C[4] + 
    C[5], (C[1] | C[2] | C[3] | C[4] | C[5]) ∈ Integers && 
    C[1] >= 0 && C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && C[5] >= 0], 
 j6 -> ConditionalExpression[
   1 + C[4], (C[1] | C[2] | C[3] | C[4] | C[5]) ∈ Integers &&
     C[1] >= 0 && C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && C[5] >= 0]}

Do you know how I could to it ? And the more important : do you think it is feasible in a reasonable amount of time (in less than 5 minutes) given the number of couples (81) to find and the complexity of the system ?

To be more lisible, the system of equations is the following :

$$ j_1 = 1+C_1+2 C_2 + C_3 + C_4 + C_5$$ $$ j_3 = 1+C_1+ C_2 + C_3 + C_4$$ $$ j_5 = 1+C_1+ C_2 + 2 C_3 + C_4 + C_5$$ $$ j_6 = 1+C_4$$

Where the $C_i$ are positive integers

$\endgroup$
1
$\begingroup$

Perhaps you can adapt this

j1 = 1 + C[1] + 2 C[2] + C[3] + C[4] + C[5];
j3 = 1 + C[1] + C[2] + C[3] + C[4];
j5 = 1 + C[1] + C[2] + 2 C[3] + C[4] + C[5];
j6 = 1 + C[4];
NMinimize[{j1^2+j3^2+j5^2+j6^2, (C[1]|C[2]|C[3]|C[4]|C[5]) \[Element] Integers &&
C[1]>0 && C[2]>0 && C[3]>0 && C[4]>0 && C[5]> 0}, {C[1],C[2],C[3],C[4],C[5]}]

Note that those conditions need >0 and not just >=0 to satisfy your requirement that the C[i] are positive integers.

This finished in about a second. Whether your full system can finish in less than 5 minutes will depend heavily on exactly what your system contains.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.