Initializing help system before first use

xprs_loadproblemdata

Purpose
Loads a new optimization problem into the optimizer
Synopsis
xprs_loadproblemdata(prob = NULL, problemdata)
Arguments
prob 
an XPRSprob object, or NULL to create a new one
problemdata 
a named list that describes the input data. The 'problemdata' understands all input arguments of the function XPRSloadmiqcqp. See the details below.
Return value
the XPRSprob object with the given optimization model loaded; this is either the prob passed to the call, or a newly created XPRSprob object.
Example

# We load and solve the following Linear Program with 2 variables and 2 constraints.
#      min   x_1 +    x_2
#          5 x_1 +    x_2  >= 7
#            x_1 +  4 x_2  >= 9
#                 x_1,x_2  >= 0
library(xpress)
# create a list object to hold all input
problemdata <- list()
# objective coefficients
problemdata$objcoef <- c(1,1)
# row coefficients
problemdata$A <- matrix(c(5,1,1,4), nrow=2, byrow=TRUE)
# right-hand side
problemdata$rhs <- c(7,9)
# row sense
problemdata$rowtype <- c("G", "G")
# lower bounds (defaulting to 0 if unspecified)
problemdata$lb <- c(0,0)
# upper bounds(defaulting to Inf if unspecified)
problemdata$ub <- c(Inf,Inf)
# names for writing to MPS/LP files
problemdata$colname <- c("x_1", "x_2")
# Problem Name displayed when the solver solves the problem.
problemdata$probname <- "FirstExample"
# load everything into a new XPRSprob 'p'. You may also use the equivalent
#
# p <- createprob()
# xprs_loadproblemdata(p, problemdata=problemdata)
#
# for convenience and the use inside pipes,
# xprs_loadproblemdata returns the prob pointer.
#
p <- xprs_loadproblemdata(problemdata=problemdata)
Further information
The data of a new optimization model is passed as a list object. Each named property declares parts of the input data for the FICO Xpress Optimizer. The linear part of the constraints, usually denoted by a coefficient matrix A, can be specified in two alternative ways through 'problemdata'. Either as a dense or sparse matrix object, or in the classical column-major representation of the C-API of Xpress. The C-style input should specify the following attributes in 'problemdata'. Note that all index vectors must be 0-based, which is different from the usual R-convention! All names of the C-style input come from XPRSloadmiqcqp().
ncols
Number of structural columns in the matrix. This is optional and usually inferred from 'lb', 'ub', and 'objcoef' problemdata attributes
nrows
Number of rows in the matrix (not including the objective row). This is optional and usually inferred from 'rowtype', 'rhs', and 'rng' problemdata attributes
start
0-based(!) integer array containing the offsets in the rowind and rowcoef arrays of the start of the elements for each column. This array is of length ncols or, if collen is NULL, length ncols+1. If collen is NULL the extra entry of start, start[ncols+1], contains the position in the rowind and rowcoef arrays at which an extra column would start, if it were present. In C, this value is also the length of the rowind and rowcoef arrays
collen
Integer array of length ncols containing the number of nonzero elements in each column. May be NULL if all elements are contiguous and start[ncols+1] contains the offset where the elements for column ncols+1 would start. This array is not required if the non-zero coefficients in the rowind and rowcoef arrays are continuous, and the start array has ncols+1 entries as described above. It may be NULL if not required
rowind
Integer array containing the 0-based(!) row indices for the nonzero elements in each column. If the indices are input contiguously, with the columns in ascending order, the length of the rowind is start[ncols]+collen[ncols] or, if collen is NULL, start[ncols+1].
rowcoef
Double array containing the nonzero element values; length as for rowind
Alternatively, A can be specified directly as matrix input.
A
a dense or sparse matrix (column major or sparse triplet format) to input the linear constraint coefficients.
It is an error to specify A and any of the C-style input. The (in-)equalities are further described by a right-hand-side vector (usually denoted as b), the type of each constraint, and an optional rng vector.
rhs
Double array of length nrows containing the right hand side coefficients of the rows. The right hand side value for a rng row gives the upper bound on the row
rowtype
String array of length 'nrows' containing the row types:
"L"
indicates a '<=' constraint (use this one for quadratic constraints as well)
"E"
indicates an '=' constraint
"G"
indicates a '>=' constraint
"R"
indicates a rng constraint
"N"
indicates a nonbinding constraint
rng
Double array of length nrows containing the rng values for rng rows. Values for all other rows will be ignored. May be NULL if there are no ranged constraints. The lower bound on a rng row is the right hand side value minus the rng value. The sign of the rng value is ignored - the absolute value is used in all cases
Column properties are lower bounds, upper bounds, and objective coefficients.
objcoef
Double array of length 'ncols' containing the objective function coefficients
lb
Double array of length 'ncols' containing the lower bounds on the columns. Use XPRS_MINUSINFINITY to represent a lower bound of minus infinity
ub
Double array of length 'ncols' containing the upper bounds on the columns. Use XPRS_PLUSINFINITY to represent an upper bound of plus infinity
Column types can be specified for all columns. By default, all columns are continuous. However, columns can also have various discrete types. This happens either by indexing those columns that should be non-continuous in C-style, or by providing the "columntypes" (and optionally, a "columnlimits")-vector, thereby avoiding any 0 vs. 1-based index confusion.
nentities
Number of binary, integer, semi-continuous, semi-continuous integer and partial integer entities. This is optional, as it can be inferred from 'gqtype', and 'entind'
coltype
Character array of length nentities containing the entity types
"B"
binary variables
"I"
integer variables
"P"
partial integer variables
"S"
semi-continuous variables
"R"
semi-continuous integer variables
entind
Integer array of length nentities containing the column indices of the MIP entities
limit
Double array of length nentities containing the integer limits for the partial integer variables and lower bounds for semi-continuous and semi-continuous integer variables (any entries in the positions corresponding to binary and integer variables will be ignored). May be NULL if not required
Or full column type specification:
columntypes
A single character array of length 'ncols'. Besides the column types for 'coltype', specify all continuous columns by "C"
columnlimits
A single numeric array of length 'ncols' to specify limits for partial integer variables and lower bounds for semi-continuous and semi-continuous integer variables. This is not needed if no such types are present
It is an error if problemdata mixes columntypes in both representations, C-style and full column types style. A quadratic objective matrix can be specified as single (sparse or dense) matrix input 'Qobj', or in C-style notation. As matrix 'Qobj', in which case no index confusion between 0- and 1-based indexing can occur
Qobj
a dense or sparse matrix (column major or sparse triplet format) to input the quadratic objective terms
Or C-style input:
nobjqcoef
Number of quadratic terms of the objective
objqcol1
Integer array of size nobjqcoef containing the 0-based(!) column index of the first variable in each quadratic objective term
objqcol2
Integer array of size nobjqcoef containing the 0-based(!) column index of the second variable in each quadratic objective term
objqcoef
Double vector of size nobjqcoef containing the quadratic objective coefficients
The same for quadratic terms in constraints. Specify them in C-style notation, or as a single list 'Qrowlist' of length 'nrows' of matrix objects, sparse or dense, with NULL elements for the rows that do not have quadratic terms. The matrix-style input argument:
Qrowlist
list of dense or sparse numeric matrices (column major or sparse triplet format) of length 'nrows' that define the quadratic terms in each constraint.
Alternatively, use the classic C-style input variant:
nqrows
Number of rows containing quadratic matrices
qrowind
Integer vector of size qmn, containing the indices of rows with quadratic matrices in them. Note that the rows are expected to be defined in rowtype as type L
nrowqcoefs
Integer vector of size qmn, containing the number of nonzeros in each quadratic constraint matrix
rowqcol1
Integer vector of size nqcelem, where nqcelem equals the sum of the elements in nrowqcoefs (i.e. the total number of quadratic matrix elements in all the constraints). It contains the first column indices of the quadratic matrices. Indices for the first matrix are listed from 0 to qcnquads[0]-1, for the second matrix from qcnquads[0] to qcnquads[0]+ qcnquads[1]-1, etc
rowqcol2
Integer array of size nqcelem, containing the second index for the quadratic constraint matrices
rowqcoef
Double array of size nqcelem, containing the coefficients for the quadratic constraint matrices
Special Ordered Sets (SOS) restrict the number of columns with a nonzero solution value. SOS constraints must be input in sparse row representation. Each row represents one SOS constraint whose member columns are given as indices together with a reference row value. It is also necessary to specify the type of each set using the 'settype' argument.
settype
Character array of length nsets containing the set types:
1
SOS1 type sets
2
SOS2 type sets
nsets
Number of SOS1 and SOS2 sets. This is readily inferred from settype and need not be specified.
setstart
Integer array containing the offsets in the setind and refval arrays indicating the start of the sets. This array is of length nsets+1, the last member containing the offset where set nsets+1 would start
setind
Integer array of length setstart[nsets]-1 containing the columns in each set
refval
Double array of length setstart[nsets]-1 containing the reference row entries for each member of the sets
probname
A string of up to MAXPROBNAMELENGTH characters containing a name for the problem
colname
(optional) a vector specifying a name for each column of the problem
rowname
(optional) a vector specifying a name for each row of the problem

© 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.