I use MIPOptimizer to do integer linear program. For that program. there are two solutions, so how can I get these two
solutions?
The code is like this in java:
MIPOptimizer opt = new MIPOptimizer("integer linear program");
opt.addVariableDiscrete("x1", 1.0, 0, 100);
opt.addVariableDiscrete("x2", 1.0, 0, 70);
opt.addConstraint("-x1 + 12x2 <= 24");
opt.addConstraint("18x1 + 7x2 <= 66");
opt.addObjective("x1 + x2");
opt.maximize();
.....
I can only get one solution (x1=3,x2=1),but there is another (x1=2,x2=2).
So how can get another?
Futher, I want to get another by add addition constraints that is
MIPOptimizer opt = new MIPOptimizer("integer linear program");
opt.addVariableDiscrete("x1", 1.0, 0, 100);
opt.addVariableDiscrete("x2", 1.0, 0, 70);
opt.addConstraint("-x1 + 12x2 <= 24");
opt.addConstraint("18x1 + 7x2 <= 66");
opt.addConstraint("x1!= 3");
opt.addConstraint("x2 != 1");
opt.addObjective("x1 + x2");
opt.maximize();
...
There is a runing exception when I run the above code with the additional constraints. "error in constraint
equation"
So, what should i do to express the additional constraints?
Thanks
Sergey — 15.04.08
Have you tried substitute "!=" with "<>"?
paul genghui — 15.04.08
I have tried substitute "!=" with "<>",and I got the same running exception "error in
constraint
equation"
Thanks
Pavel — 15.04.08
MIPOptimizer allows you to find only one best decision that meets the conditions. Finding all best decisions is the
another task.
paul genghui — 15.04.08
To Pavel
Hi, Pavel, you said that finding all best decisions is the another task. So how can I find all the best solutions?
using another api or method?
Thank you
Pavel — 16.04.08
Please search in the Internet for the third-party software or numerical methods that can solve such problems. It is the
purely mathematical task. AnyLogic with OptQuest allow you to get only one best decision. I think that correspond to the
real life where we need one optimal solution and it doesn’t make sense which one.