problem.addcols
problem.addcols |
Purpose
Add columns to the problem after passing it to the Optimizer using the input routines.
Synopsis
problem.addcols (objx, mstart, mrwind, dmatval, bdl, bdu, names, types)
Arguments
objx
|
Array containing the objective function coefficients of the new columns.
|
||||||||||||
mstart
|
Array containing the offsets in the
mrwind and
dmatval arrays of the start of the elements for each column.
|
||||||||||||
mrwind
|
Array containing the row indices for the elements in each column.
|
||||||||||||
dmatval
|
Array containing the element values.
|
||||||||||||
bdl
|
Array containing the lower bounds on the added columns.
|
||||||||||||
bdu
|
Array containing the upper bounds on the added columns.
|
||||||||||||
names
|
(optional) Array containing the names of the columns added.
|
||||||||||||
types
|
(optional) Array of characters containing the types of the newly added columns:
|
Example
In this example, we consider the two problems:
(a) | maximize: | 2x + y | (b) | maximize: | 2x + y + 3z | |||||
subject to: | x + 4y | ≤ | 24 | subject to: | x + 4y + 2z | ≤ | 24 | |||
y | ≤ | 5 | y + z | ≤ | 5 | |||||
3x + y | ≤ | 20 | 3x + y | ≤ | 20 | |||||
x + y | ≤ | 9 | x + y + 3z | ≤ | 9 | |||||
z | ≤ | 12 |
Using
addcols, the following transforms (a) into (b):
p = xpress.problem () p.read ("example.lp") # assume this problem has at least four constraints p.addcols (obj = [3], mstart = [0,3], mrwind = [0, 1, 3], matval = [2,1,3], bdl = [-xpress.infinity], bdu = [12], names = ['john_cleese'], types = ['C'])
Further information
1. The constant
xpress.infinity can be used to represent infinite bounds.
2. If the columns are added to a MIP problem, then they will be continuous variables unless
types is specified. Use
problem.chgcoltype to impose integrality conditions on such new columns.
Related topics