I use lp_solve Java API to solve a constrained problem, and I have two constraints that would limit the number of selected items in a specified range, such as the following one:
+36 S_1 +31 S_2 +20 S_3 +34 S_4 +19 S_5 +17 S_6 +15 S_7 +39 S_8 +33 S_9 +31 S_10 +23 S_11 +18 S_12 +35 S_13
+17 S_14 +27 S_15 +11 S_16 +22 S_17 +12 S_18 +36 S_19 +31 S_20 +25 S_21 +31 S_22 +10 S_23 +18 S_24 +26 S_25
+27 S_26 +24 S_27 +36 S_28 +9 S_29 <= 100;
+36 S_1 +31 S_2 +20 S_3 +34 S_4 +19 S_5 +17 S_6 +15 S_7 +39 S_8 +33 S_9 +31 S_10 +23 S_11 +18 S_12 +35 S_13
+17 S_14 +27 S_15 +11 S_16 +22 S_17 +12 S_18 +36 S_19 +31 S_20 +25 S_21 +31 S_22 +10 S_23 +18 S_24 +26 S_25
+27 S_26 +24 S_27 +36 S_28 +9 S_29 >= 75;
But lp_solve is changing it to be the following, just before starting to solve, as you can see the first variable S_1
is removed from the first constraint and a negative value for S_19
is added:
+31 S_2 +20 S_3 +34 S_4 +19 S_5 +17 S_6 +15 S_7 +39 S_8 +33 S_9 +31 S_10 +23 S_11 +18 S_12 +35 S_13 +17 S_14
+27 S_15 +11 S_16 +22 S_17 +12 S_18 +36 S_19 +31 S_20 +25 S_21 +31 S_22 +10 S_23 +18 S_24 +26 S_25 +27 S_26
+24 S_27 +36 S_28 +9 S_29 -S_19 <= 100;
+36 S_1 +31 S_2 +20 S_3 +34 S_4 +19 S_5 +17 S_6 +15 S_7 +39 S_8 +33 S_9 +31 S_10 +23 S_11 +18 S_12 +35 S_13
+17 S_14 +27 S_15 +11 S_16 +22 S_17 +12 S_18 +36 S_19 +31 S_20 +25 S_21 +31 S_22 +10 S_23 +18 S_24 +26 S_25
+27 S_26 +24 S_27 +36 S_28 +9 S_29 >= 75;
Is lp_solve changing my constraints?, is it something that lp_solve does to find a feasible solution? and if yes, is there a way to stop it from doing this?
Also, I made sure that all constraints are added properly!