[Coin-discuss] Some questions on heuristic and cut writing style

John J Forrest jjforre at us.ibm.com
Sat Mar 26 12:10:55 EST 2005


Fabrizio,

Without seeing your heuristic code it is difficult to say what is wrong. 
Look at the files CbcHeuristic*.cpp in Cbc and Cbc/Samples to see which is 
closest to what you want.   For instance in CbcHeuristic.cpp in 
CbcRounding::solution you can see the use of getColSolution.  Two points: 
You need to set solutionValue and betterSolution array and returncode of 1 
to tell Cbc you think you have a better solution.  Also - yes it is 
obviously a good idea to use current solution as otherwise you would just 
be doing same heuristic at each node but you can cheat.  A valid solution 
from ::solution is one which does not violate the bounds at the continuous 
optimum - it can violate bounds at the node in the tree.  You can see 
different uses in the various CbcHeuristic files - so you if you use 
current solver you get current bounds and if you use continuousSolver you 
get original bounds.

As to fixing variables there are many ways depending on exactly what you 
want to do.  A CglFix cut generator approach would work.  CglProbing is 
far too complex but if you want I could put up a simple example.  You 
could also inherit from the branching objects to do extra fixing.  Another 
idea which has merit is to make a specialized solver (e.g. as in 
Samples/qmip.cpp and ClpQuadInterface) and fix variables before solving. 
This is probably too complex but I will come back to it.

I could easily add a new virtual function to allow user to fix variables. 
This could be called before the solve of a branch or after.  If after it 
would act a bit like the reduced cost fixing which is done after a branch. 
 This would be a clean way which would make it less intimidating to try.

If you are fixing many variables and are intending to do complete search 
then you might wish to go back to modifying the solve.  I have an example 
which does nested branch and cut so if a lot of variables are fixed a 
branch makes a much smaller MIP and completely fathoms it.  Too much 
choice....

To get best solution in a CglCut you should make the CbcModel part of the 
data structure of your generator.  Then you could pick up 
model_->bestSolution();

Please contact me if you want clarification or sample code.

John Forrest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20050326/7eeb0e8c/attachment.html>


More information about the Coin-discuss mailing list