Specifies the branch-and-bound rule.

void set_bb_rule(lprec *lp, int bb_rule);

Return Value

set_bb_rule has no return value.



Pointer to previously created lp model. See return value of make_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI


The branch-and-bound rule. Can by any of the following values:

NODE_FIRSTSELECT (0) Select lowest indexed non-integer column
NODE_GAPSELECT (1) Selection based on distance from the current bounds
NODE_RANGESELECT (2) Selection based on the largest current bound
NODE_FRACTIONSELECT (3) Selection based on largest fractional value
NODE_PSEUDOCOSTSELECT (4) Simple, unweighted pseudo-cost of a variable
NODE_PSEUDONONINTSELECT (5) This is an extended pseudo-costing strategy based on minimizing the number of integer infeasibilities
NODE_PSEUDORATIOSELECT (6) This is an extended pseudo-costing strategy based on maximizing the normal pseudo-cost divided by the number of infeasibilities. Effectively, it is similar to (the reciprocal of) a cost/benefit ratio

One of these values may be or-ed with one or more of the following values:

NODE_BRANCHREVERSEMODE (16) In case when get_bb_floorfirst is BRANCH_AUTOMATIC, select the oposite direction (lower/upper branch) that BRANCH_AUTOMATIC had chosen.
NODE_DEPTHFIRSTMODE (128) Select the node that has already been selected before the most number of times
NODE_DYNAMICMODE (1024) When NODE_DEPTHFIRSTMODE is selected, switch off this mode when a first solution is found.
NODE_BREADTHFIRSTMODE (4096) Select the node that has been selected before the fewest number of times or not at all
NODE_AUTOORDER (8192) Create an "optimal" B&B variable ordering. Can speed up B&B algorithm.


The set_bb_rule function specifies the branch-and-bound rule for choosing which non-integer variable is to be selected. This rule can influence solving times considerably. Depending on the model one rule can be best and for another model another rule.
The default is NODE_FIRSTSELECT (0).


#include <stdio.h>
#include <stdlib.h>
#include "lp_lib.h"

int main(void)
  lprec *lp;

  /* Create a new LP model */
  lp = make_lp(0, 0);
  if(lp == NULL) {
    fprintf(stderr, "Unable to create new LP model\n");

  set_bb_rule(lp, NODE_FIRSTSELECT);


lp_solve API reference

See Also make_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, get_bb_rule