SIM Optimal Design VI

Simulation VI and Function

SIM Optimal Design VI

Owning Palette: Optimal Design VIs

Installed With: Control Design and Simulation Module

Calculates parameter values that optimize a specified cost function while keeping parameters and outputs within specified bounds. This VI uses a finite-horizon time-domain simulation to obtain these values.

Note  This VI uses the Constrained Nonlinear Optimization VI, which uses the sequential quadratic programming (SQP) algorithm to compute optimal parameter values.

Details  Examples

 Place on the block diagram  Find on the Functions palette
Inequality Constraints specifies the upper and lower envelopes within which the following variables must lie: control actions, outputs, rate of change of control actions, and rate of change of outputs. Refer to the Details section for information about these envelopes.
User Defined Objective Function Path specifies the path to a custom objective function. If you define a custom objective function, you also must specify the Bounds corresponding to User Defined Objective Function Path parameter. You can use the SIM Objective Function template, located in the labview\templates\Simulation\Optimal Design directory, to design a custom objective function.
Note  When using a custom objective function, neither the Design parameters output nor the plots on the Current Data page of this VI update.
Parameter Bounds specifies the minimum and maximum values of each parameter, forming the region in which this VI searches for optimal values. The nth element of this parameter corresponds to the nth element of the Initial Parameters parameter.
Initial Parameters specifies the parameters you want to optimize and the initial values of each parameter. This VI uses these initial values to search the parameter space for optimal values. You define the parameter space using the Parameter Bounds parameter. The structure of the Initial Parameters parameter depends on the value you specify for the System response type parameter. Refer to the Details section for information about the structure of this parameter.
Note  Use the Initial Parameters Mesh parameter to generate more sets of initial values using the method you specify.
System Data specifies information about the system on which this VI operates. You can use the SIM Construct Default System VI to obtain this information.
Solver Parameters specifies the parameters, such as the ordinary differential equation (ODE) solver, this VI uses to simulate the finite-horizon time-domain response of the dynamic system model. These parameters are identical to the ones you configure using the Configure Simulation Parameters dialog box.
Problem Specification specifies the type of system response, inequality constraints, and cost function. You can select from a pre-defined list or substitute custom types.
Note  The LabVIEW Control Design and Simulation Module includes several templates you can use to create custom specification types. To access these templates, select File»New to launch the New dialog box. Select VI»From Template»Simulation»Optimal Design from the Create New tree to display templates for each specification type. If you create a custom specification type that does not use a parameter from the template, do not delete the parameter. Deleting an unused parameter from a template breaks the connector pane structure the SIM Optimal Design VI uses to operate.
System response type specifies the type of system response for which this VI returns optimal parameters. Refer to the Details section for information about how this VI uses the Initial Values parameter depending on the System response type you select.

0Default SISO - Optimize C (default)—Determines the optimal parameters of the controller C. C must be in parallel proportional integral derivative (PID) form.
1Default SISO - Optimize F1—Determines the optimal parameters of the reference filter F1.
2Default SISO - Optimize F2—Determines the optimal parameters of the control feedforward filter F2.
3User defined (SISO/MIMO)—Specifies that you want to use a file to define a custom system response type. If you select this option, you must specify a file in the File path user defined system structure text box.
File path user defined system response specifies a path to a file containing a custom system type. This parameter is valid only if you specify User defined (SISO/MIMO) for the System response type parameter.
Inequality constraints type specifies the type of inequality constraints this VI places on the system. You also can define custom inequality constraints.

0Time series constraint envelopes (default)—Specifies that this VI constrains the system using the upper and lower envelopes you specify for the Inequality Constraints parameter.
1User defined—Specifies that you want to use a file to define custom inequality constraints. If you select this option, you must specify a file in the File path user defined inequality constraints text box.
File path user defined inequality constraints specifies a path to a file containing custom inequality constraints. This parameter is valid only if you specify User defined for the Inequality constraints type parameter.
Cost type specifies the type of cost function this VI minimizes. This VI evaluates all cost functions using discrete data points the system response calculation generates. Refer to the Details section for information about each cost function.

0IE—Specifies a cost function that integrates the error.
1IAE—Specifies a cost function that integrates the absolute value of the error.
2ISE—Specifies a cost function that integrates the square of the error.
3ITAE—Specifies a cost function that integrates the time multiplied by the absolute value of the error.
4ITE—Specifies a cost function that integrates the time multiplied by the error.
5ITSE—Specifies a cost function that integrates the time multiplied by the square of the error.
6ISTE—Specifies a cost function that integrates the square of the time multiplied by the square of the error.
7LQ (default)—Specifies a linear quadratic cost function.
8SumOfVariances—Specifies a cost function based on the variance of the error multiplied by the variance of the control action.
9User defined—Specifies that you want to use a file to define a custom cost function. If you select this option, you must specify a file in the File path user defined cost calculation text box.
File path user defined cost calculation specifies a path to a file containing a custom cost function. This parameter is valid only if you specify User defined for the Cost type parameter.
Weights for cost function specifies any weights this VI applies to the Cost type function you select.
User data variant specifies the variant data you use to pass parameters at run time.
Initial Parameters Mesh specifies the method this VI uses to generate additional sets of initial parameter values. Generating more than one set of initial parameter values increases the possibility of finding global optimal parameter values instead of local optimal parameter values. This parameter also specifies the number of initial parameter value sets to generate.
Method specifies the method this VI uses to generate N additional points, where N equals the value you specify for the Number of Points parameter.

0Uniform grid—Generates N equally spaced points between the minimum and maximum parameter values.
1Uniform random—Generates N random points. Each point equals a random number between 0 and 1 scaled by the difference between the maximum and minimum parameter values.
2Quasirandom (default)—Generates N quasirandom points using Halton sequences.
3Random walk—Generates N random points within the constrained region.
Number of Points specifies the number of points for the Initial Parameters Mesh.
error in describes error conditions that occur before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use exception control to treat what is normally an error as no error or to treat a warning as an error. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.
code is the error or warning code. The default is 0. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source specifies the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.
stopping criteria is the collection of conditions that terminate the optimization. If (function tolerance AND parameter tolerance AND gradient tolerance) OR max iterations OR max function calls then optimization terminates.
function tolerance is the relative change in function value and is defined as abs(current f – prev f)/(abs(curr f)+machine eps). If the relative change in the function value falls below function tolerance, the optimization terminates.
parameter tolerance is the relative change in parameter values and is defined as abs(current p – prev p)/(abs(curr p)+machine eps). If the relative change of all the parameter values falls below parameters tolerance, the optimization terminates.
max iterations is the largest number of iterations of the major loop of the optimization. If the number of major loop iterations exceeds max iterations, the optimization terminates.
max function calls is the largest number of objective function calls allowed before terminating the optimization process.
gradient tolerance is the 2–norm of the gradient. If the 2–norm of the gradient falls below gradient tolerance, the optimization terminates.
Bounds corresponding to User Defined Objective Function specifies the minimum and maximum inequality constraint values for the User Defined Objective Function.
beginning state contains the initial values of the inequality constraint function, the lagrangian multipliers, and the hessian. beginning state is typically the ending state of a previous optimization and allows a warm start of the optimization.
inequality constraints contains the value of the inequality constraint functions, typically from a previous call to the Constrained Nonlinear Optimization VI.
lagrangian multipliers contains the value of the lagrangian multipliers, typically from a previous call to the Constrained Nonlinear Optimization VI.
hessian contains an estimate of the hessian, typically from a previous call to the Constrained Nonlinear Optimization VI.
cno settings contains additional tolerance and termination settings that are specific to this algorithm.
constraint weight is a relative weighting of the constraints as compared to the objective function and controls the distance that the optimization search travels outside the feasible range to seek an optimal solution. A value greater than 1 forces the search to stay close to the known feasible range, and a smaller value allows a broader range of searching.
maximum minor iterations is an upper bound on the number of iterations allowed to solve the quadratic subproblem. If the constraint functions are highly nonlinear, the linearized constraints used in the quadratic subproblem might not be very accurate. In this case, it might be sensible to limit the number of minor iterations, forcing the linear approximation to be updated more often.
Signals returns the time response for all outputs and control actions corresponding to each element of the Optimal costs parameter.
Output Signals returns information about the time response of the outputs.
Time returns the time steps at which this VI calculated the time response.
y returns the time response for the outputs. The elements of this parameter correspond with the elements of the Time parameter.
Control Signals returns information about the time response of the control actions.
Time returns the time steps at which this VI calculated the time response.
u returns the time response for the control actions. The elements of this parameter correspond with the elements of the Time parameter.
Design Parameters returns the set of parameter values that minimize the specified cost function. These values are the optimal parameter values.
Design Cost returns the result of the specified cost function if you apply the values from the Design parameters parameter.
Optimal parameters returns a list of possible optimal parameter values. Each column of this array corresponds to one parameter you specified in the Parameter Bounds parameter. Each row of this array corresponds to one search for optimal values.
Optimal costs returns the results of the specified cost function that correspond to each row of the Optimal parameters array.
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.
code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning.

SIM Optimal Design Details

Defining Inequality Constraint Envelopes

An envelope is a piecewise linear curve defined by the end points of linear segments. The following figure shows a typical pair of envelopes.

where points A,B,C, and D define the upper envelope and points E, F, G, and H define the lower envelope.

The Inequality Constraints parameter contains four arrays. Each array specifies the constraints on either the control actions, outputs, rate of change of control actions, or rate of change of outputs. Each array also includes two clusters, Upper Envelope Points and Lower Envelope Points. Both of these clusters include two arrays, Time and Amplitude. These arrays specify the x and y coordinates, respectively, that define the points that make up the envelope.

Note  Instead of specifying individual points, you can use the Graphically Specify Inequality Constraints VI, located in the labview\examples\Control and Simulation\Simulation\Optimal Control Design\Graphically Specify Inequality Constraints directory, to draw the upper and lower envelopes.

Cost Function Types

The following equations define the types of cost function J you can specify for the Cost type parameter.

wheree(t) is the error, defined as r(t) – y(t)
t is the simulation time
r is the reference signal
y is the output
u is the control action
n is the current time response sample
N is the maximum number of samples in the time response
W is the weight matrix you define using the Weights for cost function parameter
i is the index of the current output channel

Specifying the System Response Type and Defining Initial Parameter Values

The structure of the Initial Parameters parameter depends on the value you select for the System response type parameter.

If you select Default SISO - Optimize C, this VI returns optimal gain values KP, KI, and KD for a parallel PID controller defined by the following equation:

where a = 0.01.

In this situation, the first element of the Initial Parameters parameter must be the initial value of KP. The second and third elements must be the initial values of KI and KD, respectively.

If you select Default SISO - Optimize F1 or Default SISO - Optimize F2, this VI returns optimal coefficient values for the following transfer function equation that defines these filters.

In this situation, the Initial Parameters parameter contains the initial values of the numerator and denominator coefficients. You must separate this parameter into an equal number of numerator and denominator coefficients. Therefore, if a coefficient is 0, you must enter 0 in the appropriate element instead of leaving that element blank.

For example, if Initial Parameters is [5 6 0 0 0 6 3 0 9 2], this VI interprets the numerator coefficients as [5 6 0 0 0] in ascending powers of s. This VI interprets the denominator coefficients as [6 3 0 9 2] in ascending powers of s. Therefore, the following transfer function equation initially defines filter.

Examples

Refer to the following VIs for examples of using the SIM Optimal Design VI:

  • PID Design for Second Order Continuous System VI: labview\examples\Control and Simulation\Simulation\Optimal Control Design

     Open example  Browse related examples

  • PID Design for Second Order Discrete System VI: labview\examples\Control and Simulation\Simulation\Optimal Control Design

     Open example  Browse related examples