A cost function is the performance measure you want to minimize. Examples of cost include total power consumption, integrated error, and deviation from a reference value of a signal. The cost function is a functional equation, which maps a set of points in a time series to a single scalar value. This scalar value is the cost.
Use the Cost type parameter of the SIM Optimal Design VI to specify the type of cost function you want this VI to minimize. The LabVIEW Control Design and Simulation Module includes the following types of cost functions:
You also can define a custom cost function using a VI template. To load this template, in the New dialog box, select VI»From Template»Simulation»Optimal Design»Compute Cost from the Create New tree.
The block diagram of this template contains several parameters including the control action u, the dynamic system output y, an array of input signals, and a time series vector. You also can specify any weights on any part of the cost function.
After you define these parameters, you can write LabVIEW block diagram code to manipulate the parameters according to the cost function. For example, the following equation defines the IE cost function.
where e(t) is the measured error, N is the total number of samples in the time response, n is the current time response sample, and i is the index of the current output.
You can view the VI that implements this cost function in the labview\vi.lib\Simulation\Optimization Based Design\Cost directory.
|Note If you create a cost function VI that does not take the control action into account, do not delete the u parameter from the block diagram. Deleting this parameter breaks the connector pane structure on which the SIM Optimal Design VI depends. Instead, leave the parameter unwired.|
After you save the custom cost function as a VI, you must specify the location of the custom function in the Problem Specification parameter of the SIM Optimal Design VI. Select User defined for the Cost type parameter and specify the path to the VI in the File path user defined custom cost calculation path control.