proceedings of the 4th international modelica - elib - dlr

13
Proceedings of the 4th International Modelica Conference, Hamburg, March 7-8, 2005, Gerhard Schmitz (editor) H. Elmqvist, H. Olsson, S.E. Mattsson, D. Brck, C. Schweiger, D. Joos, M. Otter Dynasim AB, Sweden DLR, Oberpfaffenhofen, Germany Optimization for Design and Parameter Estimation Paper presented at the 4th International Modelica Conference, March 7-8, 2005, Hamburg University of Technology, Hamburg-Harburg, Germany, organized by The Modelica Association and the Department of Thermodynamics, Hamburg University of Technology All papers of this conference can be downloaded from http://www.Modelica.org/events/Conference2005/ Program Committee Prof. Gerhard Schmitz, Hamburg University of Technology, Germany (Program chair). Prof. Bernhard Bachmann, University of Applied Sciences Bielefeld, Germany. Dr. Francesco Casella, Politecnico di Milano, Italy. Dr. Hilding Elmqvist, Dynasim AB, Sweden. Prof. Peter Fritzson, University of Linkping, Sweden Prof. Martin Otter, DLR, Germany Dr. Michael Tiller, Ford Motor Company, USA Dr. Hubertus Tummescheit, Scynamics HB, Sweden Local Organization: Gerhard Schmitz, Katrin Pr¨ olß, Wilson Casas, Henning Knigge, Jens Vasel, Stefan Wischhusen, TuTech Innovation GmbH

Upload: others

Post on 24-Feb-2022

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Proceedings of the 4th International Modelica - Elib - DLR

Proceedingsof the 4th International Modelica Conference,

Hamburg, March 7-8, 2005,Gerhard Schmitz (editor)

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. OtterDynasim AB, Sweden; DLR, Oberpfaffenhofen, GermanyOptimization for Design and Parameter Estimationpp. 255-266

Paper presented at the 4th International Modelica Conference, March 7-8, 2005,Hamburg University of Technology, Hamburg-Harburg, Germany,organized by The Modelica Association and the Department of Thermodynamics, Hamburg Universityof Technology

All papers of this conference can be downloaded fromhttp://www.Modelica.org/events/Conference2005/

Program Committee

• Prof. Gerhard Schmitz, Hamburg University of Technology, Germany (Program chair).

• Prof. Bernhard Bachmann, University of Applied Sciences Bielefeld, Germany.

• Dr. Francesco Casella, Politecnico di Milano, Italy.

• Dr. Hilding Elmqvist, Dynasim AB, Sweden.

• Prof. Peter Fritzson, University of Linkping, Sweden

• Prof. Martin Otter, DLR, Germany

• Dr. Michael Tiller, Ford Motor Company, USA

• Dr. Hubertus Tummescheit, Scynamics HB, Sweden

Local Organization: Gerhard Schmitz, Katrin Prolß, Wilson Casas, Henning Knigge, Jens Vasel, StefanWischhusen, TuTech Innovation GmbH

Page 2: Proceedings of the 4th International Modelica - Elib - DLR

largest weighted criterion is minimized). Ofcourse the maximum weighted criterion maychange during optimization depending on thetuner values found. Note that an aggregationfunction value less than 1 implies that all criteriasatisfy the demands.

There is an option to choose other aggregationfunction types like weighted sum. In any case theweights are formed by the reciprocal demandvalues.

• Constraints:Design specifications are often given as con-straints such as actuator limits. If a certain levelof compliance is achieved for a criterion, thislevel must be kept, and smaller (better) criterionvalues are not necessary. Constraints are formu-lated as criteria, which are requested to besmaller than the demand value. Optimizationprocedures account for constraints in their opti-mization strategy explicitly.

• Indicator plots:A criteria value results in one number to expressthe performance. This is necessary in order thatan optimizer can be used. A human would like toevaluate a design by visual comparison of resultplots of different designs, e.g., by viewing awhole step response curve and not only the over-shoot value. Indicator plots for a model can bedefined once and then reused, e.g., for onlinevisualization of the optimization or parameterestimation process.

• Model Cases:In many applications, several simulation runs arenecessary to evaluate a design or to estimate pa-rameters. In the Dymola environment, severalsimulation runs are collected together to modelcases: Exactly the same tuners, criteria and indi-cator plots are used for each model case. Themodel cases are distinguished only by a set offixed Modelica parameters that define the differ-ent simulation runs. Often, these case parametersdescribe different operating conditions, e.g., dif-ferent road or load conditions of a vehicle.

The paper shows for two application examples howto define the problem setup of tuners, criteria, casesand indicator plots by means of the graphical userinterface. The defined problem setups are used tosolve the calibration task of an under-actuated twojoint Furuta Pendulum and then the parameter opti-mization for robot control laws. The solution of themulti-criteria optimization problem is discussedbriefly in Section 4.

2 Application Examples

In this section, details of the experimentation envi-ronment are described elaborately by several exam-ples.

2.1 Parameter Estimation of an under-actuated

two joint Furuta Pendulum

Consider the Furuta pendulum demonstration of theDepartment of Automatic Control, Lund Institute of

Technology, Lund, Sweden. Thependulum, consisting of 2 revo-lute joints and 2 moving bodies,is shown in the figure. Only thefirst joint (vertical axis) is drivenby a DC motor. Experiments andcontroller have been designedand evaluated in [1].

Within Dymola, a model of the Furuta pendulum iseasily constructed by dragging, dropping and con-necting body and joint components from the Multi-Body library. However, it is also necessary to setphysical parameters in the model. Some of these pa-rameters such as the length of the arm or the lengthof the pendulum are easily measured on the system.Direct measurements of the weights of the partswould require the system to be dismounted (in othercases it is easy to measure the mass or determine itfrom a CAD system). Moreover, it is not simple tomeasure the inertia of the parts or the friction char-

acteristics of the two joints.

The new Dymola experimentation environment hasbeen used for parameter identification. For this, themovement of the 2 body pendulum has been re-corded by sensors in the joints. The same movementsare performed with a simulation model and the fric-tion parameters are optimized such that the measuredand the simulated movements closely agree.

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. Otter

The Modelica Association 256 Modelica 2005, March 7-8, 2005

Page 3: Proceedings of the 4th International Modelica - Elib - DLR

Optimization for Design and Parameter Estimation

Hilding Elmqvist1, Hans Olsson

1, Sven Erik Mattsson

1, Dag Brück

1,

Christian Schweiger2, Dieter Joos2, Martin Otter2

1Dynasim AB, Lund, Sweden ({Elmqvist, Hans.Olsson, SvenErik, Dag}@Dynasim.se)2DLR Institute of Robotics and Mechatronics, Oberpfaffenhofen, Germany

([email protected], [email protected], [email protected] )

Abstract

This paper describes new features of the Modelicaenvironment Dymola to perform integrated computerexperiments with Modelica models, in particular formodel calibration, design optimization androbustness or sensitivity assessment based onmultiple criteria and multiple simulation runs. Theenvironment and especially the problem setup aredemonstrated by several application examples.

1 Introduction

Recently, new features have been added to theModelica simulation environment Dymola [2] tosimplify experimentation with Modelica models sig-nificantly. Some basic ideas are from the optimiza-tion environment MOPS [3]. The central part is aModelica model of a physical system with Modelicaparameters that are not yet fixed. Several problemclasses can now be conveniently solved:

• Model Calibration (Parameter Estimation):Some Modelica parameters of the model are notknown. Several simulation runs are performedand compared with measurement data that isavailable from equivalent dynamic behavior ofthe real device. Via optimization, the selectedunknown parameters and initial conditions aredetermined such that the simulations and themeasurement data are in good agreement. Alsostandard tasks such as fitting of functions tomeasurement data is supported.

• Design Optimization

(Parameter Optimization):Selected Modelica parameters of the model aretuned to improve the system dynamics, e.g., bychanging the parameters of a controller or someparameters of the physical device. This is per-formed by multi-criteria parameter optimizationusing one or several simulation runs to compute

the desired criteria.

• Assessment (Parameter Variation):Selected Modelica parameters of the model aresystematically changed within a given grid andfor every fixed set of parameters, simulations areperformed. This might be used, e.g., to evaluatea finished design by varying the operatingpoints. For Monte Carlo simulations, the pa-rameter values are chosen statistically. Simula-tions with small variations to the parameters canbe used to determine how sensitive a design is.

All these experiment tasks utilize the same basicfunctionality that is defined once:

• Tuner Parameters:Modelica parameters that remain constant for aparticular simulation but are varied by the ex-perimentation environment to search for satis-factory solutions are called “tuners”. E.g. via pa-rameter estimation or optimization the tunersshall be determined such that criteria are mini-

mized.

• Criteria:Criteria are used to compute quantitative valuesof achieved performance of a simulation run.Criteria are assumed to be positive and smallervalues reflect better performance. Usually, sev-eral criteria are needed to express the desired be-havior. For example, typical criteria of a systemstep response are over-shoot or settling time. Byweighting each criterion individually by a fixeddemand value (criterion_i/demand_i), where thedemand value expresses the designer’s notion ofexpected system performance, a clear preferencelist of the criteria is defined. For example, thedemand value for the settling time might be 0.1s, indicating that a value of 0.1 s is satisfactoryfrom a users point of view.

To solve the multi-criteria problem by means ofstandard numerical optimization an overall crite-rion to be minimized has to be formulated. Thisso called aggregation function is by default themaximum function, yielding a min-max optimi-zation problem over the weighted criteria (= the

Optimization for Design and Parameter Estimation

The Modelica Association 255 Modelica 2005, March 7-8, 2005

Page 4: Proceedings of the 4th International Modelica - Elib - DLR

Selection of parameters to be tuned

When estimating parameters from measurements, abasic question is “Which parameters can be esti-mated from the measurements?” Changing a pa-rameter to be estimated must of course influence theoutput. However, this is not enough if several pa-rameters are to be estimated. Consider the arm of theFuruta pendulum. It rotates around a vertical axis.The model of the arm uses

Modelica.MultiBody.Parts.BodyShape

It has the following parameters: mass, position ofcenter of mass and inertia tensor with respect tocenter of mass. Since the arm is rotating around a fixaxis, it is only the inertia with respect to this axis thatinfluences the behavior of the system. Inertia withrespect to an axis being orthogonal to the verticalaxis does not influence the motion at all. The crite-rion is independent of its value. We will discuss amore general case. Let Jc denote the inertia with re-spect to a vertical axis through the center of mass.Let m denote the mass of the arm and rc denote thedistance between the point of rotation and the centerof mass. The inertia of the arm with respect to thepoint of rotation, Ja, is then

2

ccarmJJ ⋅+=

It is this inertia that is of importance for the rotationof the arm. It is this parameter that can be estimatedfrom measurements. It is not possible to estimate m,Jc or rc uniquely from measurements of positions or

velocities.

What will happen if we try to estimate Jc and m? Inthe best case we will get a good estimate of Ja, but Jc

and m may be really different from the their realphysical values. One approach to investigate if weare about to estimate too many parameters is to makeestimation experiments on the model. First one coulduse the model with its nominal parameter values toproduce simulated “measurement data”. Then onewould set the model parameters that are going to beestimated to other values, and run the calibrationprocedure using the previously produced “measure-ment data”. If the estimated parameters give thesame simulation results but are significantly differentfrom the “true” nominal ones, then this indicatesoverparametrization, because the nominal behaviorcan be reproduced by other parameter values than thenominal ones used to produce the “measurementdata”.

Assume rc = 0.1225 and being known. Assume thenominal values Jc= 0.0014 and m = 0.165. Assumethe criterion to be the integrated squared error of thependulum angle and arm angle. Let the pendulumstart in horizontal position and use the simulation

time 5 s. It is illustrative to plot the criterion versus Jc

and m as shown below.

We see a valley where the criterion is unchanged.Along the valley the effective inertia, Ja, is un-changed with peaks on either side where it has beenchanged. The error is not symmetric with respect tolarge variations in Ja and the error increases morewhen Ja decreases.

To compute this map we used a gridding functionthat takes the calibration task (as described below)and additionally the gridding parameters as inputs,i.e. we do not have to define the calibration tasktwice.

A further possibility is to investigate the sensitivityof the criterion with respect to the parameters esti-mated. In particular we can calculate the sensitivitymatrix (the Hessian of the minimization problem).Dymola calculates the sensitivity matrix by simulat-ing for disturbed parameters and taking differencesof the resulting criterion values obtained. The sensi-tivity matrix was found to be

[431064, 6456.3;

6456.3, 97.0671],

The eigenvalues being 431161 and 0.37 are very dif-ferent in magnitudes. Considering the numerical ac-curacy, the small eigenvalue may be considered asbeing zero. The eigenvector having the large eigen-value is {0.99989, 0.01498}. It means a large sensi-

tivity in the direction

{0.99989, 0.01498}*{Jc, m}

Recall Ja = Jc + 0.01501*m which shows that thecriterion is sensitive for variations in Ja. The secondeigenvector {-0.01498, 0.99989} is orthogonal. (Fora symmetric matrix, all eigenvalues are real and ei-genvectors are orthogonal.) The small eigenvalue,being very close to zero, indicates that the measuredbehavior is insensitive to variations in the directionof the second eigenvector as is also shown in plot

above.

Since the optimization problem is a non-linear least-

squares problem, ∑ )(2 pfi

, we can alternative com-

Optimization for Design and Parameter Estimation

The Modelica Association 257 Modelica 2005, March 7-8, 2005

Page 5: Proceedings of the 4th International Modelica - Elib - DLR

pute the insensitive direction (in a more numericallyrobust way) as the approximate null-space of

∑ ∂∂ ppfi

/)( .

It may be remarked that for the case where the crite-rion is independent of a parameter, there will be avalley parallel to the axis representing the parameterand the sensitivity matrix the vector in the directionof the parameter will be an eigenvector with zeroeigenvalue.

Thus for the arm we set rc = 0 and interpret the esti-mated inertia as being Ja. It means that we introducea top-level parameter I_arm and set arm.r_CM to

{0,0,0}, and arm.I_22 to I_arm.

The pendulum consists of a cylinder having a smallmass at the end. It is natural to assume its inertiawith respect to all axes perpendicular to its lengthaxis to be equal, call it I_pendulum. Set pendu-lum.I_11 = I_pendulum and set pendulum.I_33 =I_pendulum. The inertia sensed by the rotating armdepends on the angle of the pendulum, which meansthat for the pendulum, we can estimate also mass(pendulum.m) and position of the center of mass,r_CM_pendulum. We set pendulum.r_CM to {0,r_CM_pendulum, 0}.

Parameters in the friction model for the joints canalso be estimated. We assume Coulomb friction witha linear dependence on velocity. For the arm joint weintroduce tau11 and tau12 and set frictionR1.tau_posto [0, tau11; 1, tau12] and similarly for the pendulum

joint.

Setting up the calibration task

To set up the calibration task, select CalibrateModelfrom optimization package. Click the right mousebutton. Select Call Function. A dialog is shown:

It shows that the calibrate function has oneargument, setup. Clicking on the “+” opens it andshows that it is a record with five elements, whichdescribes various aspects of the calibartion taskincluding which parameters to tune, criterion andwhich measurement data to use. We will discuss thespecification of these elements in turn. The calibratefunction assumes the current model (last translated

model). This allows easy reference to parameterswhen selecting tuners as described below.

To specify which parameters to tune, click on thetunerParameters and the right pane of the dialogshows

Clicking on Select gives a browser for simpleselection where we tick the parameters as decided.

Clicking OK fills the tunerParameter dialog asshown in the following image.

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. Otter

The Modelica Association 258 Modelica 2005, March 7-8, 2005

Page 6: Proceedings of the 4th International Modelica - Elib - DLR

Estimating initial conditions

The initial conditions will be different for differentexperiments, for example, if we let the pendulumstart at different angles. To get good fits it is advis-able to estimate the initial conditions. We can givereasonable guesses, because we try to start the sys-tem in a well-defined state. For some experimentsthe initial conditions are known accurately and theyshould then be given as part of the setup of the cali-bration cases, but this is not the case here.

The joint models allow specification of initial condi-tions in terms of parameters. These parameters canbe tuned. For each of the parameter discussed previ-ously we would like to have a common tuned valuefor all cases.

However, for the initial conditions we need individ-ual estimation for each case. Moreover, we wouldalso need them to be tuned for the evaluation wherethe parameters tuned are kept fixed. The initial con-ditions to be estimated for each measurement caseare specified by the element freeStartValues. Selectthe element freeStartValues in the tree browser. It isspecified in the same way as done for tunerParame-ters. In the select dialog we tick the start values forthe angle and velocity of the two joints.

Clicking OK fills in the variable names in the firstcolumn and start values in the “Value” column.

To specify the criterion, select calibrationCriteria.

Clicking on Select displays a Select browser wherewe check pendulumAngle.phi and armAngle.phi.This fills the “name” column.

The criterion is a weighted sum of the integratedsquare difference with respect to measured value foreach variable.

The measurement files to be used are specified bythe element calibrationCases. It also specifieswhether a file is to be used for calibration or valida-tion.

The elements optimizer and integrator allows ad-vanced setting of optimization and simulation pa-rameters. We use their default settings, except for

simulation time that we need to specify.

Running the calibration

When all the input data have been entered, the cali-bration is started by clicking “Execute” on the dia-log. The two next plots compare the simulation resultwith the obtained tuned parameters and measureddata where the pendulum starts in a horizontal

Optimization for Design and Parameter Estimation

The Modelica Association 259 Modelica 2005, March 7-8, 2005

Page 7: Proceedings of the 4th International Modelica - Elib - DLR

position. The result shows a good agreement. Thetuned parameters were validated against another ex-periment where the pendulum starts in a more up-right position. The system is nonlinear and it is ofinterest to validate the model for cases where theamplitudes of the pendulum are large.

The jump in the pendulum angle in the validationcase between –100° and –80° is due to problems ofhandling wrap-around in the measurement device.The agreement is good, in particular for the pendu-lum motions. The modeling of the arm may be im-proved by a more elaborate modeling of the armfriction. However, that is out of the scope of this pa-per.

2.2 Robot optimization

In this section it is demonstrated how to optimize thecontroller parameters of a robot for a set of casesconsisting of different loads and reference motions.

Description of the robot

The model is chosen as the r3-robot from the Mode-lica standard library. As described in its documenta-

tion this was originally a Manutec r3-robot. It wasthen updated with incorporating CAD-data from aKUKA-robot, and the geometry was modified to fitthe CAD-data.

Figure 1 Animation of the robot

The robot consists of a 6 degree-of-freedom me-chanical structure modelled as the multibody system“mechanics” (= bodies connected together by revo-lute joints). The calculation of the animation can beoptionally switched off to increase simulation speed,which is especially important during an optimizationrun. Every joint is driven by a drive train called“axis1”, “axis2”, ..., in the next figure:

Figure 2 Composition diagram of robot

The desired reference motion is generated in compo-nent “path” and as input it has the start and end angleof each axis. All signal data is communicated via a“data bus”.

Figure 3 Drive train of one axis

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. Otter

The Modelica Association 260 Modelica 2005, March 7-8, 2005

Page 8: Proceedings of the 4th International Modelica - Elib - DLR

One drive train consists of a controller, an electricalmotor, a gearbox (which includes the bearing fric-tion). The controller of one axis is a P-PI cascadecontroller, i.e., has the simplest form useful for aservo drive (in most industrial robots, more sophisti-cated controllers are used). The goal of the optimiza-tion is to tune the values of the 3 controller parame-

ters of every axis:

• kp – gain of position controller

• ks – gain of speed controller

• Ts – integrator time constant of speed controller

The difficulty is that this controller should work wellwith a fixed set of values for all paths and operatingconditions encountered by the robot. This makes itimpossible to use standard, linear control designmethods.

Optimization setup

The structure of the optimization setup is similar tothe calibration setup:

The tuner parameters are the 3 controller parametersof each axis as discussed above. They are easily en-tered in the tunerParameter dialog by using the Sel-lect dialog. The snapshot below shows the dialogwhen the controller parameters of axis 2 have beenselected. Numeric values have also been entered for“Value” to be used as the start of the optimizationand minimum and maximum values that are used asbox constraints during optimization and optionally

also for scaling:

In order to specify the different cases of the optimi-zation, the case parameters are first selected by using

the Select dialog to browse the model parameters.The parameter values for the different cases used tooptimize the design of the controller are then givenby filling out the cases form as below (the selectedparameter names appear as column headings):

Simulation cases are defined by specific settings ofmodel parameters that are given as labels “startAn-gle2”, “startAngle3” etc. in the figure above. Notethat in the reference trajectory axis 2 goes throughdifferent movements in the different cases, whereasaxis 3 is fixed in different positions (all other axesare fixed to the default reference angle in all cases).In practice, robots are optimized for a larger numberof cases.

Optimization criteria

If we compare the actual axis speed with the refer-ence speed we normally get the following:

For design optimization the goal is in general not tosimply minimize these errors, as it would be for a

calibration, but something more advanced.

For the design optimization we thus have to intro-duce additional blocks to measure the performanceof the axis, these are introduced by extending therobot-model with an additional performance compo-nent for the reference signals (containing differentperformance indicator blocks).

Optimization for Design and Parameter Estimation

The Modelica Association 261 Modelica 2005, March 7-8, 2005

Page 9: Proceedings of the 4th International Modelica - Elib - DLR

In the performance Modelica model, the followingperformance indicator blocks are present (theseblocks are from a criteria library that contains severalpredefined useful criteria blocks):

• Block “Overshoot” computes the overshoot(here: the maximum deviation from the referenceangle) after the referenced motion has come to arest. This is performed very precisely by trig-gering an event whenever the derivative of theinput signal is zero (here: whenever the speed iszero), i.e., a minimum or maximum of the signalis reached and storing the corresponding signal,if its absolute value is larger than the previouslystored value. The last stored value is the over-

shoot which shall be minimized.

• Block “SettlingTime” computes the time until asignal stays completely within a tolerance bandaround zero, after the reference motion is in rest.This is performed by triggering an event when-ever the input signal passes through this bandand storing the corresponding time instants. Thelast stored value is the settling time which shall

be minimized.

The usage of these two blocks is shown above. Ascan be seen the angle error is used as input to the“overshoot” block whereas the speed error is used asinput in to the “settlingTime” block.

This is connected to the bus to get the reference sig-nals and the actual values for the specific axis. Wethen select two reference indicators, the overshootand the settling time, in the optimizer:

As an alternative to using criteria blocks in themodel one can compute the criteria in a post-processing function that operates on the simulationresults and which is selected in the drop down menushown below. In this case we select the final valuefor these two criteria:

We also have to set the demand values. Based onfirst simulations and specifications we set the over-shoot demand to 3/1000 [rad/s] and the settling timeto 0.3 [s]:

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. Otter

The Modelica Association 262 Modelica 2005, March 7-8, 2005

Page 10: Proceedings of the 4th International Modelica - Elib - DLR

Applying these values as demand values results inthe following weighted criteria:

case overshoot settling time

High 1 0.6854 0.7588

Low 1 1.5106 0.9855

High 2 0.8332 0.5579

Low 2 1.7887 1.0468

The values indicate satisfactory behavior in caseswith load (cases “High 1” and “High 2”), but badovershoot performance in unloaded cases (cases“Low 1” and “Low 2”).

After finalizing the optimization setup, a click on“Execute” starts the design optimization. As a resultof the first optimization run, which converges after30 function evaluations, we obtain the followingtuner and corresponding weighted criteria values:

kp2 3.0776

ks2 2.5089

Ts2 0.08896

overshoot settling time

High 1 0.5929 0.8998

Low 1 1.0315 1.0902

High 2 0.6510 0.7157

Low 2 1.1956 1.1955

Overshoot has been improved but settling time isslower. The equal and largest criteria values in case“Low 2” indicate a conflict between the 2 criteriawhich usually can only be solved when one criterionis eased off.

We decide to force the overshoot criteria that theyreach their demand values and to put lower emphasison settling time. This is accomplished by applyingall overshoot criteria as inequality constraints duringthe next optimization run forcing the optimizer toperform improvements in these criteria until the de-mand value is reached. Criteria to be minimized(here settling time) may increase. The next run re-sults in:

kp2 4.0722

ks2 4.8897

Ts2 0.070565

overshoot settling time

High 1 0.7623 0.8965

Low 1 0.8845 1.1855

High 2 0.6175 0.7161

Low 2 0.9985 1.2027

The overshoot demand is satisfied, The settling timeslightly increases to 1.2027 for the worst case “Low2”. We might stop the design optimization here. Inother cases, one might change demands, select othersimulations cases and criteria. In the next figure, re-sults for the 3 runs (initial, first and second optimi-

zation run) are shown for case “Low 2”:

3 Customizable user interfaces

Experimentation includes operations that require richinterfaces to supply all the information needed to

perform the task.

For model components, parameters have been visu-ally split into groups and tabbed pages, representinglogical grouping of primary and secondary parame-ters. However, the individual data items comprise a

relatively “flat” structure.

For calibration and optimization the interface con-tains a much deeper hierarchical structure, and thecomplexity at each level is also greater. For example,it is common that subitems contain variable amount

of data, typically represented by arrays of records.

To handle the increased complexity, the graphicaluser interface of Dymola has been extended in twodimensions:

• The nested structure is visualized by a tree,which makes relationships easier to understandand allows easy navigation between data items.

• Specialized GUI elements, for example, for fileand color selection, can be enabled by annota-tions, which facilitate common input operations.

Several of these improvements are useful also forsimpler data structures, and the specialized GUI ele-ments can also be used for parameters of models. In

Optimization for Design and Parameter Estimation

The Modelica Association 263 Modelica 2005, March 7-8, 2005

Page 11: Proceedings of the 4th International Modelica - Elib - DLR

other words, all the features discussed below can beeasily utilized by every user. It is even possible tomake a copy of the calibration and/or optimizationsetup and adapt the user interface to the specificneeds of an end-user with more specialized menus.

3.1 Nested structures

Model calibration will be used as an example. Thefunction CalibrateModel takes a record (setup) as itsinput parameter. The structure of the record containsamong other elements an array of type Tuner-Parameter, which in turn contains several attributes.

function CalibrateModel

"Calibrate model to measured data"

input ModelCalibrationSetup setup;

...

end CalibrateModel;

record ModelCalibrationSetup

String Model;

TunerParameter tunerParameters[:];

...

Optimizer optimizer;

Integrator integrator;

end ModelCalibrationSetup;

record TunerParameter

"Model parameter to be optimized ..."

String name="" "Full name of ...";

Boolean active=true "true, if ...";

...

end TunerParameter;

The GUI is automatically built from the data struc-ture declarations. The nested structure of the input toCalibrateModel is evident in the tree view at the left.

The tree serves two puposes. First it shows thestructure and makes it easier to understand whatinformation must be provided. The tree view corre-sponds exactly to the data structure. Second, it isused to navigate between multiple “pages” (input

forms) that are swapped into the space at the right.

The component tunerParameters is an array ofrecords, each containing several variables. The usercan choose a combined tabular view of the array (as

shown above), which offers maximum overview in acompact format.

Alternatively it is possible to inspect and editindividual array elements, which has the advantageof displaying descriptions for each input field andthat data can be grouped and put under different tabs.Each page corresponds to one row in the combinedview.

The implementation of the tree view also ensuresthat data filled out by the user is propagated. Forexample, changes to an individual tuner parametermust be visible when the user switches to the tabularview of all tuner parameters. Changes in a modifierat a high level is propagated down to more detailedviews.

3.2 New GUI elements

The graphical user interface can greatly simplifycertain input tasks with some additional support.Although it is always difficult to strike a balancebetween features and complexity, the following op-erations have been found useful in the experimenta-

tion environment.

The deployment of these GUI elements is controlledby model annotations, either at the class level or onindividual variables.

Predefined choices. A list of values suitable to aparticular type or application are presented. A simpleexample is “true” and “false” for Boolean. Selectionof a criteria function is specified by this annotation:

CriterionSpecification criteria

"Criteria specification"

annotation (choices(

choice=FinalValue(),

choice=SettlingTime(),

choice=Overshoot()));

To the user the choices are presented in a drop-downcombobox:

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. Otter

The Modelica Association 264 Modelica 2005, March 7-8, 2005

Page 12: Proceedings of the 4th International Modelica - Elib - DLR

Because parameters which depend on the selectedfunction must also be specified, pressing the “edit”button will display a dialog for the parameters to thechosen function.

Color selection. Colors can typically be representedby RGB (red, green, blue) or HSV (hue, saturation,value) tuples. Although they could be specified nu-merically by the user, a colorful dialog makes selec-tion much easier.

File selection. Standard dialogs for selecting fileseither for reading or writing data. The filename isstored in the corresponding variable.

Variable selection. Several operations in the ex-perimentation environment involves the selection ofvariables from the model, for example, parameters tooptimize. A specialized selection dialog simplifiesthe task considerably. Furthermore, additional data,such as, start/min/max values can be extracted.

In this case a detailed specification (in the form of anannotation) is needed to move data into the right

elements of a table, and if needed resize the table.

User-defined labels. The default labels used in thetree view or in the combined tabular view are con-structed from variable names found in the datastructure. By use of annotations, other labels can bespecified or even extracted from actual data in thestructure.

4 Solving the Multi-Criteria

Optimization problem

In a multi-criteria optimisation problem setup all

weighted criteria / ,ij ij ij minq c d ij S= ∈ can be com-

bined to a vector q , where min

S denotes the set of

all criteria (i) to be minimised defined in all simula-tion cases (j). In order to decide whether a solution

Iq is better than a solution

IIq , these vectors should

be completely comparable. However, comparingeach vector component individually, some compo-nents can be better, others can be worse. To makecriteria vectors completely comparable a vector normhas to be introduced.

We prefer to use the max-norm, because weightedcriteria with positive ‘the smaller the better’ valuesand quality limiting demands as upper bounds yield amost visible comparative satisfaction assessment ofdesign alternatives in case of the max-norm. Define

for all weighted criteria

: max{ }, ,ij min

ijq ij Sα = ∈

then requirements' satisfaction of a design alternative(II) is said to be better than of a design alternative (I)

if )()( III

αα < . If 1≤α , the design alternative is

called a satisfactory solution, because in that caseeach criterion is less than the respective demandvalue. In particular, a best possible design alternative

is characterised by }{min* αα = , yielding the over-

all constraint optimization problem which can besolved by standard optimization methods:

, ,

minmax{ ( ) / }

( ) ,

( ) ,

min

ij ijT ij S

ij ij inequality

ij ij equality

min k k max k

c T d

c T d ij S

c T d ij S

T T T

≤ ∈

= ∈

≤ ≤

(1)

The disadvantage of this approach is the lack of dif-ferentiability of the aggregation function. Thus,methods relying on gradients (like SQP methods)can encounter difficulties in this case.

To overcome the problem of differentiability weprovide two mechanisms: an exponential approxi-mation of the max-function yielding a smooth over-all criteria and a reformulation by ‘equivalent con-straints’. In the latter case the min-max problem canbe reformulated by an equivalent constrained prob-

lem. Let γ be a new variable for which we impose

that max{ ( ), }ij minq T ij Sγ ≥ ∈ . Instead of (1), we

can solve an equivalent optimization problem withthe extended parameter vector ],[ γTx = . The aggre-

gation function to be minimized is simply γα =)(x .

Defined inequality and equality constraints are ap-plied as in (1) while the components to be minimizedare added as additional constraints as

( ) ,ij minq x ij Sγ≤ ∈

The main advantage of this formulation is that thefunctions are differentiable provided the definedproblem criteria are differentiable. The disadvantageis that a problem of higher dimension is solved andadditional constraints are added. However, the appli-cation of this formulation of the min-max problem isrecommended whenever a gradient based optimiza-tion method is used. There is an option to choose

other aggregation functions like weighted sum:

: | |,ij min

ij

q ij Sα = ∈∑

Optimization for Design and Parameter Estimation

The Modelica Association 265 Modelica 2005, March 7-8, 2005

Page 13: Proceedings of the 4th International Modelica - Elib - DLR

Optimization Methods

At the moment 5 different methods to solve the op-timization problem (1) are implemented for use withModelica:

1. Sequential quadratic programming (SQP)2. Quasi Newton (Bounds)3. Pattern search (Pattern)4. Simplex method (Simplex)5. Genetic algorithm (GA)

The Sequential Quadratic Programming (SQP) ap-proach can be used to solve the general optimizationproblem and has usually a super-linear convergence(= faster than linear, and slower than quadratic con-vergence). Bounds on tuners and linear equality andinequality constraints are met exactly during the it-erations. The SQP approach needs gradients of func-tions and constraints. SQP in combination with thereformulation of the min-max optimization problemas an equivalent constraint problem is the method ofchoice for general optimization or calibration prob-lems.

The Quasi Newton method (Bounds) is an algorithmintended to solve large optimization problems butcan only handle simple bounds constraints on thetuners. “Bounds” needs also gradient information ofthe aggregation function.

The Pattern Search approach is a derivative freesearch method. It is numerically more robust intackling with non-smooth criteria than other meth-ods.

The Simplex approach is also a derivative-free algo-rithm and employs linear approximations to the ob-jective and constraint functions. The main advantageof SIMPLEX over many of its competitors is that ittreats each constraint individually when calculating achange to the variables, instead of lumping the con-straints together into a single penalty function. Adrawback of this method is that even bound con-

straints can be violated during computation.

The genetic algorithm (GA) is a global optimizationtechnique. The basic algorithm allows only simplebounds on the variables. Thus, to address more gen-eral constraints, penalty function techniques are em-ployed. The genetic algorithm search method isbased on evolution principles which guarantee thesurvival of the fittest individual. The use of GA foroptimization is normally quite costly in terms offunction evaluations.

5 Conclusions

An environment was presented to optimize Modelicamodels in Dymola, especially with regards to designoptimizations and calibration of unknown model pa-rameters.

It is possible to prepare a customized GUI in Dymolafor specific tasks such as optimization. This makes itpossible to customize the optimization menus. Sincethe customization is performed in Modelica (annota-tions) it is possible for an end-user to also adapt this

to his/her particular needs.

Acknowledgements

Measurements and calibration of the Furuta pendu-lum was performed by Marco Bracci as a part of hismaster-thesis project at the Department of AutomaticControl, Lund Institute of Technology, Lund, Swe-den.

References

[1] Åkesson J. (2000): Safe Manual Control of

Unstable Systems. Master Thesis, ISRNLUTFD2/TFRT--5646—SE, Department ofAutomatic Control, Lund Institute of Technology,Lund, Sweden.

[2] Dynasim (2005): Dymola - Users’ Manual

[3] Joos H.-D., Bals J., Looye G., Schnepper K., VargaA. (2002): A multi-objective optimisation based

software environment for control system design.Proc. IEEE International Conference on ControlApplications, Glasgow, Scotland, Sept. 18-20, pp. 7-14.

H. Elmqvist, H. Olsson, S.E. Mattsson, D. Bruck, C. Schweiger, D. Joos, M. Otter

The Modelica Association 266 Modelica 2005, March 7-8, 2005