This example uses data from Floudas and Pardalos (1992) and illustrates how to use the VARIABLES= and LINCON= options in conjunction with the OBJECTIVE= option. The problem has nine linear constraints and a quadratic objective function. Suppose you want to minimize
subject to
and
The following statements use the dense format to define the linear constraints:
data vardata; input _id_ $ _lb_ _ub_; datalines; x1 0 1 x2 0 1 x3 0 1 x4 0 1 x5 0 1 x6 0 1 x7 0 1 x8 0 1 x9 0 1 x10 0 100 x11 0 100 x12 0 100 x13 0 1 ; proc fcmp outlib=sasuser.myfuncs.mypkg; function quadobj(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13); sum1 = 5*(x1 + x2 + x3 + x4); sum2 = 5*(x1**2 + x2**2 + x3**2 + x4**2); sum3 = (x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13); return (sum1 - sum2 - sum3); endsub; run; data objdata; input _id_ $ _function_ $ _sense_ $; datalines; f quadobj min ; data lindata; input _id_ $ _lb_ x1-x13 _ub_; datalines; a1 . 2 2 0 0 0 0 0 0 0 1 1 0 0 10 a2 . 2 0 2 0 0 0 0 0 0 1 0 1 0 10 a3 . 2 0 2 0 0 0 0 0 0 0 1 1 0 10 a4 . -8 0 0 0 0 0 0 0 0 1 0 0 0 0 a5 . 0 -8 0 0 0 0 0 0 0 0 1 0 0 0 a6 . 0 0 -8 0 0 0 0 0 0 0 0 1 0 0 a7 . 0 0 0 -2 -1 0 0 0 0 1 0 0 0 0 a8 . 0 0 0 0 0 -2 -1 0 0 0 1 0 0 0 a9 . 0 0 0 0 0 0 0 -2 -1 0 0 1 0 0 ; options cmplib = sasuser.myfuncs; proc optlso primalout = solution objective = objdata variables = vardata lincon = lindata; performance nthreads=2; run; proc print data=solution; run;
The VARIABLES=
VARDATA option in the PROC OPTLSO statement specifies the variables and their respective bounds. The objective function is
defined by using PROC FCMP and the objective function name QUADOBJ. Other properties are described in the SAS data set objdata
. The linear constraints are specified by using the SAS data set lindata
, in which each row stores the (zero and nonzero) coefficients of the corresponding linear constraint along with their respective
lower and upper bounds. The problem description is then passed to the OPTLSO procedure by using the options VARIABLES=
VARDATA, OBJECTIVE=
OBJDATA, and LINCON=
LINDATA. The PERFORMANCE
statement specifies the number of threads that PROC OPTLSO can use.
Output 3.1.1 shows the output from running these statements.
Output 3.1.1: Using Dense Format
Problem Summary | |
---|---|
Problem Type | NLP |
Linear Constraints | LINDATA |
Objective Definition Set | OBJDATA |
Variables | VARDATA |
Number of Variables | 13 |
Integer Variables | 0 |
Continuous Variables | 13 |
Number of Constraints | 9 |
Linear Constraints | 9 |
Nonlinear Constraints | 0 |
Objective Definition Source | OBJDATA |
Objective Sense | Minimize |