The Black-Box Optimization Solver

Example 10.6 Discontinuous Function with a Lookup Table

This example illustrates the ability of the black-box solver to optimize a discontinuous function. The example generates arrays of discrete values that approximate a given smooth nonlinear function. The function that is optimized is simply using those data as a lookup table to find the appropriate discretized value. The underlying smooth function is defined as follows:

f left-parenthesis x right-parenthesis equals x sine left-parenthesis x right-parenthesis plus x squared cosine left-parenthesis x right-parenthesis

This first PROC OPTMODEL call shows how to optimize this function by using the discretized lookup approach:

%let N = 100;
%let L = 0;
%let U = 10;

proc optmodel;
   set OBS = 1..&N;
   num xdata {i in OBS} = &L + (i/&N)*(&U-&L);
   num ydata {i in OBS} = xdata[i]*sin(xdata[i]) + xdata[i]^2*cos(xdata[i]);
   var x >= &L <= &U;
   min f = sum {i in 1..&N-1} ydata[i] * (xdata[i] <= x < xdata[i+1]);
   solve with blackbox;
   print x;
quit;

The previous statements first create the lookup arrays (xdata and ydata) for x values at 100 (N) uniformly spaced points between 0 (L) and 10 (U). The objective function f is simply returning the discretized function value when the given x value is between two neighboring x values in the array. When the solver finds the appropriate location in the arrays, the smaller of the two nearest points is returned as the function value.

Output 10.6.1 shows the ODS tables that are produced.

Output 10.6.1: Discontinuous Function: ODS Tables

The OPTMODEL Procedure

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

Solution Summary
SolverBlack-Box
Objective Functionf
Solution StatusFunction Convergence
Objective Value-93.18498962
  
Infeasibility0
Random Seed Used1
  
Evaluations284
Cached Evaluations51
Iterations11
Presolve Time0.00
Solution Time0.01

x
9.7436


The following statements optimize the smooth version of the same function to demonstrate that virtually the same result is achieved in both cases:

proc optmodel;
   var x >= &L <= &U;
   min f = x*sin(x) + x^2*cos(x);
   solve with blackbox;
   print x;
quit;

Output 10.6.2 shows the ODS tables that are produced.

Output 10.6.2: Smooth Function: ODS Tables

The OPTMODEL Procedure

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

Solution Summary
SolverBlack-Box
Objective Functionf
Solution StatusFunction Convergence
Objective Value-93.22152602
  
Infeasibility0
Random Seed Used1
  
Evaluations616
Cached Evaluations95
Iterations24
Presolve Time0.00
Solution Time0.01

x
9.7269


Last updated: September 09, 2026