10110https://www.ibm.com/developerworks/community/forums/atom/replies?topicUuid=77777777-0000-0000-0000-000014942814Getting multiple solution of MIP for only linear variable Replies2013-03-13T16:58:19.134ZIBM Connections - Discussion Forumurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014956427Re: Getting multiple solution of MIP for only linear variable2013-03-13T16:58:19.134ZSystemAdmin110000D4XKactive2013-03-13T16:58:19.134Z
Thanks It was helpful...
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943300Re: Getting multiple solution of MIP for only linear variable2013-02-21T14:18:33.657ZSystemAdmin110000D4XKactive2013-02-21T14:18:33.657Z
Thomas, you are exactly right here. Changing any part of the model will discard the solution.
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943285Re: Getting multiple solution of MIP for only linear variable2013-02-21T13:58:53.680ZT_O2700035QV5active2013-02-21T13:58:53.680Z
I guess that changing the bounds discards the solution in the following iterations. So you should first obtain the solution and then change the bounds.<br />
<br />
Best regards,<br />
Thomas
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943280Re: Getting multiple solution of MIP for only linear variable2013-02-21T13:50:02.817ZSystemAdmin110000D4XKactive2013-02-21T13:50:02.817Z
Even when I put the loop like <br />
<br />
for(int q=0;q<arc_selected.length;q++)<br />
{ <br />
System.out.println("Arc is::::::::::arc selected::"+subcplex.getValue(arc_selected[q])); <br />
arc_selected[q].setLB(0);<br />
arc_selected[q].setUB(1);<br />
}<br />
<br />
it just enter the lop once and say <br />
Arc is::::::::::arc selected[0]::1.0<br />
:::::::::::::::::::::::::::::::Concert Error: ilog.cplex.CpxException: CPLEX Error 1217: No solution exists.<br />
<br />
the problem seems, once you solve the model u can not add the new constraint <br />
<br />
Is the process I am following is right or there is another process for calling solve multiple times.<br />
<br />
Thanks<br />
Arun Lila
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943268Re: Getting multiple solution of MIP for only linear variable2013-02-21T13:27:15.131ZSystemAdmin110000D4XKactive2014-03-24T22:39:37.446Ziron-man270000AK5Mactive
Could you please provide details about the exception that is thrown? What is the type of the exception? What is the exception message? What is the backtrace? <br />
Also note that this is potentially calling for trouble: <br />
<pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">
double i = subcplex.getValue(arc_selected[q]);
arc_selected[q].setLB(i);
arc_selected[q].setUB(i);
</pre>
<br />
Due to tolerances or round-off errors <i>i</i> may be slightly non-integral and you may be fixing the variable to a non-integral value. A safer variant of your code would be to round the value for i: <br />
<pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">
double i = Math.round(subcplex.getValue(arc_selected[q]));
</pre>
<br />
That ensures that you actually fix to integral values. <br />
<br />
What do you mean by "fix the search for linear variable upto maximum two points of decimal"? Do you mean that only values like 1.11, 1.12 etc. are allowed for that variable but not 1.234? That is not possible since it would turn a continuous variable into a discrete variable (basically it would just be a scaled integral variable). To get things like that you will have to model with integer variables and scale them appropriately.
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943258Re: Getting multiple solution of MIP for only linear variable2013-02-21T13:17:34.198ZSystemAdmin110000D4XKactive2013-02-21T13:17:34.198Z
Thanks Thomas, <br />
<br />
to implemet your suggestion I am trying following thing <br />
if ( subcplex.solve() ) <br />
{ <br />
System.out.println("objective = " + subcplex.getObjValue());<br />
}<br />
for(int q=0;q<arc_selected.length;q++)<br />
{ <br />
System.out.println("Arc is::::::::::arc selected::"+subcplex.getValue(arc_selected[q]));<br />
double i = subcplex.getValue(arc_selected[q]); <br />
arc_selected[q].setLB(i);<br />
arc_selected[q].setUB(i);<br />
}<br />
subcplex.setParam(IloCplex.IntParam.PopulateLim, 10);<br />
subcplex.setParam(IloCplex.IntParam.SolnPoolIntensity, 4);<br />
subcplex.setParam(IloCplex.IntParam.SolnPoolReplace, 1);<br />
subcplex.setParam(IloCplex.IntParam.SolnPoolCapacity , 1000);<br />
subcplex.setParam(IloCplex.DoubleParam.SolnPoolGap, 1000000000);<br />
subcplex.setParam(IloCplex.DoubleParam.SolnPoolAGap, 1); <br />
<br />
if ( subcplex.populate() )<br />
{<br />
System.out.println();<br />
System.out.println("knapsack solved");<br />
numsol = subcplex.getSolnPoolNsolns();<br />
System.out.println("The solution pool contains " + numsol + " solutions.");<br />
}<br />
<br />
where arc_selected[] is Boolean variable.<br />
<br />
But it throws an exception , it seems i can not add the constraints to the solved model. <br />
<br />
Please suggest a way out, <br />
<br />
Also i would like to know if can fix the search for linear variable upto maximum two points of decimal.<br />
Reagrds<br />
Arun LIla
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943178Re: Getting multiple solution of MIP for only linear variable2013-02-21T09:19:44.067ZT_O2700035QV5active2013-02-21T09:19:44.067Z
> <span class="jive-quote-header">XV05_Arun_Lila wrote:</span><br />
> Can we also populate result for a particular binary variable, I have two variables and i does not want the change in the one , i want result only changing the second variable.<br />
<br />
Just fix the first variable by setting its upper and lower bound to the same value.<br />
<br />
Best regards,<br />
Thomas
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943176Re: Getting multiple solution of MIP for only linear variable2013-02-21T09:05:50.654ZSystemAdmin110000D4XKactive2013-02-21T09:05:50.654Z
Can we also populate result for a particular binary variable, I have two variables and i does not want the change in the one , i want result only changing the second variable.<br />
<br />
Thanks<br />
Arun Lila
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943139Re: Getting multiple solution of MIP for only linear variable2013-02-21T07:06:37.922ZSystemAdmin110000D4XKactive2013-02-21T07:06:37.922Z
Thanks Paul, your suggestions are helpful and my model is giving required results. <br />
<br />
I just want to know one more thing , Is there any way we can do "solve MIP, then populate" in java , like we do in AMPL setting populate == 1 or 2.<br />
<br />
Regards<br />
Arun Lila
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943041Re: Getting multiple solution of MIP for only linear variable2013-02-20T22:50:01.409ZSystemAdmin110000D4XKactive2013-02-20T22:50:01.409Z
I don't think populate will be of any use; the MIP solver is simply not designed to look for multiple optima that differ only in the continuous variables.<br />
<br />
Once you have solved the MIP, convert the problem to a "fixed" LP (by fixing the values of the integer variables) and solve it that way. It likely will produce the same values for the continuous variables, but who knows, you might get a second optimum (if one exists). Either way, use the sensitivity output to see if other solutions may exist (see <a class="jive-link-external" href="http://orinanobworld.blogspot.com/2012/10/detecting-multiple-optima-in-lp.html">here</a> for details -- the last paragraph suggests one way to find additional solutions). Another possible approach (still using the fixed LP) is described at the end of <a class="jive-link-external" href="http://orinanobworld.blogspot.com/2013/01/finding-all-solutions-or-not.html">this post</a>.<br />
<br />
Paul<br />
<br />
Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
none, view_forum, view_category