I'm having a hard time getting FindInstance
to return multiple results. Consider this simple example:
FindInstance[a > 0 && b >= 0 && c >= a + b && a >= c/3 , {a, b, c}, Integers, 2]
Mathematica (8.0.1 on Mac) quickly returns
{{a -> 244, b -> 206, c -> 618}, {a -> 306, b -> 299, c -> 860}}
Good. But if I change c/3
to c/4
, which only relaxes the constraints, Mathematica goes busy for 18 sec. For a little more complicated case (9 variables with 15 similar constraints) it never returns (I left it running for several days).
Asking for one solution for the c/4
case (and for the 9 variable case) gets an immediate result:
FindInstance[a > 0 && b >= 0 && c >= a + b && a >= c/4, { a, b, c}, Integers, 1]
returns
{{a -> 1, b -> 0, c -> 3}}
What accounts for the difference?
One more edit: for completeness, here's the 9 variable case:
FindInstance[{a0 >= 0, a1 >= 0, a2 >= 0, a3 >= 0, a4 >= 0, a5 >= 0,
a6 >= 0, a7 >= 0,
nn == a0 + a2 + a4 + a6 + a1 + a3 + a5 + a7,
(a1 + a3 + a5 + a7) / nn >= 0.5735, (a1 + a3 + a5 + a7) /nn <= 0.5745,
(a2 + a3 + a6 + a7) / nn >= 0.4715, (a2 + a3 + a6 + a7) / nn <= 0.4725,
(a4 + a5 + a6 + a7) / nn >= 0.5225, (a4 + a5 + a6 + a7) / nn <= 0.5235,
(a3 + a7) / nn >= 0.2325, (a3 + a7) / nn <= 0.2335,
(a6 + a7) / nn >= 0.2775, (a6 + a7) / nn <= 0.2785,
(a5 + a7) / nn >= 0.2655, (a5 + a7) / nn <= 0.2665,
( a7) / nn >= 0.1195, (a7) / nn <= 0.1205
},
{a0 , a1, a2, a3, a4, a5 , a6, a7, nn}, Integers, 2]
I tried a few variants, such as replacing the decimals with fractions and expanding nn
, to no avail.
{{a -> 343, b -> 570, c -> 1003}, {a -> 520, b -> 826, c -> 1648}}
on mine (8.0 on win32). $\endgroup$