Design Optimization to Meet a Custom Objective (GUI)
This example shows how to optimize a design to meet a custom objective using the Response Optimization tool. You optimize the cylinder parameters to minimize the cylinder geometry and satisfy design requirements.
Hydraulic Cylinder Model
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.
Hydraulic Cylinder Design Problem
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 Response Optimization Tool
Open the Response Optimization tool to configure and run design optimization problems interactively using the command
Specify Design Variables
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 Response Optimization Tool Workspace.
Specify Design Requirements
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 Response Optimization Tool 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.
Designate the Requirement Name as MaxPressure. In both the start and end Amplitude columns, enter the maximum pressure requirement of 1.75e6 N/m, and set the Edge End Time to 0.1 s. In the Select Signals to Bound area, select Pressures, the signal on which this requirement applies.
- A new MaxPressure variable appears in the Response Optimization Tool 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 named PistonResponse, and the required rise and settling time bounds. Select PistonPosition as the signal to apply the step response requirement to.
Specify Custom Objective
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. %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
Evaluate the Initial Design
Click Plot Model 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 in the View tab.
From the plots, see that the maximum pressure requirement is satisfied but the piston position step response requirement is not satisfied.
Optimize the Design
Create a plot to display how the cylinder cross-sectional area and piston spring constant are modified during optimization.
In the Data to Plot drop-down list, select DesignVars, which contains the optimization design variables Ac and K. In the Add Plot drop-down, create a new iteration plot to show the design variable trajectories. For this new plot, click Show scaled values in the Iteration Plot tab, to facilitate viewing the two trajectories on the same axes.
Click Optimize in the Response Optimization tab.
The optimization progress window updates at each iteration and shows that the optimization converged after 4 iterations.
The Pressures and PistonPosition plots indicate that the design requirements are satisfied. The MinimizeAC plot shows that the cylinder cross-sectional area Ac is minimized.
To view the optimized design variable values, click the variable name in the Response Optimization Tool 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)".