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:
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
| Problem Summary | |
|---|---|
| Objective Sense | Minimization |
| Objective Function | f |
| Objective Type | Nonlinear |
| Number of Variables | 1 |
| Bounded Above | 0 |
| Bounded Below | 0 |
| Bounded Below and Above | 1 |
| Free | 0 |
| Fixed | 0 |
| Number of Constraints | 0 |
| Constraint Coefficients | 0 |
| Solution Summary | |
|---|---|
| Solver | Black-Box |
| Objective Function | f |
| Solution Status | Function Convergence |
| Objective Value | -93.18498962 |
| Infeasibility | 0 |
| Random Seed Used | 1 |
| Evaluations | 284 |
| Cached Evaluations | 51 |
| Iterations | 11 |
| Presolve Time | 0.00 |
| Solution Time | 0.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
| Problem Summary | |
|---|---|
| Objective Sense | Minimization |
| Objective Function | f |
| Objective Type | Nonlinear |
| Number of Variables | 1 |
| Bounded Above | 0 |
| Bounded Below | 0 |
| Bounded Below and Above | 1 |
| Free | 0 |
| Fixed | 0 |
| Number of Constraints | 0 |
| Constraint Coefficients | 0 |
| Solution Summary | |
|---|---|
| Solver | Black-Box |
| Objective Function | f |
| Solution Status | Function Convergence |
| Objective Value | -93.22152602 |
| Infeasibility | 0 |
| Random Seed Used | 1 |
| Evaluations | 616 |
| Cached Evaluations | 95 |
| Iterations | 24 |
| Presolve Time | 0.00 |
| Solution Time | 0.01 |
| x |
|---|
| 9.7269 |