Evaluate cost function for samples
[y,info] = sdo.evaluate(fcn,params) evaluates the cost function, fcn, for samples of the parameter space specified by params (sdo.ParameterSpace object). The software generates a table of samples with 2Np+1 rows and Np columns. These samples are generated per the distributions specified by the ParameterDistributions, RankCorrelation, and Options properties of params. The software evaluates the cost function for each row of the samples table. y is a table with one column for each cost or constraint output returned by fcn and 2Np+1 rows. Np is the number of parameters specified in params.
[y,info] = sdo.evaluate(fcn,params,param_samples) evaluates the cost function for the specified parameter samples table, param_samples. For this syntax, you can specify params as an sdo.ParameterSpace object or a vector of param.Continuous objects.
y is a table with one column for each cost or constraint output returned by fcn. y contains as many rows as param_samples.
Create an arbitrary param.Continuous object.
p = param.Continuous('x',1);
Specify the parameter space definition for the model parameter.
ps = sdo.ParameterSpace(p);
Evaluate the cost function.
[y,info] = sdo.evaluate(@(p) sdoExampleCostFunction(p),ps);
The software generates 3 (2Np+1, Np = 1 parameter) samples and evaluates the sdoExampleCostFunction cost function for each sample.
Model parameters and states, specified as an sdo.ParameterSpace object or a vector of param.Continuous objects.
If you specify params as a vector of param.Continuous objects, you must also specify param_samples.
Parameter samples, specified as a table.
param_samples contains columns that correspond to free scalar parameters and rows that are samples of these parameters. Free scalar parameters refers to all the parameters specified by params whose Free property is set to 1. Specifying this property value as 1 indicates that the software can vary the value of this parameter during optimization.
Each column name must be equal to the name of the corresponding scalar parameter.
Cost function and constraint evaluations, returned as a table.
y is a table with one column for each cost or constraint output returned by fcn, and Ns rows.
Evaluation information, returned as a structure with the following fields:
Status — Evaluation status for each sample, returned as a cell array of strings.
Each entry of the cell array is one of the following strings:
'success' — Model evaluation was successful
'failure' — Model evaluation resulted all NaN results
'error' — Model evaluation resulted in an error
Stats — Time to evaluate all samples, returned as a structure with the following fields:
StartTime — Evaluation start time, returned as a six-element date vector containing the current date and time in decimal form: [year month day hour minute seconds]
EndTime — Evaluation end time, returned as a six-element date vector containing the current date and time in decimal form: [year month day hour minute seconds]
To determine the total evaluation time, use etime(info.EndTime,info.StartTime).