So this might be complicated but I am trying to find the proper command .
I need the possible solutions for
119< 5 x1 + 10 x2 + 7 x3 + 5.2 x4 + 6.7 x5 <120
with
x1, x2, x3, x4, x5 ∈ [1 ..5]
I already tried
NSolve [{
119< 5 x1 + 10 x2 + 7 x3 + 5.2 x4 + 6.7 x5 <120,
Element[ {x1, x2, x3, x4, x5}, Point @ { {0},{1},{2},{3},{4} } ] }, { x1, x2, x3, x4, x5 }]
But somehow it doesn’t compute? Is there another maybe more elegant way?
Rob,
here is one simple way:
maxSols = 400;
(* get 'maxSols' solutions: *)
sols = FindInstance[119 < 5 x1 + 10 x2 + 7 x3 + 5.2 x4 + 6.7 x5 < 120, {x1, x2, x3, x4, x5}, PositiveIntegers, maxSols];
(* if "True" we might have found all solutions: *)
Length[sols] < maxSols
and then:
(* select solutions in the respective interval: *)
Select[sols, x1 <= 5 && x2 <= 5 && x3 <= 5 && x4 <= 5 && x5 <= 5 /. # &]
Another way:
Solve[119 < 5 x1 + 10 x2 + 7 x3 + 52/10 x4 + 67/10 x5 < 120 &&
0 <= x1 <= 5 && 0 <= x2 <= 5 && 0 <= x3 <= 5 && 0 <= x4 <= 5 &&
0 <= x5 <= 5, {x1, x2, x3, x4, x5}, Integers]