[Cbc] Solution callbacks

Gleb Belov gleb.belov at monash.edu
Thu Feb 25 00:21:22 EST 2016


-- Thank you John,

a,b) this is not a very clean interface... maybe put this into 
postProcess so I can access the correct obj from originalModel()?

c) what do you mean by size? The preprocessed model has always smaller 
NumColumns() than the start model in my examples and originalModel() has 
always the same number. In the meantime I have an example where 
postProcess() crashes, probably on a model which is not intended to be 
post-processed.

How is it with cut generators, do they get LP solution for the original 
model?

I'd be happy to access the current number of open (unexplored) nodes by 
some interface method. Also in the solution callback, assuming we get it 
to work.

I noticed when performing postprocessing in the callback, the solution 
way differs... probably because post-processing calls some LP resolving 
procedures? I tried to create a copy of *cbcCglPreProcess each time but 
the copy crashes.

Gleb

On 24/02/2016 8:34 PM, John Forrest wrote:
> Gleb,
>
> On wrong objective value
>
> a) you need to take into account fixed part of objective
>
> solver->getDblParam(OsiObjOffset, objOffset);
>
> b) internally it is always minimization
>
> c) only report when size of problem is same as preprocessed model - 
> first report could come from heuristic on a smaller model
>
> John
>
> On 24/02/16 01:09, Gleb Belov wrote:
>> Hi John,
>>
>> the callBack() function from interrupt.cpp is wrong, my code either 
>> crashes when using callCbc1, or exits without anything when CbcMain1. 
>> BTW the NEW_STYLE_SOLVER==1 variant with CbcSolver does not use the 
>> callBack() at all. I resorted to simple callCbc(options, model) as 
>> before.
>>
>> Implemented for now only the objective value conversion as follows:
>>
>>         if (whichEvent==solution||whichEvent==heuristicSolution) {
>>           if ( 0!=cbcPreProcessPointer ) {
>>             cbcPreProcessPointer->postProcess( *model_->solver(),
>>     false );
>>             printf("VALUE of solution is %g\n",
>>     cbcPreProcessPointer->originalModel()->getObjValue());
>>           }
>>           return noAction; // carry on
>>         } else {
>>           return noAction; // carry on
>>         }
>>
>>
>> It seems to show a local dual bound sometimes, or I don't know where 
>> 328 below came from:
>>
>>     Integer solution of 1894 found by RINS after 30787 iterations and
>>     200 nodes (11.59 seconds)
>>     VALUE of solution is 1804
>>     VALUE of solution is 328
>>     Integer solution of 1680 found by strong branching after 42125
>>     iterations and 281 nodes (14.78 seconds)
>>     VALUE of solution is 1558
>>     Integer solution of 1589 found by strong branching after 53959
>>     iterations and 329 nodes (17.41 seconds)
>>     VALUE of solution is 1402
>>
>>
>> Moreover, on another problem which is a maximization, it seems not to 
>> get the current solution at all:
>>
>>     After 0.14 seconds - Feasibility pump exiting with objective of
>>     -4 - took 0.13 seconds
>>     Integer solution of -4 found by feasibility pump after 0
>>     iterations and 0 nodes (0.14 seconds)
>>     VALUE of solution is 8
>>     VALUE of solution is 8
>>     Full problem 142 rows 181 columns, reduced to 77 rows 57 columns
>>     ........
>>     Maximum depth 0, 0 variables fixed on reduced cost
>>     VALUE of solution is 8
>>     18 added rows had average density of 41.666667
>>     At root node, 18 cuts changed objective from -8 to -8 in 100 passes
>>     Cut generator 0 (Probing) - 236 row cuts average 5.1 elements, 0
>>     column cuts (0 active)  in 0.100 seconds - new frequency is -100
>>     ....
>>     Cut generator 6 (TwoMirCuts) - 119 row cuts average 135.9
>>     elements, 0 column cuts (0 active)  in 0.040 seconds - new
>>     frequency is -100
>>     VALUE of solution is 8
>>     After 0 nodes, 1 on tree, -4 best solution, best possible -8
>>     (0.85 seconds)
>>     Full problem 142 rows 181 columns, reduced to 67 rows 44 columns
>>     The LP relaxation is infeasible or too expensive
>>     Solution of 1e+50 already found by heuristic
>>     ...
>>     Maximum depth 0, 0 variables fixed on reduced cost
>>     Integer solution of -8 found by strong branching after 7137
>>     iterations and 161 nodes (1.26 seconds)
>>     VALUE of solution is 8
>>
>>
>>
>> Gleb
>>
>> On 23/02/2016 8:45 PM, John Forrest wrote:
>>> Gleb,
>>>
>>> On 23/02/16 05:25, Gleb Belov wrote:
>>>> Hi John,
>>>>
>>>> there is demand for continuous solution output so I am trying this. 
>>>> Looks like I need a method to obtain the PreProcess object during 
>>>> solving (because it is created in CbcMain1). BTW you say postsolve 
>>>> deletes data but the 2nd parameter could be used to avoid this?
>>>
>>> There is a fudge to access the preProcess object.  Add
>>>
>>> extern CglPreProcess * cbcPreProcessPointer;
>>>
>>> to the event handler.
>>>>
>>>> What is the usage of the callback function opposed to the event 
>>>> handler? I don't see how I can use the callback because in 
>>>> interrupt.cpp the MyEventHandler3 class is used to print a solution.
>>>
>>> event handler only works inside CbcModel::branchAndBound.  The 
>>> callback is to handle events before and after.  the most common is 
>>> to add in specialized heuristics after preprocessing but before 
>>> branch and bound
>>>
>>> John
>>>>
>>>> Gleb

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20160225/00d6f7b9/attachment.html>


More information about the Cbc mailing list