Branching

If the user declares variables as integer but does no more, then Cbc will treat them as simple integer variables. In many cases the user would like to do some more fine tuning. This shows how to create integer variables with pseudo costs. When pseudo costs are given then it is assumed that if a variable is at 1.3 then the cost of branching that variable down will be 0.3 times the down pseudo cost and the cost of branching up would be 0.7 times the up pseudo cost. This can be used both for branching and for choosing a node. The full code is in longthin.cpp (this code can be found in the CBC Samples directory, see Chapter 5, More Samples ). The idea is simple for set covering problems. Branching up gets us much closer to an integer solution so we want to encourage up - so we will branch up if variable value > 0.333333. The expected cost of going up obviously depends on the cost of the variable so we just choose pseudo costs to reflect that.

The actual coding in the example also tries to give more importance to variables with more coefficients. Whether this sort of thing is worthwhile should be the subject of experimentation. Here is another example which is for crew scheduling problems. In this case the problem has few rows but many thousands of variables. Branching a variable to 1 is very powerful as it fixes many other variables to zero, but branching to zero is very weak as thousands of variables can increase from zero. But in crew scheduling each constraint is a flight leg e.g. JFK to DFW. From DFW (Dallas) there may be several flights the crew could take next - suppose one flight is the 9:30 flight from DFW to LAX (Los Angeles). Then a binary branch is that the crew arriving at DFW either take the 9:30 flight to LAX or they don't. This follow-on branching does not fix individual variables but instead divides all the variables with entries in the JFK-DFW constraint into two groups - those with entries in the DFW-LAX constraint and those without entries. The full code is in crew.cpp (this code can be found in the CBC Samples directory, see Chapter 5, More Samples ). In this case we may as well leave the simple integer variables and we may have to if there are other sorts of constraints. But we want to branch on the follow-on rules first so we use priorities to say that those are the important ones.