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