<br><font size=2 face="sans-serif">Kish,</font>
<br>
<br><font size=2 face="sans-serif">a) postprocessing deletes the solver
it is given which is why you get error in getNumCols() as that just asks
current solver how many columns it has.</font>
<br><font size=2 face="sans-serif">b) On first inspection of your code
it looks as if the solution should be back in lpd-&gt;lp-&gt;solver. &nbsp;One
way to check would be to put garbage in the solution before postprocess
(setColSolution) and see if it changes. &nbsp;If so it should be correct.</font>
<br><font size=2 face="sans-serif">c) It is more likely that - shock, horror
- there is a bug in preprocessing. &nbsp;I am fairly sure at least one
bug has been fixed since June. &nbsp;If the user can give you the problem
that fails try with cbc-stable/2.0 and cbc-trunk.</font>
<br>
<br><font size=2 face="sans-serif">John</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Kish Shen &lt;kisshen@cisco.com&gt;</b>
</font>
<p><font size=1 face="sans-serif">11/08/2007 12:58 PM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">John J Forrest/Watson/IBM@IBMUS</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">cbc@list.coin-or.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [Cbc] getting solution to original
problem from Cbc/Clp</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><tt><font size=2>Hi John,<br>
<br>
I have not had time to look into my problem again in detail until now,
<br>
so sorry for the delay in this follow-up...<br>
<br>
John J Forrest wrote:<br>
&gt; <br>
&gt; Kish,<br>
&gt; <br>
&gt; It sounds as if you are using presolve rather than CglPreProcess.
&nbsp;This <br>
&gt; could give wrong results as you describe.<br>
&gt; <br>
&gt; Look at Cbc/examples/sample2.cpp and try with PREPROCESS defined to
1 or <br>
&gt; 2 to see two ways of using CglPreProcess.<br>
&gt; <br>
&gt; As to your questions.<br>
&gt; <br>
&gt; 1) &nbsp;The solver can in some circumstances not have an integer
solution - <br>
&gt; bestSolution is what is needed but it must go through post processing.<br>
<br>
<br>
I think it is best if I actually show what exactly I am doing in my <br>
code. Here is a brief outline of what I do:<br>
<br>
Types of variables used:<br>
<br>
OsiClpSolverInterface * lpd-&gt;lp-&gt;Solver &nbsp; &lt;--- the original
problem<br>
<br>
OsiSolverInterface * &nbsp; &nbsp;mipsolver<br>
CbcModel * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpd-&gt;lp-&gt;mipmodel<br>
CbcModel * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;model<br>
CglPreProcess &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;process<br>
<br>
1. I first preprocess the original problem:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
mipsolver = process.preProcess(*lpd-&gt;lp-&gt;Solver, false, 5);<br>
<br>
2. I then put this preprocessed problem into a CbcModel (unless <br>
preprocess failed, in which case I abort):<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
lpd-&gt;lp-&gt;mipmodel = new CbcModel(static_cast&lt;OsiSolverInterface
<br>
&amp;&gt;(*mipsolver));<br>
 &nbsp; &nbsp; &nbsp; &nbsp; CbcModel* model = lpd-&gt;lp-&gt;mipmodel;<br>
<br>
The lpd-&gt;lp-&gt;mipmodel is to allow me to access the model later in
the <br>
code, whereas model is used locally..<br>
<br>
3. this is followed by some more optimisations etc., based on the <br>
example2 code, and then branchAndBound is called:<br>
<br>
 &nbsp; &nbsp; model-&gt;branchAndBound();<br>
<br>
In some cases, the branchAndBound may time-out early, because a timeout
<br>
is set.<br>
<br>
4. the problem is post-processed (this is always done, even if the <br>
problem was timed out, or is infeasible):<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
process.postProcess(*model-&gt;solver());<br>
<br>
looking at the comment of example2, this will put the post-processed <br>
solution back into lpd-&gt;lp-&gt;Solver. I then subsequently access this
via <br>
lpd-&gt;lp-&gt;Solver-&gt;getColSolution().<br>
<br>
My user have reported that the solution returned may sometimes be wrong
<br>
because it seems to violate some the constraints in the original <br>
problem. This is why I thought I may be returning a relaxed solution <br>
from a node in the branch and bound (e.g. when the problem was timed <br>
out), rather than the best integer solution. This is why I want to use
<br>
bestSolution to return the solution.<br>
<br>
However, bestSolution is a method for CbcModel, and not OSI, I think, <br>
and the solution in the CbcModel (the one in model in my code) is still
<br>
the preprocessed problem, rather than the original problem, even after
<br>
the postProcess call in 4. I checked this by returning the column number
<br>
for model before and after the post-processing, and it is the same (and
<br>
less than the original problem's).<br>
<br>
Is there any way I can be certain I am getting the best integer solution<br>
found by the branchAndBound, in the original problem form, rather than
<br>
the preprocessed one?<br>
<br>
In checking the column numbers, I was somewhat surprised that I got an
<br>
error in the second call to getNumCols:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
std::cout&lt;&lt; &quot;before:&quot;&lt;&lt;mipsolver-&gt;getNumCols()&lt;&lt;std::endl;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
process.postProcess(*model-&gt;solver());<br>
 &gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; std::cout&lt;&lt; &quot;after:&quot;&lt;&lt;mipsolver-&gt;getNumCols()&lt;&lt;std::endl;<br>
<br>
here is the output from running this:<br>
<br>
before:16<br>
pure virtual method called<br>
after:Signal 6<br>
<br>
I am not sure this is directly related to my problem, but is this <br>
expected behaviour?<br>
<br>
I think I am using a Cbc that I download in June this year.<br>
<br>
Thanks in advance for any information/help!<br>
<br>
Cheers,<br>
<br>
Kish<br>
<br>
<br>
<br>
<br>
&gt; 2) The result should be correct for problem with all integer variables
<br>
&gt; fixed to correct values.<br>
&gt; <br>
&gt; <br>
&gt; John Forrest<br>
&gt; <br>
&gt; <br>
&gt; *Kish Shen &lt;kisshen@cisco.com&gt;*<br>
&gt; Sent by: cbc-bounces@list.coin-or.org<br>
&gt; <br>
&gt; 10/19/2007 12:03 PM<br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; To<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cbc@list.coin-or.org<br>
&gt; cc<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; Subject<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[Cbc]
getting solution to original problem from Cbc/Clp<br>
&gt; <br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Hi,<br>
&gt; <br>
&gt; I am using CBC with CLP as the linear solver. CLP is accessed via
OSI<br>
&gt; i.e. OsiClpSolverInterface), but CBC is accessed directly, instead
of<br>
&gt; via OSI.<br>
&gt; <br>
&gt; I have been obtaining the solution state for MIP problems via the
OSI<br>
&gt; calls, e.g. getColSolution(), getRowPrice(), etc.. One of our users<br>
&gt; reported that some of the solution is incorrect, e.g. variables that<br>
&gt; should be integers are not, and some constraints are violated.<br>
&gt; <br>
&gt; I suspected that this is because the OSI calls are via<br>
&gt; OsiClpSolverInterface, and so I am obtaining the state from the most<br>
&gt; recent LP relaxation, rather than the most recent MIP solution. I<br>
&gt; therefore changed the code to obtain the solution state via Cbc calls,<br>
&gt; for example, bestSolution() of CbcModel instead of getColSolution().<br>
&gt; <br>
&gt; Unfortunately, in this case, the number of columnssiz in the problem<br>
&gt; seems to be much smaller: in one example, the original problem had
945<br>
&gt; columns, and the MIP solution of the problem has only &nbsp;205 columns.
I<br>
&gt; assume this is because presolve reduced the problem, and bestSolution()<br>
&gt; returns the solution for the presolved matrix.<br>
&gt; <br>
&gt; Questions:<br>
&gt; <br>
&gt; 1) Am I correct that OSIClpSolverInterface's methods, such as<br>
&gt; getColSolution(), is returning the state from the LP relaxation, rather<br>
&gt; than the MIP solution? [If not, then there is something wrong with
the<br>
&gt; MIP solution produced]<br>
&gt; <br>
&gt; 2) How can I obtain the MIP solution state (solution values, row price,<br>
&gt; row activity, reduced cost [and basis status for the LP relaxation
that<br>
&gt; produced the MIP solution, if this is available], for the original<br>
&gt; problem (and not the presolved problem)?<br>
&gt; <br>
&gt; Thanks in advance for any help/information!<br>
&gt; <br>
&gt; Cheers,<br>
&gt; <br>
&gt; Kish Shen<br>
&gt; _______________________________________________<br>
&gt; Cbc mailing list<br>
&gt; Cbc@list.coin-or.org<br>
&gt; http://list.coin-or.org/mailman/listinfo/cbc<br>
&gt; <br>
&gt; <br>
&gt; ------------------------------------------------------------------------<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; Cbc mailing list<br>
&gt; Cbc@list.coin-or.org<br>
&gt; http://list.coin-or.org/mailman/listinfo/cbc<br>
</font></tt>
<br>