Documentation Center

  • Trial Software
  • Product Updates

sdo.evaluate

Evaluate cost function for samples

Syntax

  • [y,info] = sdo.evaluate(fcn,params) example
  • [y,info] = sdo.evaluate(fcn,params,param_samples)
  • [y,info] = sdo.evaluate(___,opts)

Description

example

[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.

[y,info] = sdo.evaluate(___,opts) specifies evaluation options that configure the evaluation error handling, display, and parallel computing options. This syntax can include any of the input argument combinations in the previous syntaxes.

Examples

expand all

Evaluate Cost Function Value for Parameter 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.

Input Arguments

expand all

fcn — Function to be minimized by sdo.optimizefunction handle

Function to be minimized by sdo.optimize, specified as a function handle.

For information about this function, see the description of the opt_fcn input argument in sdo.optimize. Also, see Writing a Cost Function.

params — Model parameters and statessdo.ParameterSpace object | vector of param.Continuous objects

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.

param_samples — Parameter samplestable

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.

opts — Evaluation optionssdo.EvaluateOptions object

Evaluation options, specified as an sdo.EvaluateOptions object.

Output Arguments

expand all

y — Cost function evaluationtable

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.

If you specify param_samples, Ns is equal to the number of rows of param_samples. Otherwise, Ns is equal to 2Np+1. Np is the number of parameters specified in params.

info — Evaluation informationstructure

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).

See Also

| | | |

Was this topic helpful?