branchobj.addrows
branchobj.addrows |
Purpose
Adds new constraints to a branch of a user branching object.
Synopsis
branchobj.addrows(ibranch, rtype, rhs, beg, mcol, val)
Arguments
|
ibranch
|
The number of the branch to add the new constraints for. This branch must already have been created using
branchobj.addbranches. Branches are indexed starting from zero.
|
||||||
|
rtype
|
Character array indicating the type of constraints to add:
|
||||||
|
rhs
|
Array containing the right-hand side values.
|
||||||
|
beg
|
Array containing the offsets of the
mcol and
dval arrays of the start of the non zero coefficients in the new constraints.
|
||||||
|
mcol
|
Array containing the columns for the non zero coefficients.
|
||||||
|
dval
|
Array containing the non-zero coefficient values.
|
Example
The following function will create a branching object that branches on constraints
x1 + x2 ≥ 1 or
x1 + x2 ≤ 0:
def CreateConstraintBranch(mip, icol):
# Create the new object with two empty branches.
bo = xpress.branchobj(mip, isoriginal=True)
bo.addbranches(2)
# Add the constraint of the branching object:
# x1 + x2 >= 1
# x1 + x2 <= 0
bo.addrows(0, 1, 2, ['G'], [1.0], [0], [0,1], [1.0,1.0])
bo.addrows(1, 1, 2, ['L'], [0.0], [0], [0,1], [1.0,1.0])
# Set a low priority value so our branch object is picked up
# before the default branch candidates.
bo.setpriority(100)
return bo
