Initializing help system before first use

problem.addcols

Purpose
Add columns to the problem after passing it to the Optimizer using the input routines.
Synopsis
problem.addcols(objcoef, start, rowind, rowcoef, lb, ub, names, types, unlinked=False)
Arguments
objcoef 
Array containing the objective function coefficients of the new columns.
start 
Array containing the offsets in the rowind and rowcoef arrays of the start of the elements for each column. The array must contain one more element than the number of columns to add, with the last element being the total number of coefficients across all columns.
rowind 
Array containing the rows (i.e. xpress.constraint objects, indices, or names) for the elements in each column.
rowcoef 
Array containing the element values.
lb 
Array containing the lower bounds on the added columns.
ub 
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:
indicates a continuous variable (default);
indicates an integer variable;
indicates a binary variable;
indicates a semi-continuous variable;
indicates a semi-continuous integer variable;
indicates a partial integer variable.
unlinked 
(optional) If True, unlinked variables will be created (deprecated).
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], start=[0,3], rowind=[0, 1, 3],
           matval=[2,1,3], lb=[-xpress.infinity], ub=[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

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.