0

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!

  • 1
    Maybe you want to provide the rest of the code ? – k88 May 17 '20 at 06:04
  • @k88 The whole code is very complex, I think what I asked about here is whether we can disable this kind of behavior from lp_solve or not, I've checked the API and didn't find any useful information so far – Abdarhman Taha May 18 '20 at 02:22
  • I don't think anyone can be of much help here. Have a read [here](https://stackoverflow.com/help/minimal-reproducible-example) and provide a minimal reproducible example. We can be of better help then. (And please refrain from putting the entire code in a question) – k88 May 18 '20 at 05:38
  • If you load the problem and immediately write out the lp file, and you see this behavior, I would start to believe you have a bug in your code that creates the problem. – Erwin Kalvelagen May 18 '20 at 16:16
  • @ErwinKalvelagen You're right, my problem has around 900 constraints (rows), after going through all of them I found I had one {null} value in one constraint which I think caused the other constraint to change the way it did, this is a very strange behavior for me, cause I think it should have had one of two choices, 1- to throw an error or 2- remove this null constraint and continue normally – Abdarhman Taha May 20 '20 at 05:03

0 Answers0