This example illustrates the use of external data sets that are specified in the OBJECTIVE= option. The Bard function (Moré, Garbow, and Hillstrom, 1981) is a least squares problem that has parameters and functions
where
with , , and
The minimum function value = 4.107E–3 occurs at the point . In this example, the additional variable bounds for are added.
There are two approaches to specifying the objective function. The first approach assumes that the necessary data are stored within the FCMP function. In this case, you can specify the objective function without using an external data set, as follows:
data vardata; input _id_ $ _lb_ _ub_ ; datalines; x1 -1000 1000 x2 -1000 1000 x3 -1000 1000 ; data objdata; input _id_ $ _function_ $ _sense_ $; datalines; f bard min ; proc fcmp outlib=sasuser.myfuncs.mypkg; function bard(x1, x2, x3); array y[15] /nosym (0.14 0.18 0.22 0.25 0.29 0.32 0.35 0.39 0.37 0.58 0.73 0.96 1.34 2.10 4.39); fx = 0; do k=1 to 15; vk = 16 - k; wk = min(k,vk); fxk = y[k] - (x1 + k/(vk*x2 + wk*x3)); fx = fx + fxk**2; end; return (0.5*fx); endsub; run; options cmplib = sasuser.myfuncs; proc optlso variables = vardata objective = objdata; performance nthreads=2; run;
Output 3.7.1 shows the output from running these steps.
Output 3.7.1: Using External Data Sets (I)
Performance Information | |
---|---|
Execution Mode | Single-Machine |
Number of Threads | 2 |
Parallel Mode | Deterministic |
Problem Summary | |
---|---|
Problem Type | NLP |
Objective Definition Set | OBJDATA |
Variables | VARDATA |
Number of Variables | 3 |
Integer Variables | 0 |
Continuous Variables | 3 |
Number of Constraints | 0 |
Linear Constraints | 0 |
Nonlinear Constraints | 0 |
Objective Definition Source | OBJDATA |
Objective Sense | Minimize |
Solution Summary | |
---|---|
Solution Status | Function convergence |
Objective | 0.0041074417 |
Infeasibility | 0 |
Iterations | 73 |
Evaluations | 6517 |
Cached Evaluations | 1149 |
Global Searches | 1 |
Population Size | 120 |
Seed | 1 |
This approach is cumbersome if the size of the required data increases. Furthermore, this approach is not possible if you are working in a distributed-data setting. As a second approach to specifying the objective function, PROC OPTLSO provides an alternate data input gateway that is described in the OBJECTIVE= data set, as shown in the following statements:
data vardata; input _id_ $ _lb_ _ub_ ; datalines; x1 -1000 1000 x2 -1000 1000 x3 -1000 1000 ; data barddata; k = _n_; input y @@; datalines; 0.14 0.18 0.22 0.25 0.29 0.32 0.35 0.39 0.37 0.58 0.73 0.96 1.34 2.10 4.39 ;
data objdata; input _id_ $ _function_ $ _sense_ $ _dataset_ $; datalines; fx bard min barddata ; proc fcmp outlib=sasuser.myfuncs.mypkg; function bard(x1, x2, x3, k, y); vk = 16 - k; wk = min(k,vk); fxk = y - (x1 + k/(vk*x2 + wk*x3)); return (0.5*fxk**2); endsub; run; options cmplib = sasuser.myfuncs; proc optlso variables=vardata objective=objdata; performance nodes=2 nthreads=8; run;
Output 3.7.2 shows the output from running these statements.
Output 3.7.2: Using External Data Sets (II)
Performance Information | |
---|---|
Host Node | wintergreen.unx.sas.com |
Execution Mode | Distributed |
Grid Mode | Symmetric |
Number of Compute Nodes | 2 |
Number of Threads per Node | 8 |
Parallel Mode | Deterministic |
Problem Summary | |
---|---|
Problem Type | NLP |
Objective Definition Set | OBJDATA |
Variables | VARDATA |
Number of Variables | 3 |
Integer Variables | 0 |
Continuous Variables | 3 |
Number of Constraints | 0 |
Linear Constraints | 0 |
Nonlinear Constraints | 0 |
Objective Definition Source | OBJDATA |
Objective Sense | Minimize |
Objective Data Set | barddata |
Solution Summary | |
---|---|
Solution Status | Function convergence |
Objective | 0.0041074417 |
Infeasibility | 0 |
Iterations | 73 |
Evaluations | 6517 |
Cached Evaluations | 1149 |
Global Searches | 1 |
Population Size | 120 |
Seed | 1 |