Skip to content

Limit solve time/iterations/... or cancel solving process #39

Answered by jhmgoossens
SashmanGH asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
Apologies for the confusion. I didn’t realise your question was for Sonnet—I thought it was for cbc.. I deleted my original answer.

For sonnet, the short answer is to either add the “sec” solver arg or cbcmodel setMaximumSeconds:

Solver solver = ….
OsiCbcSolverInterface osiCbc = solver.OsiSolver as OsiCbcSolverInterface;
osiCbc.AddCbcSolverArgs("-sec", "5");

or to use the setMaximumSeconds of CbcModel:
osiCbc.getModelPtr().setMaximumSeconds(5.0;
Which should work again since CBC #467 was closed. See test/SonnetTest/Sonnet_CbcTests.cs

For an example of how to use CBC Callbacks from sonnet, see also Sonnet_CbcTests.cs

For background: Sonnet relies on Osi, but Osi doesn’t include things…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jhmgoossens
Comment options

Answer selected by SashmanGH
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants