put_bb_branchfunc

Specifies a user function to select a B&B branching, given the column to branch on.

void put_bb_branchfunc(lprec *lp, lphandleint_intfunc newbranch, void *bb_branchhandle);

Return Value

put_bb_branchfunc has no return value.

Parameters

lp

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

newbranch

The branch routine.

typedef int (__WINAPI lphandleint_intfunc)(lprec *lp, void *bb_branchhandle, int column);

The routine must return TRUE if first the floor branch must be taken and FALSE if first the ceiling branch must be taken for the specified column.
Note the __WINAPI attribute. This is important under Windows. It ensures __stdcall calling convention which is required.

bb_branchhandle

A parameter that will be provided to the branch routine.

Remarks

Specifies a user function to select a B&B branching, given the column to branch on. With this function you can specify which branch must be taken first in the B&B algorithm. The floor or the ceiling. This overrules the setting of set_bb_floorfirst.

Example

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

int __WINAPI branchfunction(lprec *lp, void *bb_branchhandle, int column)
{
 int branch;

 /* set branch to TRUE or FALSE to specify to branch first on the floor or ceiling branch */

 return(branch);
}

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");
    return(1);
  }

  put_bb_branchfunc(lp, branchfunction, NULL);

  solve(lp);

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, set_bb_floorfirst, get_bb_floorfirst, set_var_branch, get_var_branch, set_var_weights, get_var_priority