# Mixed integer programming with FindMinimum

As this works fine

FindMinimum[{x[1, 1] + x[2, 2],
x[1, 1] + 2 x[2, 2] >= 3 && x[1, 1] >= 0 && x[2, 2] >= 0 &&
x[2, 2] <= 2 && x[1, 1] \[Element] Integers}, {x[1, 1], x[2, 2]}]


I was expecting that the more complex program --- more complex in line but not in nature ---

obj = Total[Total[Table[x[i, j], {i, 1, 5}, {j, 1, 5}]]];
cc = And @@
Flatten@Table[
x[i, j] + x[i - 1, j] + x[i + 1, j] + x[i, j - 1] +
x[i, j + 1] - 2 y[i, j] == 1, {i, 2, 4}, {j, 2,
4}];(*Cases centrales*)
ccu = x[1, 1] + x[2, 1] + x[1, 2] - 2 y[1, 1] == 1;(*Case angle 11*)
ccd = x[5, 1] + x[4, 1] + x[5, 2] - 2 y[5, 1] == 1;(*Case angle 51*)
cct = x[1, 5] + x[2, 5] + x[1, 4] - 2 y[1, 5] == 1;(*Case angle 15*)
ccq = x[5, 5] + x[4, 5] + x[5, 4] - 2 y[5, 5] == 1;(*Case angle 55*)
cc1 = (((cc && ccu) && ccd) && cct ) && ccq;
ccpq = And @@
Flatten@Table[
x[i, 1] + x[i - 1, 1] + x[i + 1, 1] + x[1, 2] - 2 y[i, 1] ==
1, {i, 2, 4}];(*Cases première colonne centre*)
cccq = And @@
Flatten@Table[
x[i, 5] + x[i - 1, 5] + x[i + 1, 5] + x[i, 4] - 2 y[i, 5] ==
1, {i, 2, 4}];
ccpl = And @@
Flatten@Table[
x[1, j] + x[1, j - 1] + x[1, j + 1] + x[2, j] - 2 y[i, 5] ==
1, {i, 2, 4}];(*Cases première ligne centre*)
cccl = And @@
Flatten@Table[
x[5, j] + x[5, j - 1] + x[5, j + 1] + x[4, j] - 2 y[5, j] ==
1, {j, 2, 4}];
cc2 = (((cc1 && ccpq) && cccq) && ccpl);
var1 = Flatten[Table[x[i, j], {i, 1, 5}, {j, 1, 5}]];
var2 = Flatten[Table[y[i, j], {i, 1, 5}, {j, 1, 5}]];
vari1 = And @@
Flatten[Table[x[i, j] \[Element] Integers, {i, 1, 5}, {j, 1, 5}]];
vari2 = And @@
Flatten[Table[y[i, j] \[Element] Integers, {i, 1, 5}, {j, 1, 5}]];
var = var1~Join~var2;
vari = vari1 && vari2;
cic1 = And @@
Flatten@Table[x[i, j] <= 5 && x[i, j] >= 1, {i, 2, 4}, {j, 2, 4}];
cipq1 = And @@ Flatten@Table[x[i, 1] <= 3 && x[i, 1] >= 1, {i, 1, 5}];
cicq1 = And @@ Flatten@Table[x[i, 5] <= 3 && x[i, 5] >= 1, {i, 1, 5}];
cipl1 = And @@ Flatten@Table[x[1, j] <= 3 && x[1, j] >= 1, {j, 2, 4}];
cicl1 = And @@ Flatten@Table[x[5, j] <= 3 && x[5, j] >= 1, {j, 2, 4}];
ccf = ((((cc2 && cic1) && cipq1) && cipl1 ) && cicl1) && vari ;
FindMinimum[{obj, ccf }, var]


would also work without difficulties. But, var, which is apparently correctly declared stay blue and no computation is run.

Certainly a mistake of mine. So I need a little help. Thanks.

• Since FindMinimum has Attribute HoldAll, use FindMinimum[Evaluate[{obj, ccf}], Evaluate[var]] instead. But the real problem is that ccpl still contails symbolic js. Maybe you mean j to be equal to 3? Or you need a further Table? – Henrik Schumacher Aug 31 '18 at 7:23
• Dear Herik, you were true. The correct is ccpl = And @@ Flatten@Table[ x[1, j] + x[1, j - 1] + x[1, j + 1] + x[2, j] - 2 y[j, 5] == 1, {j, 2, 4}]; but if now mma computes it doesnt solve saying LinearProgramming is inconsistent with nonlinear constraints or \ object function in – cyrille.piatecki Aug 31 '18 at 8:39
• Now I get the error message "No solution can be found that satisfies the constraints." It is quite obvious what that means... – Henrik Schumacher Aug 31 '18 at 8:41