Purpose
Used to load a
quadratic problem into the Optimizer data structure. Such a problem may have quadratic terms in its
objective function, although not in its constraints.
Synopsis
int XPRS_CC XPRSloadqp(XPRSprob prob, const char *probname, int ncol, int nrow, const char qrtype[], const double rhs[], const
double range[],
const double obj[], const int mstart[], const int mnel[], const int mrwind[], const double dmatval[], const double dlb[],
const double dub[],
int nqtr, const int mqc1[], const int mqc2[], const double dqe[]);
Arguments
prob
|
The current problem.
|
probname
|
A string of up to 200 characters containing a names for the problem.
|
ncol
|
Number of structural columns in the matrix.
|
nrow
|
Number of rows in the matrix (not including the objective row). Objective coefficients must be supplied in the obj array, and the objective function should not be included in any of the other arrays.
|
qrtype
|
Character array of length nrow containing the row types:
L
|
indicates a  constraint;
|
E
|
indicates an = constraint;
|
G
|
indicates a  constraint;
|
R
|
indicates a range constraint;
|
N
|
indicates a nonbinding constraint.
|
|
rhs
|
Double array of length nrow containing the right hand side coefficients of the rows. The right hand side value for a range row gives the upper bound on the row.
|
range
|
Double array of length nrow containing the range values for range rows. Values for all other rows will be ignored. May be NULL if there are no ranged constraints. The lower bound on a range row is the right hand side value minus the range value. The
sign of the range value is ignored - the absolute value is used in all cases.
|
obj
|
Double array of length ncol containing the objective function coefficients.
|
mstart
|
Integer array containing the offsets in the mrwind and dmatval arrays of the start of the elements for each column. This array is of length ncol or, if mnel is NULL, length ncol+1. If mnel is NULL the extra entry of mstart, mstart[ncol], contains the position in the mrwind and dmatval arrays at which an extra column would start, if it were present. In C, this value is also the length of the mrwind and dmatval arrays.
|
mnel
|
Integer array of length ncol containing the number of nonzero elements in each column. May be NULL if all elements are contiguous and mstart[ncol] contains the offset where the elements for column ncol+1 would start. This array is not required if the non-zero coefficients in the mrwind and dmatval arrays are continuous, and the mstart array has ncol+1 entries as described above. It may be NULL if not required.
|
mrwind
|
Integer array containing the 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 mrwind is mstart[ncol-1]+mnel[ncol-1] or, if mnel is NULL, mstart[ncol].
|
dmatval
|
Double array containing the nonzero element values; length as for mrwind.
|
dlb
|
Double array of length ncol containing the lower bounds on the columns. Use XPRS_MINUSINFINITY to represent a lower bound of minus infinity.
|
dub
|
Double array of length ncol containing the upper bounds on the columns. Use XPRS_PLUSINFINITY to represent an upper bound of plus infinity.
|
nqtr
|
Number of quadratic terms.
|
mqc1
|
Integer array of size nqtr containing the column index of the first variable in each quadratic term.
|
mqc2
|
Integer array of size nqtr containing the column index of the second variable in each quadratic term.
|
dqe
|
Double array of size nqtr containing the quadratic coefficients.
|
Related Controls
Integer
|
Number of extra columns to be allowed for.
|
|
Number of extra matrix elements to be allowed for.
|
|
Number of extra elements to allow for in presolve.
|
|
Number of extra rows to be allowed for.
|
|
Status for nonbinding rows.
|
|
Type of scaling.
|
Double
|
Zero tolerance on matrix elements.
|
Example
Minimize -6x
1 + 2x
12 - 2x
1x
2 + 2x
22 subject to x
1 + x
2 
1.9:
int nrow = 1, ncol = 2, nquad = 3;
int mstart[] = {0, 1, 2};
int mrwind[] = {0, 0};
double dmatval[] = {1, 1};
double rhs[] = {1.9};
char qrtype[] = {"L"};
double lbound[] = {0, 0};
double ubound[] = {XPRS_PLUSINFINITY,XPRS_PLUSINFINITY};
double obj[] = {-6, 0};
int mqc1[] = {0, 0, 1};
int mqc2[] = {0, 1, 1};
double dquad[] = {4, -2, 4};
double *primal, *dual;
primal = malloc(ncol*sizeof(double));
dual = malloc(nrow*sizeof(double));
...
XPRSloadqp(prob, "example", ncol, nrow, qrtype, rhs,
NULL, obj, mstart, NULL, mrwind, dmatval,
lbound, ubound, nquad, mqc1, mqc2, dquad)
Further information
1. The objective function is of the form c'x+x'Qx where Q is
positive semi-definite for minimization problems and negative semi-definite for maximization
problems. If this is not the case the optimization algorithms may converge to a local optimum or
may not converge at all. Note that only the upper or lower triangular part of the Q matrix is
specified.
2. The row and column indices follow the usual C convention of going from
0 to nrow-1 and 0 to ncol-1 respectively.
3. The double constants XPRS_PLUSINFINITY and XPRS_MINUSINFINITY
are defined in the Optimizer library header file.
Related topics
If you have any comments or suggestions about these pages,
please send mail to docs@dashoptimization.com.