Initializing help system before first use

XPRS_bo_addrows

XPRS_bo_addrows


Purpose
Adds new constraints to a branch of a user branching object.
Synopsis
int XPRS_CC XPRS_bo_addrows(XPRSbranchobject obranch, int ibranch, int nrows, int nelems, const char crtype[], const double drrhs[], const int mrbeg[], const int mcol[], const double dval[]);
Arguments
obranch 
The user branching object to modify.
ibranch 
The number of the branch to add the new constraints for. This branch must already have been created using XPRS_bo_addbranches. Branches are indexed starting from zero.
nrows 
Number of new constraints to add.
nelems 
Number of non-zero coefficients in all new constraints.
crtype 
Character array of length nrows indicating the type of constraints to add:
Less than type.
Greater than type.
Equality type.
drrhs 
Double array of length nrows containing the right hand side values.
mrbeg 
Integer array of length nrows containing the offsets of the mcol and dval arrays of the start of the non zero coefficients in the new constraints.
mcol 
Integer array of length nelems containing the column indices for the non zero coefficients.
dval 
Double array of length nelems containing the non zero coefficient values.
Example
The following function will create a branching object that branches on constraints x_1 + x_2 ≥ 1 or x_1 + x_2 ≤ 0:
XPRSbranchobject CreateConstraintBranch(XPRSprob xp_mip, int icol)
{
  char   cRowType;
  double dRowRHS;
  int    mRowBeg;
  int    mElemCol[2];
  double dElemVal[2];

  XPRSbranchobject bo = NULL;
  int isoriginal = 1;

  /* Create the new object with two empty branches. */
  XPRS_bo_create(&bo, xp_mip, isoriginal);
  XPRS_bo_addbranches(bo, 2);

  /* Add the constraint x1 + x2 >= 1. */
  cRowType = 'G';
  dRowRHS  = 1.0;
  mRowBeg  = 0;
  mElemCol[0] = 0; mElemCol[1] = 1;
  dElemVal[0] = 1.0; dElemVal[1] = 1.0;
  XPRS_bo_addrows
    (bo, 0, 1, 2, &cRowType, &dRowRHS, &mRowBeg, mElemCol, dElemVal);
  /* Add the constraint x1 + x2 <= 0. */
  cRowType = 'L';
  dRowRHS  = 0.0;
  XPRS_bo_addrows
    (bo, 1, 1, 2, &cRowType, &dRowRHS, &mRowBeg, mElemCol, dElemVal);

  /* Set a low priority value so our branch object is picked up */
  /* before the default branch candidates. */
  XPRS_bo_setpriority(bo, 100);

  return bo;
}
Related topics