Main Content

优化设计来满足一个定制的目标(GUI)

This example shows how to optimize a design to meet a custom objective using theResponse Optimizerapp. 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® modelsldemo_hydcyl. The model includes:

  • 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 Optimizer

Open theResponse Optimizerto configure and run design optimization problems interactively using the following command.

sdotool('sdoHydraulicCylinder')

Specify Design Variables

指定以下模型参数作为设计variables for optimization:

  • Cylinder cross-sectional areaAc

  • Piston spring constantK

In theDesign Variables Setdrop-down list, selectNew. A dialog to select model parameters for optimization opens.

SelectAcandK. 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 theMaximumandMinimumcolumns.

Because the variable values are different orders of magnitude, scaleAcby 1e-3 andKby 1e5.

PressEnterafter you specify the values.

ClickOK. A new variableDesignVarsappears in theResponse Optimizerbrowser.

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 theCylinder Assemblyblock.

In theNewdrop-down list, selectSignal. A dialog to select model signals to log opens.

EnterPressuresas the signal name in theSignal setfield. Then, in the Simulink model, click the first output port of theCylinder Assemblyblock namedPressure. The dialog updates to display the selected signal.

Select the signal in the dialog and click ⇨ to add it to the signal set.

ClickOK. A new variablePressuresappears in theResponse Optimizerbrowser.

Similarly, log the piston position, which is the second output of theCylinder Assemblyblock, in a variable namedPistonPosition.

Specify the maximum cylinder pressure requirement of less than 1.75e6 N/m.

In theNewdrop-down list, selectSignal Bound. A dialog to create a signal bound requirement opens.

Designate theRequirement NameasMaxPressure. In both the start and endAmplitudecolumns, enter the maximum pressure requirement of 1.75e6 N/m, and set theEdge End Timeto 0.1 s. In theSelect Signals to Boundarea, selectPressures, the signal on which this requirement applies.

ClickOK.

  • A newMaxPressurevariable appears in theResponse Optimizerbrowser.

  • 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 theNewdrop-down list of theResponse Optimizationtab, selectStep Response Envelope. A dialog to create a step response requirement opens.

Specify a requirement namedPistonResponse, and the required rise and settling time bounds. SelectPistonPositionas the signal to apply the step response requirement to.

ClickOK.

Specify Custom Objective

The custom objective is to minimize the cylinder cross-sectional area.

In theNewdrop-down list, selectCustom Requirement. A dialog to create a custom requirement opens.

Specify a function to call during optimization in theRequirement Functionfield. 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 usesdoHydraulicCylinder_customObjectiveas the custom requirement function, which returns the value of the cylinder cross-sectional area.

In theRequirement Typedrop-down list, specify whether the requirement is an objective to minimize (min), an inequality constraint (<=), or an equality constraint (==).

typesdoHydraulicCylinder_customObjective
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

ClickPlot Model Responseto 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 theViewtab.

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 theData to Plotdrop-down list, selectDesignVars, which contains the optimization design variablesAcandK. In theAdd Plotdrop-down, create a new iteration plot to show the design variable trajectories. For this new plot, clickShow scaled valuesin theIteration Plottab, to facilitate viewing the two trajectories on the same axes.

ClickOptimizein theResponse Optimizationtab.

The optimization progress window updates at each iteration and shows that the optimization converged after 4 iterations.

ThePressuresandPistonPositionplots indicate that the design requirements are satisfied. TheMinimizeACplot shows that the cylinder cross-sectional areaAcis minimized.

To view the optimized design variable values, click the variable name in theResponse Optimizerbrowser. The optimized values of the design variables are automatically updated in the Simulink model.

Related Examples

To learn how to optimize the cylinder design using thesdo.optimizecommand, see优化设计来满足一个定制的目标(Code).