Simulink Design Optimization
This example shows how to optimize a design to meet a custom objective using the Design Optimization tool. You optimize the cylinder parameters to minimize the cylinder geometry and satisfy design requirements.
The hydraulic cylinder model is based on the Simulink model sldemo_hydcyl. The model includes:
Pump and Cylinder Assembly subsystems. For more information on the subsystems, see "Single Hydraulic Cylinder Simulation".
A step change applied to the cylinder control valve orifice area that causes the cylinder piston position to change.
You tune the cylinder cross-sectional area and piston spring constant to meet the following design requirements:
Ensure that the piston position has a step response rise time of less than 0.04 seconds and setting time of less than 0.05 seconds.
Limit the maximum cylinder pressures to 1.75e6 N/m.
Minimize the cylinder cross-sectional area.
Open the Design Optimization tool to configure and run design optimization problems interactively.
Specify the following model parameters as design variables for optimization:
Cylinder cross-sectional area Ac
Piston spring constant K
In the Design Variables Set drop-down list, select New. A dialog to select model parameters for optimization opens.
Select Ac and K. Click <- to add the selected parameters to the design variables set.
Limit the cylinder cross-sectional area to circular area with radius between 1 and 2 centimeters and the piston spring constant to a range of 1e4 to 10e4 N/m. To do so, specify the maximum and minimum for the corresponding variable in the Maximum and Minimum columns.
Because the variable values are different orders of magnitude, scale Ac by 1e-3 and K by 1e5.
Press Enter after you specify the values.
Click OK. A new variable DesignVars appears in the SDOTOOL Workspace.
The design requirements require logged model signals. During optimization, the model is simulated using the current value of the design variables and the logged signal is used to evaluate the design requirements.
Log the cylinder pressures, which is the first output port of the Cylinder Assembly block.
In the New drop-down list, select Signal. A dialog to select model signals to log opens.
Enter Pressures as the signal name in the Signal set field. Then, in the Simulink model, click the first output port of the Cylinder Assembly block named Pressure. The dialog updates to display the selected signal.
Select the signal in the dialog and click -> to add it to the signal set.
Click OK. A new variable Pressures appears in the SDOTOOL Workspace.
Similarly, log the piston position, which is the second output of the Cylinder Assembly block, in a variable named PistonPosition.
Specify the maximum cylinder pressure requirement of less than 1.75e6 N/m.
In the New drop-down list, select Signal Bound. A dialog to create a signal bound requirement opens.
In the Amplitude columns, enter the maximum pressure requirement of 1.75e6 N/m and Requirement Name as MaxPressure. In the Select Model Signals area, select Pressures, the signal on which this requirement applies.
A new MaxPressure variable appears in the SDOTOOL Workspace.
A graphical view of the maximum pressure requirement is automatically created.
Specify the piston position step response requirement of rise time of less than 0.04 seconds and a settling time of less than 0.05 seconds.
In the New drop-down list of the Response Optimization tab, select Step Response Envelope. A dialog to create a step response requirement opens.
Specify a requirement name PistonResponse, the required rise and settling time bounds. Select PistonPosition as the signal to apply the step response requirement to.
The custom objective is to minimize the cylinder cross-sectional area.
In the New drop-down list, select Custom Requirement. A dialog to create custom requirement opens.
Specify a function to call during optimization in the Requirement function field. At each optimization iteration, the software calls the function and passes the current design variable values. You can also optionally pass logged signals to the custom requirement. Here, you use sdoHydraulicCylinder_customObjective as the custom requirement function, which returns the value of the cylinder cross-sectional area.
In the Requirement type drop-down list, specify whether the requirement is an objective to minimize (min), an inequality constraint (<=), or an equality constraint (==).
function objective = sdoHydraulicCylinder_customObjective(data) %SDOHYDRAULICCYLINDER_CUSTOMOBJECTIVE % % The sdoHydraulicCylinder_customObjective function is used to define a % custom requirement that can be used in the graphical SDTOOL environment. % % The |data| input argument is a structure with fields containing the % design variable values chosen by the optimizer. % % The |objective| return argument is the objective value to be minimized by % the SDOTOOL optimization solver. % % Copyright 2011 The MathWorks, Inc. % $Revision: 220.127.116.11 $ $Date: 2011/05/09 01:20:51 $ %For the cylinder design problem we want to minimize the cylinder %cross-sectional area so return the cylinder cross-sectional area as an %objective value. Ac = data.DesignVars(1); objective = Ac.Value; end
Click Plot Current Response to simulate the model and check how well the initial design satisfies the design requirements. To show both requirement plots at the same time, use the plot layout widgets at the top-right of the tool.
From the plots, see that the maximum pressure requirement is satisfied but the piston position step response requirement is not satisfied.
Create a plot to display how the cylinder cross-sectional area and piston spring constant are modified during optimization.
In the Add plot drop-down list, select DesignVars, which contains the optimization design variables Ac and K.
The optimization progress window updates at each iteration and shows that the optimization converged after 5 iterations.
The Pressures and PistonPosition plots indicate that the design requirements are satisfied. The DesignVars plot shows that the cylinder cross-sectional area Ac is minimized.
To view the optimized design variable values, click the variable name in the SDOTOOL Workspace. The optimized values of the design variables are automatically updated in the Simulink model.
To learn how to optimize the cylinder design using the sdo.optimize command, see "Design Optimization to Meet Custom Objective (Code)".
% Close the model setOption(sdotool('sdoHydraulicCylinder'),'NoPromptClose',true) bdclose('sdoHydraulicCylinder')