The Black-Box Optimization Solver

Example 10.4 Using External Data Sets

This example illustrates the use of external data that are required in order to evaluate the objective function. The Bard function (Moré, Garbow, and Hillstrom 1981) is a least squares problem that has n equals 3 parameters and m equals 15 functions f Subscript k Baseline comma

f left-parenthesis x right-parenthesis equals one-half sigma-summation Underscript k equals 1 Overscript 15 Endscripts f Subscript k Superscript 2 Baseline left-parenthesis x right-parenthesis comma x equals left-parenthesis x 1 comma x 2 comma x 3 right-parenthesis

where

f Subscript k Baseline left-parenthesis x right-parenthesis equals y Subscript k Baseline minus left-parenthesis x 1 plus StartFraction k Over v Subscript k Baseline x 2 plus w Subscript k Baseline x 3 EndFraction right-parenthesis

with v Subscript k Baseline equals 16 minus k, w Subscript k Baseline equals min left-parenthesis u Subscript k Baseline comma v Subscript k Baseline right-parenthesis, and

y equals left-parenthesis 0.14 comma 0.18 comma 0.22 comma 0.25 comma 0.29 comma 0.32 comma 0.35 comma 0.39 comma 0.37 comma 0.58 comma 0.73 comma 0.96 comma 1.34 comma 2.10 comma 4.39 right-parenthesis

The minimum function value f left-parenthesis x Superscript asterisk Baseline right-parenthesis = 4.107E–3 occurs at the point left-parenthesis 0.08 comma 1.13 comma 2.34 right-parenthesis. In this example, the additional variable bounds negative 1,000 less-than-or-equal-to x Subscript i Baseline less-than-or-equal-to 1,000 for i equals 1 comma 2 comma 3 are added.

The following example code shows two approaches to specifying the objective function. The first approach assumes that the necessary data are stored within the FCMP function that defines the objective. In this case, you can specify the objective function without using an external data set, as follows:

proc fcmp outlib=work.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 = work.myfuncs;
proc optmodel;
   var x {1..3} >= -1000 <= 1000;
   min f = bard(of x[*]);
   solve with blackbox / nthreads=2;
   print x;
quit;

Output 10.4.1 shows the output from running these steps.

Output 10.4.1: Using External Data Sets

The OPTMODEL Procedure

Problem Summary
Objective SenseMinimization
Objective Functionf
Objective TypeNonlinear
  
Number of Variables3
Bounded Above0
Bounded Below0
Bounded Below and Above3
Free0
Fixed0
  
Number of Constraints0
  
Constraint Coefficients0

Solution Summary
SolverBlack-Box
Objective Functionf
Solution StatusFunction Convergence
Objective Value0.0041074408
  
Infeasibility0
Random Seed Used1
  
Evaluations4589
Cached Evaluations55
Iterations53
Presolve Time0.00
Solution Time0.09

[1]x
10.082419
21.133250
32.343536


The preceding approach can be prohibitive if the data set is large. As a second approach to specifying the objective function, you can define data in a SAS data set, read the data set into PROC OPTMODEL, and then use the values from that data set as part of the objective computation. This approach is shown in the following statements:

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
;

proc fcmp outlib=work.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 = work.myfuncs;
proc optmodel;
   set KSET;
   num y {KSET};
   read data barddata into KSET=[k] y;
   var x {1..3} >= -1000 <= 1000;
   min f = sum {k in KSET} bard(of x[*], k, y[k]);
   solve with blackbox / nthreads=2;
   print x;
quit;

Output 10.4.2 shows the output from running these statements.

Output 10.4.2: Using External Data Sets (II)

The OPTMODEL Procedure

Problem Summary
Objective SenseMinimization
Objective Functionf
Objective TypeNonlinear
  
Number of Variables3
Bounded Above0
Bounded Below0
Bounded Below and Above3
Free0
Fixed0
  
Number of Constraints0
  
Constraint Coefficients0

Solution Summary
SolverBlack-Box
Objective Functionf
Solution StatusFunction Convergence
Objective Value0.0041074408
  
Infeasibility0
Random Seed Used1
  
Evaluations4589
Cached Evaluations55
Iterations53
Presolve Time0.00
Solution Time0.09


Last updated: September 09, 2026