[Cbc] Getting information from running model in CbcMain1
Stefan Vigerske
stefan at math.hu-berlin.de
Thu Feb 19 14:11:36 EST 2009
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
More information about the Cbc
mailing list