The following optimization problem is discussed in Haverly (1978) and Liebman et al. (1986). This example illustrates how to use PROC FCMP to define nonlinear constraints and use an MPS data set to define linear constraints. Maximize
subject to
and
In the following steps, the linear component of the problem definition is first described in PROC OPTMODEL and then saved
as an MPS data set. Because the objective is linear, no FCMP objective function needs to be used. In the second section of
steps, the nonlinear constraints are defined by using FCMP functions, and their corresponding names and lower and upper bounds
are stored in the data set condata
. The OPTLSO procedure is then called with the options NLINCON=
CONDATA and MPSDATA=
NLCEX.
As in Using MPS Format, you can use the macro definition lsompsmod
to strip brackets from the resulting data set:
%macro lsompsmod(setold,setnew); data &setnew(drop=i); set &setold; array FC{*} _CHARACTER_; do i=1 to dim(FC); FC[i] = compress(FC[i], "[]"); end; run; %mend;
proc optmodel; var x{1..10} >= 0; x[10].lb = 1; x[10].ub = 3; x[1].ub = 100; x[2].ub = 200; con x[3] + x[4] = x[6] + x[7], x[6] + x[8] = x[1], x[7] + x[9] = x[2], x[8] + x[9] = x[5]; max f = 9*x[1] + 15*x[2] - 6*x[3] - 16*x[4] - 10*x[5]; save mps nlcexOld; quit; %lsompsmod(nlcexOld, nlcex); proc fcmp outlib=sasuser.myfuncs.mypkg; function nlc1(x1,x6,x8,x10); return (2.5*x1 - x10*x6 - 2*x8); endsub; function nlc2(x2,x7,x9,x10); return (1.5*x2 - x10*x7 - 2*x9); endsub; function nlc3(x3,x4,x10); return (3*x3 + x4 - x10*(x3 + x4)); endsub; run; data condata; input _id_ $ _lb_ _ub_; datalines; nlc1 0 . nlc2 0 . nlc3 0 0 ;
options cmplib = sasuser.myfuncs; proc optlso primalout = solution mpsdata = nlcex nlincon = condata logfreq = 10; performance nthreads=2; run; proc print data=solution; run;
Output 3.6.1 shows the ODS tables that are produced from running these steps.
Output 3.6.1: Using Nonlinear Constraints: ODS Tables
Output 3.6.2 shows the iteration log from running these steps.
Output 3.6.2: Using Nonlinear Constraints: Log
NOTE: The OPTLSO procedure is executing in single-machine mode. |
NOTE: The OPTLSO algorithm is using up to 2 threads. |
NOTE: The problem has 10 variables (0 integer, 10 continuous). |
NOTE: The problem has 7 constraints (4 linear, 3 nonlinear). |
NOTE: The problem has 3 FCMP function definitions. |
NOTE: The deterministic parallel mode is enabled. |
Best |
Iteration Objective Infeasibility Evals Time |
1 0 0 170 0 |
11 399.967674198371 0 1274 0 |
21 400.003665875725 0.0006109165499 2468 0 |
31 400.014578082483 0.00093511701363 3663 1 |
41 400.014578082483 0.00093511701363 4828 1 |
NOTE: Function convergence criteria reached. |
NOTE: There were 3 observations read from the data set WORK.CONDATA. |
NOTE: The data set WORK.SOLUTION has 16 observations and 3 variables. |