<br><font size=2 face="sans-serif">Thank you, Stefan: that works like a
charm.</font>
<br>
<br><font size=2 face="sans-serif">Also, to John Forrest: perhaps I neglected
to reply to your last suggestion for tracking down a bug in my driver4-like
application. &nbsp;Your suggestion enabled me to find my problem, and we're
now cooking along happily.</font>
<br>
<br><font size=2 face="sans-serif">This forum is a very useful and supportive
place. &nbsp;Thanks to all of you.</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">From:</font>
<td><font size=1 face="sans-serif">Stefan Vigerske &lt;stefan@math.hu-berlin.de&gt;</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font>
<td><font size=1 face="sans-serif">acw@ascent.com</font>
<tr>
<td valign=top><font size=1 color=#5f5f5f face="sans-serif">Cc:</font>
<td><font size=1 face="sans-serif">cbc@list.coin-or.org</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Date:</font>
<td><font size=1 face="sans-serif">02/19/2009 02:11 PM</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Subject:</font>
<td><font size=1 face="sans-serif">Re: [Cbc] Getting information from running
model in CbcMain1</font></table>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>Hi,<br>
<br>
I do this by given a callback function to CbcMain1.<br>
The callback always gets the current model, so you can get, e.g., the<br>
model after preprocessing.<br>
<br>
It looks like the following:<br>
<br>
CbcModel* preprocessedmodel=NULL; /* global variable */<br>
int gamsCallBack(CbcModel* currentSolver, int whereFrom) {<br>
 &nbsp; &nbsp; if (whereFrom==3) preprocessedmodel=currentSolver;<br>
 &nbsp; &nbsp; return 0;<br>
}<br>
<br>
int main (int argc, const char *argv[]) {<br>
 ...<br>
 CbcModel model(lp);<br>
 ...<br>
 CbcMain1(par_list_length,cbc_args,model,gamsCallBack);<br>
 ...<br>
}<br>
<br>
See<br>
</font></tt><a href="https://projects.coin-or.org/GAMSlinks/browser/stable/0.4/GAMSlinks/src/Cbc/GamsCoinCbc.cpp"><tt><font size=2>https://projects.coin-or.org/GAMSlinks/browser/stable/0.4/GAMSlinks/src/Cbc/GamsCoinCbc.cpp</font></tt></a><tt><font size=2><br>
for the full code.<br>
<br>
Best,<br>
Stefan<br>
<br>
acw@ascent.com wrote:<br>
&gt; We have a Cbc application modeled on Cbc/examples/driver4.cpp; in
<br>
&gt; particular, it uses the function CbcMain1 to actually launch the solution.<br>
&gt; <br>
&gt; In a previous version of the same application, we mimicked something
much <br>
&gt; simpler, more like driver1.cpp. &nbsp;In that version, we were able
to monitor <br>
&gt; the problem as it was being solved. &nbsp;We used calls like <br>
&gt; CbcModel-&gt;getObjValue() in another thread to watch the objective
<br>
&gt; improving. &nbsp;(We are aware of thread hazards, but we were pretty
careful to <br>
&gt; protect ourselves from them.)<br>
&gt; <br>
&gt; When we switched to the driver4-like approach, this stopped working.
<br>
&gt; CbcMain1 makes its own copy of the given Cbc model, and it is on this
copy <br>
&gt; (called &quot;cbcModel&quot; in the code, which is in CbcSolver.cpp)
that <br>
&gt; CbcModel.branchAndBound() is actually invoked. &nbsp;Poking the original
model <br>
&gt; to find out its best objective so far, or the number of nodes it has
<br>
&gt; processed, doesn't work.<br>
&gt; <br>
&gt; Is there a right way to expose this copied model so that outside code
can <br>
&gt; query its progress? &nbsp;I'm reluctant to mess around with the code
in <br>
&gt; CbcSolver.cpp, but will do that if I have to.<br>
&gt; <br>
&gt; <br>
&gt; ------------------------------------------------------------------------<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; Cbc mailing list<br>
&gt; Cbc@list.coin-or.org<br>
&gt; </font></tt><a href="http://list.coin-or.org/mailman/listinfo/cbc"><tt><font size=2>http://list.coin-or.org/mailman/listinfo/cbc</font></tt></a><tt><font size=2><br>
<br>
<br>
-- <br>
Stefan Vigerske<br>
Humboldt University Berlin, Numerical Mathematics<br>
</font></tt><a href="http://www.math.hu-berlin.de/~stefan"><tt><font size=2>http://www.math.hu-berlin.de/~stefan</font></tt></a><tt><font size=2><br>
</font></tt>
<br>