Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling...

13
Computers and Chemical Engineering 34 (2010) 1737–1749 Contents lists available at ScienceDirect Computers and Chemical Engineering journal homepage: www.elsevier.com/locate/compchemeng Modeling and optimization with Optimica and JModelica.org—Languages and tools for solving large-scale dynamic optimization problems J. Åkesson a,b,, K.-E. Årzén a , M. Gäfvert b , T. Bergdahl b , H. Tummescheit b a Department of Automatic Control, Lund University, P.O. Box 118, SE-221 00 Lund, Sweden b Modelon AB, Ideon Science Park, SE-223 70 Lund, Sweden article info Article history: Received 1 May 2009 Received in revised form 20 October 2009 Accepted 8 November 2009 Available online 29 December 2009 Keywords: Modelica Optimica Dynamic optimization Model predictive control abstract The Modelica language, targeted at modeling of complex physical systems, has gained increased atten- tion during the last decade. Modelica is about to establish itself as a de facto standard in the modeling community with strong support both within academia and industry. While there are several tools, both commercial and free, supporting simulation of Modelica models few efforts have been made in the area of dynamic optimization of Modelica models. In this paper, an extension to the Modelica language, entitled Optimica, is reported. Optimica enables compact and intuitive formulations of optimization problems, static and dynamic, based on Modelica models. The paper also reports a novel Modelica-based open source project, JModelica.org, specifically targeted at dynamic optimization. JModelica.org supports the Optimica extension and offers an open platform based on established technologies, including Python, C, Java and XML. Examples are provided to demonstrate the capabilities of Optimica and JModelica.org. © 2009 Elsevier Ltd. All rights reserved. 1. Introduction The complexity of products and processes is rapidly increasing. This complexity stems both from the increasing size of systems, and increasing heterogeneity of systems. In order to manage such complexity and to encode system knowledge in a structured way, modeling languages, primarily intended for simulation of dynamic models, have been traditionally used. An example of such a lan- guage is Modelica (The Modelica Association, 2007). While modeling and simulation remain important tools for engineers in many disciplines, the landscape is shifting towards a more flexible and diverse use of model-based design method- ologies. This trend raises new demands on associated tools. In particular, model-based process and product development com- monly includes activities such as simulation, parameter sensitivity analysis, design optimization and control system development and deployment. Commonly, these activities are performed in a highly iterative manner. Fig. 1 illustrates a typical work cycle. Accord- ingly, flexibility and interoperability are key success factors for algorithms and tools in order to meet future challenges. This paper focuses on dynamic optimization in the context of high-level modeling languages, in particular Modelica. Optimiza- Corresponding author. Tel.: +46 46 2228797. E-mail addresses: [email protected] (J. Åkesson), [email protected] (K.-E. Årzén), [email protected] (M. Gäfvert), [email protected] (T. Bergdahl), [email protected] (H. Tummescheit). tion is used extensively in many industrial branches, in particular in the process industry. Applications include design optimization to develop optimal processes, set-point optimization to minimize raw material and energy consumption, and on-line optimal control strategies such as model predictive control. While there are several tools supporting dynamic optimization, they are typically restricted to a particular modeling domain and a particular numerical algo- rithm. In this paper, a different approach is taken. In particular, the problem of optimizing heterogeneous physical systems while enabling use of a wide range of numerical algorithms is considered. Sophisticated numerical optimization algorithms often have cumbersome APIs, which do not always match the engineering need for high-level description formats. For example, it is not uncommon for such numerical packages to be written in C, or in Fortran, and that they require the dynamic system to be mod- eled as an ODE/DAE, which is also encoded in C or Fortran. In addition, it may be required to also encode first and second order derivatives. Although there are efficient tools for automatic differ- entiation encoding of dynamic optimization problems in low-level languages 1 like C or FORTRAN is often cumbersome and error- prone. An important goal of developing high-level languages for dynamic optimization is therefore to bridge the gap between the engineering need for high-level descriptions and the APIs of numer- ical algorithms. 1 The term low-level is relative, but is here used in relation to domain-specific languages like Modelica. 0098-1354/$ – see front matter © 2009 Elsevier Ltd. All rights reserved. doi:10.1016/j.compchemeng.2009.11.011

Transcript of Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling...

Page 1: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

Mt

Ja

b

a

ARRAA

KMODM

1

Tacmmg

eaopmadiia

h

k(h

0d

Computers and Chemical Engineering 34 (2010) 1737–1749

Contents lists available at ScienceDirect

Computers and Chemical Engineering

journa l homepage: www.e lsev ier .com/ locate /compchemeng

odeling and optimization with Optimica and JModelica.org—Languages andools for solving large-scale dynamic optimization problems

. Åkessona,b,∗, K.-E. Årzéna, M. Gäfvertb, T. Bergdahlb, H. Tummescheitb

Department of Automatic Control, Lund University, P.O. Box 118, SE-221 00 Lund, SwedenModelon AB, Ideon Science Park, SE-223 70 Lund, Sweden

r t i c l e i n f o

rticle history:eceived 1 May 2009eceived in revised form 20 October 2009ccepted 8 November 2009

a b s t r a c t

The Modelica language, targeted at modeling of complex physical systems, has gained increased atten-tion during the last decade. Modelica is about to establish itself as a de facto standard in the modelingcommunity with strong support both within academia and industry. While there are several tools, both

vailable online 29 December 2009

eywords:odelicaptimicaynamic optimization

commercial and free, supporting simulation of Modelica models few efforts have been made in the area ofdynamic optimization of Modelica models. In this paper, an extension to the Modelica language, entitledOptimica, is reported. Optimica enables compact and intuitive formulations of optimization problems,static and dynamic, based on Modelica models. The paper also reports a novel Modelica-based opensource project, JModelica.org, specifically targeted at dynamic optimization. JModelica.org supports theOptimica extension and offers an open platform based on established technologies, including Python, C,

are pr

odel predictive control Java and XML. Examples

. Introduction

The complexity of products and processes is rapidly increasing.his complexity stems both from the increasing size of systems,nd increasing heterogeneity of systems. In order to manage suchomplexity and to encode system knowledge in a structured way,odeling languages, primarily intended for simulation of dynamicodels, have been traditionally used. An example of such a lan-

uage is Modelica (The Modelica Association, 2007).While modeling and simulation remain important tools for

ngineers in many disciplines, the landscape is shifting towardsmore flexible and diverse use of model-based design method-

logies. This trend raises new demands on associated tools. Inarticular, model-based process and product development com-only includes activities such as simulation, parameter sensitivity

nalysis, design optimization and control system development andeployment. Commonly, these activities are performed in a highly

terative manner. Fig. 1 illustrates a typical work cycle. Accord-

ngly, flexibility and interoperability are key success factors forlgorithms and tools in order to meet future challenges.

This paper focuses on dynamic optimization in the context ofigh-level modeling languages, in particular Modelica. Optimiza-

∗ Corresponding author. Tel.: +46 46 2228797.E-mail addresses: [email protected] (J. Åkesson),

[email protected] (K.-E. Årzén), [email protected]. Gäfvert), [email protected] (T. Bergdahl),[email protected] (H. Tummescheit).

098-1354/$ – see front matter © 2009 Elsevier Ltd. All rights reserved.oi:10.1016/j.compchemeng.2009.11.011

ovided to demonstrate the capabilities of Optimica and JModelica.org.© 2009 Elsevier Ltd. All rights reserved.

tion is used extensively in many industrial branches, in particularin the process industry. Applications include design optimizationto develop optimal processes, set-point optimization to minimizeraw material and energy consumption, and on-line optimal controlstrategies such as model predictive control. While there are severaltools supporting dynamic optimization, they are typically restrictedto a particular modeling domain and a particular numerical algo-rithm. In this paper, a different approach is taken. In particular,the problem of optimizing heterogeneous physical systems whileenabling use of a wide range of numerical algorithms is considered.

Sophisticated numerical optimization algorithms often havecumbersome APIs, which do not always match the engineeringneed for high-level description formats. For example, it is notuncommon for such numerical packages to be written in C, or inFortran, and that they require the dynamic system to be mod-eled as an ODE/DAE, which is also encoded in C or Fortran. Inaddition, it may be required to also encode first and second orderderivatives. Although there are efficient tools for automatic differ-entiation encoding of dynamic optimization problems in low-levellanguages1 like C or FORTRAN is often cumbersome and error-

prone. An important goal of developing high-level languages fordynamic optimization is therefore to bridge the gap between theengineering need for high-level descriptions and the APIs of numer-ical algorithms.

1 The term low-level is relative, but is here used in relation to domain-specificlanguages like Modelica.

Page 2: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

1738 J. Åkesson et al. / Computers and Chemica

Fp

(holptstipRie

tpoflttr(tbipfptpauwt(

MIapS

2

2

lsts

environment, Modelica code is typically not immediately suitable

ig. 1. A typical work cycle for formulation and solution of dynamic optimizationroblems.

This paper presents an extension of the Modelica languageThe Modelica Association, 2007), entitled Optimica, dedicated toigh-level formulation of dynamic optimization problems basedn Modelica models. Optimica consists of a few but powerful newanguage constructs that enable the user to express optimizationroblems using high-level descriptions on par with Modelica. Usinghe Optimica extension, optimization interval, cost function, con-traints and information related to the numerical algorithm usedo solve the problem can be specified. A key feature of Optimicas that the formulation of the optimization problem is done inde-endently of the numerical algorithm used to solve the problem.ather, the algorithm and associated control parameters are spec-

fied using light weight language constructs that make it easy tovaluate the applicability of several different algorithms.

In order to demonstrate the feasibility and effectiveness ofhe proposed Optimica extension, a Modelica-based open sourcelatform called JModelica.org (Modelon AB, 2009) is under devel-pment. The objective of the JModelica.org platform is to create aexible and extensible Modelica environment focused on optimiza-ion. The software consists of several parts; compiler front-endso transform Modelica and Optimica code into a canonical rep-esentation, compiler back-ends to generate efficient model codecurrently C and XML), implementations of dynamic optimiza-ion algorithms. In addition, the compilers and algorithms haveeen interfaced with Python in order to offer a convenient script-

ng and prototyping environment. The main objective of theroject is to create an industrially viable Modelica environmentor optimization, yet offering rich opportunities for research. Inarticular, JModelica.org forms a vehicle for communicating indus-rially relevant applications into the academic community and forropagating state of the art numerical algorithms developed in thecademic community into industrial use. JModelica.org can also besed for experimental language design where Modelica is extendedith new functionality, or as a comprehensive environment for

eaching. For more information, see the JModelica.org home pageModelon AB, 2009).

The paper is outlined as follows. In Section 2, backgrounds onodelica, dynamic optimization, and optimization tools is given.

n Section 3, the Optimica extension is presented. Section 4 givesn overview of the JModelica.org open source project, and exam-les are given in Section 5. The paper ends with a summary inection 6.

. Background

.1. Modelica

Modelica is the result of an effort to create a unified modeling

anguage for complex heterogeneous physical systems. The efforttarted in the mid nineties with the objective of gathering prac-itioners from several application fields, including thermo-fluidystems, robotics, electronics, mechanics and avionics. In addition,

l Engineering 34 (2010) 1737–1749

researchers specializing in computer science were part of the groupthat published the first version of the Modelica language spec-ification in 1997. The language is continuously maintained anddeveloped by the non-profit organization The Modelica Association(2007)—since the start in 1997 there have been about 60 designmeetings where the language has been discussed and improved.The latest version of the specification, Modelica 3.0, was publishedin September 2007.

The Modelica language builds on principles of earlier languages,notably Omola (Mattsson & Andersson, 1992). Also, the bond graphformalism (Karnopp & Rosenberg, 1968), influenced the design. Oneof the main targets of Modelica is to enable modeling of differentphysical domains in one unified language. This approach differsfrom some other modeling frameworks such as SPICE (Nagel &Pederson, 1973) and VHDL-AMS (IEEE, 1997) which are specializedon electrical circuits, gPROMS (Process Systems Enterprise, 2007)specialized in chemical processes, and ADAMS (MSC Software,2007) specialized in simulation of mechanical systems. While thisheterogeneous modeling strategy enables a high degree of flexibil-ity, it should also be noted that Modelica lacks some specializedfeatures, for example intrinsic PDE support.

Modelica shares several properties with other modern model-ing languages, including gPROMS and VHDL-AMS. Modelica is anobject-oriented language, supporting fundamental concepts suchas packages, classes, inheritance, and components. These abstrac-tions enable structuring and reuse of complex models. Modelicais based on acausal equations, rather than assignment statements.This property has far-reaching consequences in terms of ease ofuse, since it enables the user to input equations, both differen-tial and algebraic, in a natural text-book style. In particular, thisfeatures eliminates the need to solve for the derivatives. In orderto enable component-based modeling, Modelica offers a mecha-nism to explicitly model acausal physical interfaces: connectors. Aconnector models the physical quantities involved in the interfaceby means of through and across variables, e.g., flow and pressure.When a component with connectors of the same type is con-nected, the signal directions need not be determined by the user,but are rather given by the topology of the component network.This methodology is fundamentally different from that of block-based modeling used in e.g., Simulink, see Åström, Elmqvist, andMattsson (1998) for a discussion. Modelica also supports joint tex-tual and graphical modeling, mixed continuous discrete (hybridbehavior), user defined functions, and interfacing with external Cor Fortran code. For a comprehensive overview of Modelica, seeFritzson (2004).

Typically, Modelica code is organized into reusable modellibraries. Commonly, domain expert knowledge is encoded in theform of Modelica libraries, which are then used by applicationengineers to construct model instances corresponding to a partic-ular process or plant. The users of Modelica can then be roughlycategorized into two groups: library developers and applicationdevelopers. Library developers typically work with encoding of thelaws of nature in the form of differential algebraic equations andstructuring of the code. Application engineers on the other hand,typically use predefined components and connect them togetherin a graphical model editor. There are numerous Modelica librariesavailable, both commercially and freely available, ranging fromthermodynamics and power plants to automotive and space appli-cations. There is also a freely available standard library for Modelicafrom The Modelica Association (2007).

While the Modelica language provides a convenient modeling

for integration with numerical algorithms. A Modelica tool there-fore needs to perform several transformation steps in order toproduce model code which in turn can be interfaced with an algo-rithm for simulation or optimization. The procedure is illustrated

Page 3: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

J. Åkesson et al. / Computers and Chemica

icohratDTihcn

ause

2

ttp(bnBmat

cPW(pl

psafiddmsfibtoia

c

Fig. 2. The Modelica compilation process.

n Fig. 2. In a first step called flattening, the hierarchical Modelicaode is transformed into a flat representation consisting essentiallyf variables and equations. This representation corresponds to aybrid DAE, but it is still not suitable for use with numerical algo-ithms, since it may be of high index, and it may also contain severallias variables which can be eliminated. In a second step, struc-ural and symbolic algorithms are applied in order transform theAE into a structured form. The equations are then sorted usingarjans algorithm (Tarjan, 1972) and index reduction is performedf needed (Mattsson & Söderlind, 1993). The result is a structuredybrid DAE of index one. In a final step, efficient code (typically Code) is generated. This code, in turn, is suited for integration withumerical algorithms.

There are several tools supporting Modelica, both commercialnd free. Commercial tools include Dymola (Dynasim, 2009), Sim-lation X (ITI, 2009) and MapleSim (Maplesoft, 2009). The openource project OpenModelica (PELAB, 2009) offers an free Modelicanvironment which is mainly targeted at simulation.

.2. Dynamic optimization

During the last five decades, the theory of dynamic optimiza-ion has received much attention. In 1957, Bellman formulatedhe celebrated principle of optimality, and showed that dynamicrogramming was applicable to a broad range of applicationsBellman, 1957). Following this work, dynamic programming haseen applied to various fields, notably inventory control, eco-omics, statistics, and engineering. For a modern description, seeertsekas (2000) and Bertsekas (2000). Using dynamic program-ing, an optimal control law can be derived from the solution ofpartial differential equation, the Hamilton–Jacobi–Bellman equa-

ion.Another important contribution to the theory of optimal

ontrol is the maximum principle, which was presented byontryagin, Boltyanskii, Gamkrelidze, and Mishchenko (1962).hereas dynamic programming provides a closed loop control law

the control law as a function of the system states), the maximumrinciple provides the necessary conditions for an open loop control

aw (the control law as a function of time) to be optimal.2

Both dynamic programming and the maximum principle haveractical drawbacks that make them hard to apply to large scale-ystems. For example, in the presence of inequality constraints, thectivation sequence must be known a priori. Also, it may be dif-cult to find initial guesses for adjoint variables. In the last twoecades, a new family of methods has emerged to overcome theseifficulties. These methods are referred to as direct methods. Directethods attempt to solve dynamic optimization problems by tran-

cribing the original infinite dimensional dynamic problem into anite dimensional static optimization problem. There are two mainranches within the family of direct methods, referred to as sequen-

ial and simultaneous methods, see Binder et al. (2001) for anverview. The sequential methods rely on state of the art numericalntegrators, typically also capable of computing state sensitivities,nd standard nonlinear programming (NLP) codes. The controls

2 There are some exceptions, where the maximum principle yields a closed loopontrol law, for example in the case of linear systems and quadratic cost.

l Engineering 34 (2010) 1737–1749 1739

are then usually approximated by piece-wise polynomials, whichrender the controls to be parametrized by a finite number of param-eters. These parameters are then optimized. See e.g., Vassiliadis(1993) and Kraft, 1994 for details on sequential methods. Simul-taneous methods, on the other hand, are based on collocation, andapproximate both the state and the control variables by means ofpiece-wise polynomials, see Biegler, Cervantes, and Wächter (2002)for an overview. This strategy requires a fine-grained discretizationof the states, in order to approximate the dynamic constraint withsufficient accuracy. Accordingly, the NLPs resulting from applica-tion of simultaneous methods are not only very large, but alsosparse. In order to solve large-scale problems, the structure of theproblem needs to be explored. A detailed treatment of direct collo-cation methods is given in Betts (2001).

A popular extension of the single shooting algorithms is multipleshooting (Bock & Plitt, 1984). In a multiple shooting algorithm, theoptimization interval [t0, tf ] is divided into a number of segments.New optimization variables corresponding to the initial conditionsfor the states in each segment, are then introduced. This enablesthe dynamics, as well as the sensitivity equations, to be integratedindependently in each segment. In order to enforce continuity of thestate profiles, equality constraints are introduced in the optimiza-tion problem to ensure continuous state profiles. Extensions of themultiple shooting algorithm include the DAE case, see Bock, Eich,and Schlöder (1988), and application to real-time model predictivecontrol, see Diehl et al. (2002).

2.3. Optimization tools

There are several tools for optimization on the market, offer-ing different features. In essence, three different categories oftools can be distinguished, although the functionality is some-times overlapping. Model integration tools addresses the problemof interfacing several design tools into a single computation envi-ronment, where analysis, simulation and optimization can beperformed. Examples are ModelCenter (Phoenix Integration, 2009),OptiY (OptiY, 2009), modeFRONTIER (ESTECO, 2009), and iSIGHT(Dassault, 2009). Typically, such tools are dedicated to design opti-mization of extremely complex systems which may be composedfrom subsystems encoded in different tools. Accordingly, modelintegration tools typically offers interfaces to CAD and finite ele-ment software as well as simulation tools for, e.g., mechanicaland hydraulic systems. As a result of the heterogeneity and com-plexity of the target models, models are usually treated as blackboxes, i.e. the result of a computation is propagated to the tool,but the structure of a particular model is not explored. Accord-ingly, heuristic optimization algorithms which do not requirederivative information or detailed structural information, are usu-ally employed. In addition, model integration tools often havesophisticated features supporting model approximation and visu-alization.

Several modeling tools come with optimization add-ons, e.g.,Dymola (Dynasim, 2009), gPROMS (Process Systems Enterprise,2007) and Jacobian (Numerica Technology, 2007), which is a suc-cessor of the Abacuss system (Clabaugh, 2001). Such tools typicallyoffer strong support for modeling of physical systems and simula-tion. The level of support for optimization in this category differsbetween different tools. Dymola, for example, offers add-ons forparameter identification and design optimization (Elmqvist et al.,2005). gPROMS, specifically the module gOPT, on the other hand,offers support for solution of optimal control problems and has

the additional benefit in comparison with Modelica tools to pro-vide support for partial differential equations (PDEs). Tools in thiscategory are usually limited to a predefined set of optimizationalgorithms. Integration of new algorithms may be difficult if thetools do not provide the necessary APIs.
Page 4: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

1 emica

opoittdrrotppwdd

lagbsatirr

mitslsoo

3

3

ski

the other hand, in some cases, reformulation of discontinuities tosmooth approximations may be possible in order to enable efficientoptimization. This is particularly important in on-line applications.

740 J. Åkesson et al. / Computers and Ch

In the third category we have numerical packages for dynamicptimization, often developed as part of research programs. Exam-les are ACADO (OPTEC K.U. Leuven, 2009), Muscod II (Universityf Heidelberg, 2009), and DynoPC (Lang & Biegler, 2007), whichs based on Ipopt (Wächter & Biegler, 2006). Such packages areypically focused on efficient implementation of an optimiza-ion algorithm for a particular class of dynamic systems. Also,etailed information about the model to optimize is generallyequired in order for such algorithms to work, including accu-ate derivatives and in some cases also sparsity patterns. Somef the packages in this category are also targeting optimal con-rol and estimation problems in real-time, e.g., non-linear modelredictive control, which require fast convergence. While theseackages offer state of the art algorithms, they typically comeith simple or no user interface. Their usage is therefore limitedue to the effort required to code the model and optimizationescriptions.

The JModelica.org platform is positioned to fill the gapeft between simulation tools offering optimization capabilitiesnd state of the art numerical algorithms. In comparison withPROMS/gOPT, the main advantages of JModelica.org are that it isased on an open standard, Modelica, it comes with open interfacesuitable for algorithm integration, and that it is freely availables open source software. Now, gPROMS/gOPT are highly sophis-icated products which have been applied in a large number ofndustrial applications. JModelica.org, on the other hand, is cur-ently more geared towards experimental algorithm development,esearch and education.

Primarily, target algorithms of JModelica.org are gradient-basedethods offering fast convergence. Never the less, JModelica.org

s well suited for use also with heuristic direct search methods;he requirements with respect to execution interface is typically aubset of the requirements for gradient based methods. The prob-ems addressed by model integration tools is currently beyond thecope of JModelica.org, even though its integration with Pythonffers extensive possibilities to develop custom applications basedn the solution of simulation and optimization problems.

. Optimica

.1. Information structure

In order to formulate a dynamic optimization problem, to beolved by a numerical algorithm, the user must supply differentinds of information. It is natural to categorize this informationnto three levels, corresponding to increasing levels of detail.

Level I. At the mathematical level, a canonical formulation ofa dynamic optimization problem is given. This include vari-ables and parameters to optimize, cost function to minimize,constraints, and the Modelica model constituting the dynamicconstraint. The optimization problem formulated at this levelis in general infinite dimensional, and is thereby only partial inthe respect that it cannot be directly used by a numerical algo-rithm without additional information, for example, concerningtranscription of continuous variables.Level II. At the transcription level, a method for translatingthe problem from an infinite dimensional problem to a finitedimensional problem needs to be provided. This might includediscretization meshes as well as initial guesses for optimization

parameters and variables. It should be noticed that the infor-mation required at this level is dependent on the numericalalgorithm that is used to solve the problem.Level III. At the algorithm level, information such as tolerances andalgorithm control parameters may be given. Such parameters are

l Engineering 34 (2010) 1737–1749

often critical in order to achieve acceptable performance in termsof convergence, numerical reliability, and speed.

An important issue to address is whether information associatedwith all levels should be given in the language extension. In Mod-elica, only information corresponding to Level I is expressed in theactual model description. Existing Modelica tools then typically useautomatic algorithms for critical tasks such as state selection andcalculation of consistent initial conditions, although the algorithmscan be influenced by the user via the Modelica code, by means ofannotations,3 or attributes, such as StateSelect. Yet other infor-mation, such as choice of solver, tolerances and simulation horizonis provided directly to the tool, either by means of a graphical userinterface, a script language, or alternatively, in annotations.

For dynamic optimization, the situation is similar, but the needfor user input at the algorithm level is more emphasized. Auto-matic algorithms, for example for mesh selection, exist, but maynot be suitable for all kinds of problems. It is therefore desirable toinclude, in the language, means for the user to specify most aspectsof the problem in order to maintain flexibility, while allowing forautomatic algorithms to be used when possible and suitable.

Relating to the three levels described above, the approach takenin the design of Optimica is to extend the Modelica language witha few new language constructs corresponding to the elements ofthe mathematical description of the optimization problem (LevelI). The information included in Levels II and III, however, may ratherbe specified by means of annotations.

3.2. Dynamic system model

The scope of Optimica can be separated into two parts. Thefirst part is concerned with the class of models that can bedescribed in Modelica. Arguably, this class is large, since verycomplex, non-linear and hybrid behavior can be encoded in Mod-elica. From a dynamic optimization perspective, the inherentcomplexity of Modelica models is a major challenge. Typically,different algorithms for dynamic optimization support differentmodel structures. In fact, the key to developing efficient algo-rithms lies in exploiting the structure of the model being optimized.Consequently, there are different algorithms for different modelstructures, such as linear systems, non-linear ODEs, general DAEs,and hybrid systems. In general, an algorithm can be expected tohave better performance, in terms of convergence properties andshorter execution times, if the model structure can be exploited. Forexample, if the model is linear, and the cost function is quadratic,the problem can be obtained very efficiently by solving a Riccatiequation. On the other hand, optimization of general non-linearand hybrid DAEs is still an area of active research, see for exampleBarton & Lee, 2002. As a result, the structure of the model highlyaffects the applicability of different algorithms. The Optimica com-piler presented in this paper relies on a direct collocation algorithmin order to demonstrate the proposed concept. Accordingly, therestrictions imposed on model structure by this algorithm applywhen formulating the Modelica model, upon which the optimiza-tion problem is based. For example, this excludes the use of hybridconstructs, since the right hand side of the dynamics is assumedto be twice continuously differentiable. Obviously, this restric-tion excludes optimization of many realistic Modelica models. On

The Optimica extension, as presented in this paper, could also be

3 Annotations are light weight Modelica language elements that are typically usedto provide options to algorithms and solvers.

Page 5: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

emica

et

3

rff

u

s

F

a

c

c

c

c

waattoit[dp

((ei

ttuotfcfssc

wm

l

m

s

F

c

J. Åkesson et al. / Computers and Ch

xtended to support other algorithms, which are indeed applicableo a larger class of models.

.3. The dynamic optimization problem

The second part of the scope of Optimica is concerned with theemaining elements of the optimization problem. This includes costunctions, constraints and variable bounds. Consider the followingormulation of a dynamic optimization problem:

min(t),p (z, p) (1)

ubject to the dynamic system:

(x(t), x(t), y(t), u(t), p, t) = 0, t ∈ [t0, tf ] (2)

nd the constraints:

ineq(x(t), y(t), u(t), p) ≤ 0, t ∈ [t0, tf ] (3)

eq(x(t), y(t), u(t), p) = 0, t ∈ [t0, tf ] (4)

pineq

(z, p) ≤ 0 (5)

peq(z, p) = 0 (6)

here x(t) ∈Rnx are the dynamic variables, y(t) ∈Rny are thelgebraic variables, u(t) ∈Rnu are the control inputs, and p∈Rnpre parameters which are free in the optimization. In addition,he optimization is performed on the interval t ∈ [t0, tf ], where0 and tf can be fixed or free, respectively. The initial valuesf the dynamic and algebraic variables may be fixed or freen the optimization. The vector z is composed from discreteime points of the states, controls and algebraic variables; z =x(t1),..,x(tNp ), y(t1),..,y(tNp ), u(t1),..,u(tNp )]T , ti ∈ [t0, tf ], where Npenotes the number of time points included in the optimizationroblem.

The constraints include inequality and equality path constraints,3) and (4). In addition, inequality and equality point constraints,5) and (6), are supported. Point constraints are typically used toxpress initial or terminal constraints, but can also be used to spec-fy constraints for time points in the interior of the interval.

The cost function (1) is a generalization of a terminal cost func-ion, �(tf ), in that it admits inclusion of variable values at otherime instants. This form includes some of the most commonlysed cost function formulations. A Lagrange cost function can bebtained by introducing an additional state variable, xL(t), withhe associated differential equation xL(t) = L(x(t), u(t)), and the costunction (tf ) = xL(tf ). The need to include variable values at dis-rete points in the interior of the optimization interval in the costunction arises for example in parameter estimation problems. Inuch cases, a sequence of measurements, yd(ti), obtained at theampling instants ti, i∈ 1 . . . Nd is typically available. A cost functionandidate is then:Nd

i=1

(y(ti) − yd(ti))TW(y(ti) − yd(ti)) (7)

here y(ti) is the model response at time ti and W is a weightingatrix.Another important class of problems is static optimization prob-

ems on the form:

inu,pϕ(x, y, u, p)

ubject to

(0, x, y, u, p, ts) = 0 (8)

ineq(x, u, p) ≤ 0

l Engineering 34 (2010) 1737–1749 1741

ceq(x, u, p) = 0

In this case, a static optimization problem is derived from a, poten-tially, dynamic Modelica model by setting all derivatives to zero.Since the problem is static, all variables are algebraic and accord-ingly, no transcription procedure is necessary. The variable tsdenotes the time instant at which the static optimization problemis defined.

In this paper a direct collocation method (see for exampleBiegler et al., 2002) will be used to illustrate how the transcriptionstep can also be encoded in the Optimica extension. The infor-mation that needs to be provided by the user is then a meshspecification, the collocation points, and the coefficients of theinterpolation polynomials.

3.4. The Optimica extension

In this section, the Optimica extension will be presented andinformally defined. The presentation will be made using the follow-ing dynamic optimization problem, based on a double integratorsystem, as an example:

minu(t)

∫ tf

0

1 dt (9)

subject to the dynamic constraint:

x(t) = v(t), x(0) = 0v(t) = u(t), v(0) = 0

(10)

and

x(tf ) = 1, v(tf ) = 0v(t) ≤ 0.5, −1 ≤ u(t) ≤ 1

(11)

In this problem, the final time, tf , is free, and the objective is thusto minimize the time it takes to transfer the state of the doubleintegrator from the point (0, 0) to (1, 0), while respecting boundson the velocity v(t) and the input u(t).

In summary, the Optimica extension consists of the followingelements:

• A new specialized class: optimization.• New attributes for the built-in type Real: free and ini-

tialGuess.• A new function for accessing the value of a variable at a specified

time instant.• Class attributes for the specialized class optimization: objec-

tive, startTime, finalTime and static.• A new section: constraint.• Inequality constraints.• An annotation for providing transcription information.

3.4.1. A new specialized class

It is convenient to introduce a new specialized class, called

optimization, in which the proposed Optimica-specific con-structs are valid. This approach is consistent with the Modelicalanguage, since there are already several other specialized classes,e.g., record, function and model. By introducing a new specialized

Page 6: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

1 emica

cgaa3cc

caphWpaap

l

di

3

tFecofmaft

tIaftalictfpids

ot

s

742 J. Åkesson et al. / Computers and Ch

lass, it also becomes straightforward to check the validity of a pro-ram, since the Optimica-specific constructs are only valid insiden optimization class. The optimization class corresponds ton optimization problem, static or dynamic, as specified in Section.3. Apart from the Optimica-specific constructs, an optimizationlass can also contain component and variable declarations, locallasses, and equations.

It is not possible to declare components from optimizationlasses in the current version of Optimica. Rather, the underlyingssumption is that an optimization class defines an optimizationroblem, that is solved off-line. An interesting extension would,owever, be to allow for optimization classes to be instantiated.ith this extension, it would be possible to solve optimization

roblems, on-line, during simulation. A particularly interestingpplication of this feature is model predictive control, which iscontrol strategy that involves on-line solution of optimization

roblems during execution.As a starting-point for the formulation of the optimization prob-

ems (9)–(11), consider the optimization class:

This class contains only one component representing theynamic system model, but will be extended in the following to

ncorporate also the other elements of the optimization problem.

.4.2. Attributes for the built-in type RealIn order to superimpose information on variable declarations,

wo new attributes are introduced for the built-in type Real.4

irstly, it should be possible to specify that a variable, or param-ter, is free in the optimization. Modelica parameters are normallyonsidered to be fixed after the initialization step, but in the casef optimization, some parameters may rather be considered to beree. In optimal control formulations, the control inputs should be

arked as free, to indicate that they are indeed optimization vari-bles. For these reasons, a new attribute for the built-in type Real,ree, of Boolean type is introduced. By default, this attribute is seto false.

Secondly, an attribute, initialGuess, is introduced to enablehe user to provide an initial guess for variables and parameters.n the case of free optimization parameters, the initialGuessttribute provides an initial guess to the optimization algorithmor the corresponding parameter. In the case of variables, the ini-ialGuess attribute is used to provide the numerical solver withn initial guess for the entire optimization interval. This is particu-arly important if a simultaneous or multiple-shooting algorithms used, since these algorithms introduce optimization variablesorresponding to the values of variables at discrete points overhe interval. Notice that such initial guesses may be needed bothor control and state variables. For such variables, however, theroposed strategy for providing initial guesses may sometimes be

nadequate. In some cases, a better solution is to use simulationata to initialize the optimization problem. This approach is alsoupported by the Optimica compiler.

In the double integrator example, the control variable u is a freeptimization variable, and accordingly, the free attribute is set torue. Also, the initialGuess attribute is set to 0.0.

4 The same attributes may be introduced for the built-in type Integer, in order toupport also variables of type Integer in the optimization formulation.

l Engineering 34 (2010) 1737–1749

3.4.3. A function for accessing instant values of a variableAn important component of some dynamic optimization

problems, in particular parameter estimation problems wheremeasurement data is available, is variable access at discrete timeinstants. For example, if a measurement data value, yi, has beenobtained at time ti, it may be desirable to penalize the deviationbetween yi and a corresponding variable in the model, evaluated atthe time instant ti. In Modelica, it is not possible to access the valueof a variable at a particular time instant in a natural way, and a newconstruct therefore has to be introduced.

All variables in Modelica are functions of time. The variabilityof variables may be different—some are continuously changing,whereas others can change value only at discrete time instants,and yet others are constant. Nevertheless, the value of a Model-ica variable is defined for all time instants within the simulation,or optimization, interval. The time arguments of variables are notwritten explicitly in Modelica, however. One option for enablingaccess to variable values at specified time instants is therefore toassociate an implicitly defined function with a variable declaration.This function can then be invoked by the standard Modelica syntaxfor function calls, y(t i). The name of the function is identical tothe name of the variable, and it has one argument; the time instantat which the variable is evaluated. This syntax is also very natu-ral since it corresponds precisely to the mathematical notation of afunction. Notice that the proposed syntax y(t i) makes the inter-pretation of such an expression context dependent. In order for thisconstruct to be valid in standard Modelica, y must refer to a func-tion declaration. With the proposed extension, y may refer either toa function declaration or a variable declaration. A compiler there-fore needs to classify an expression y(t i) based on the context,i.e., what function and variable declarations are visible. An alterna-tive syntax would have been to introduce a new built-in function,that returns the value of a variable at a specified time instant. Whilethis alternative would have been straightforward to implement, theproposed syntax has the advantages of being easier to read and thatit more closely resembles the corresponding mathematical nota-tion. This feature of Optimica is used in the constraint section ofthe double integrator example, and is described below.

3.4.4. Class attributesIn the optimization formulations (1)–(6) and (8), there are

elements that occur only once, i.e., the cost function and the opti-mization interval in (1)–(6), and in the static case (8), only the costfunction. These elements are intrinsic properties of the respectiveoptimization formulations, and should be specified, once, by theuser. In this respect the cost function and optimization interval dif-fer from, for example, constraints, since the user may specify zero,one or more of the latter.

One option for providing this kind of information is to introducea built-in class, call it Optimization, and require that all opti-mization classes inherit from Optimization. Information aboutthe cost function and optimization interval may then be given asmodifications of components in this built-in class:

Here, objective, startTime and finalTime are assumed to becomponents located in Optimization, whereas cost is a variable

Page 7: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

emica

wNttpMcpiS

Ibpm

pwelItdtttpm

atbdb

3

cicstsfcmpetcaitat

J. Åkesson et al. / Computers and Ch

hich is looked up in the scope of the optimization class itself.otice also how the cost function, cost, has been introduced, and

hat the finalTime attribute is specified to be free in the optimiza-ion. This approach of inheriting from a built-in class has been usedreviously, in the tool Mosilab (Nytsch-Geusen, 2007), where theodelica language is extended to support statecharts. In the state-

hart extension, a new specialized class, state, is introduced, androperties of a state class (for example whether the state is an

nitial state) can be specified by inheriting from the built-in classtate and applying suitable modifications.

The main drawback of the above approach is its lack of clarity.n particular, it is not immediately clear that Optimization is auilt-in class, and that its contained elements represent intrinsicroperties of the optimization class, rather than regular ele-ents, as in the case of inheritance from user or library classes.To remedy this deficiency, the notion of class attributes is pro-

osed. This idea is not new, but has been discussed previouslyithin the Modelica community. A class attribute is an intrinsic

lement of a specialized class, and may be modified in a class dec-aration without the need to explicitly extend from a built-in class.n the Optimica extension, four class attributes are introduced forhe specialized class optimization. These are objective, whichefines the cost function, startTime, which defines the start ofhe optimization interval, finalTime, which defines the end ofhe optimization interval, and static, which indicates whetherhe class defines a static or dynamic optimization problem. Theroposed syntax for class attributes is shown in the following opti-ization class:

The default value of the class attribute static is false, andccordingly, it does not have to be set in this case. In essence,he keyword extends and the reference to the built-in class haveeen eliminated, and the modification construct is instead givenirectly after the name of the class itself. The class attributes maye accessed and modified in the same way as if they were inherited.

.4.5. ConstraintsConstraints are similar to equations, and in fact, a path equality

onstraint is equivalent to a Modelica equation. But in addition,nequality constraints, as well as point equality and inequalityonstraints should be supported. It is therefore natural to have aeparation between equations and constraints. In Modelica, ini-ial equations, equations, and algorithms are specified in separateections, within a class body. A reasonable alternative for speci-ying constraints is therefore to introduce a new kind of section,onstraint. Constraint sections are only allowed inside an opti-ization class, and may contain equality, inequality as well asoint constraints. In the double integrator example, there are sev-ral constraints. Apart from the constraints specifying bounds onhe control input u and the velocity v, there are also terminalonstraints. The latter are conveniently expressed using the mech-

nism for accessing the value of a variable at a particular timenstant; di.x(finalTime)=1 and di.v(finalTime)=0. In addi-ion, bounds may have to be specified for the finalTime classttribute. The resulting optimization formulation may now be writ-en:

l Engineering 34 (2010) 1737–1749 1743

3.4.6. Annotations for specification of the transcription schemeThe transcription scheme used to transform the infinite-

dimensional dynamic optimization problem into a finite-dimensional approximate problem usually influences theproperties of the numerical solution. Nevertheless, transcriptioninformation can be considered to be complimentary information,that is not part of the mathematical definition of the optimizationproblem itself. Also, transcription information is closely related toparticular numerical algorithms. It is therefore reasonable not tointroduce new language constructs, but rather new annotationsfor specification of transcription schemes. This solution is alsomore flexible, which is important in order easily accommodatetranscription schemes corresponding to algorithms other than thedirect collocation method currently supported.

4. The JModelica.org platform

In order to demonstrate the feasibility and effectiveness ofthe proposed Optimica extension, a prototype compiler wasdeveloped (Åkesson, 2007). Currently, the initial prototype com-piler is being developed with the objective of creating aModelica-based open source platform focused on dynamic opti-mization.

The architecture of the JModelica.org platform is illustrated inFig. 3. The platform consists essentially of two main parts: the com-piler and the JModelica.org Model Interface (JMI) run-time library.The compiler translates Modelica and Optimica source code into aflat model description, then applies symbolic algorithms to trans-form the model into a hybrid DAE, and finally generates C and XMLcode. The generated C code contains the actual model equationsin a format suitable for efficient evaluation, whereas the XML codecontains model meta data, such as variable names and parametervalues. The JMI run-time library provides a C interface which inturn can be interfaced with numerical algorithms. There is also anEclipse plug-in and a Python integration module under develop-ment. In this section, the key parts of the JModelica.org platformwill be described.

4.1. Compiler development—JastAdd

Compiler construction has traditionally been associated withintricate programming techniques within the area of computer sci-ence. Recent research effort has, however, resulted in new compiler

construction frameworks that are easier to use and where it is fea-sible to develop compilers with a comparatively reasonable effort.One such framework is JastAdd (Ekman, Hedin, & Magnusson, 2006;Hedin & Magnusson, 2003). JastAdd is a Java-based compiler con-struction framework based on concepts such as object-orientation,
Page 8: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

1744 J. Åkesson et al. / Computers and Chemical Engineering 34 (2010) 1737–1749

delica

aHcoafia

otgAbcshi

acfc(iootscJ

F(i

Fig. 3. Overview of the JMo

spect-orientation and reference attributed grammars (Ekman &edin, 2004). At the core of JastAdd is an abstract syntax specifi-ation, which defines the structure of a computer program. Basedn an abstract syntax tree (AST), the compiler performs tasks suchs name analysis, i.e., finding declarations corresponding to identi-ers, type analysis, i.e., verifying the type correctness of a program,nd code generation.

The JastAdd way of building compilers involves specificationf attributes and equations based on the abstract syntax specifica-ion. This feature is very similar to ordinary Knuth-style attributerammars (Knuth, 1968) but enhanced with reference attributes.ccordingly, attributes may be used to specify, declaratively, linksetween different nodes in the AST. For example, identifier nodesan be bound to their declaration nodes. In Fig. 4, an example of amall Modelica program and its corresponding AST is shown. Noticeow the reference attribute myDecl links an identifier (IdUse) to

ts declaration (CompDecl).JastAdd attributes and equations are organized into separate

spects, which form a convenient abstraction for encoding of crossutting behavior. Typically, implementation of a semantic function,or example type analysis, involves adding code to large number oflasses in the AST specification. Using aspects, much like in AspectJKiczales et al., 2001), cross cutting behavior can be modularizedn a natural way. In addition, this approach is the basis for onef the distinguishing features of JastAdd: it enables development

f modularly extensible compilers. This means that it is feasibleo develop, with a comparatively moderate effort, modular exten-ions of an existing JastAdd compiler without changing the coreompiler. This feature has been used in the implementation of theModelica.org Modelica and Optimica compilers, where the Opti-

ig. 4. A simple Modelica model (left) and its corresponding abstract syntax treeright). The dashed arrow represents the reference attribute myDecl which binds andentifier to its declaration.

.org platform architecture.

mica compiler is a fully modular extension of the core Modelicacompiler.

The JastAdd compiler transforms the JastAdd specification intopure Java code, where the definition of the abstract grammartranslates into Java classes corresponding to Modelica classes,components, functions, and equations. The JastAdd attributes arewoven into the Java classes as methods. In addition, methods fortraversing an AST and query properties of a particular AST class,e.g., obtain a list of variables contained in a class declaration, areautomatically generated. As a result of this approach, compilersproduced by JastAdd are in the form of standard Java packages,which in turn can be integrated in other applications. It is there-fore not necessary to know the particular details of how to writeJastAdd specifications in order to use the JModelica.org compilers,knowledge of Java is generally sufficient.

4.2. The Modelica and Optimica compilers

At the core of the JModelica.org platform is a Modelica compilerthat is capable of transforming Modelica code into a flat represen-tation and of generating C code. In the Modelica compiler, severaldesign strategies, for example name look-up, developed for a Javacompiler developed using JastAdd (Ekman & Hedin, 2007), werereused. For additional details on the implementation of the com-piler, see Åkesson, Ekman, and Hedin (2010). In order to supportalso the Optimica extension, an extended compiler capable of trans-lating standard Modelica enhanced with the new Optimica syntaxpresented in Section 3 has also been developed.

The JModelica.org Modelica compiler currently supports a sub-set of Modelica version 3.0. The Modelica Standard Library version3.0.1 can be parsed and the corresponding source AST can beconstructed. Flattening support is more limited, but is being con-tinuously improved.

4.3. Code generation

The JModelica.org offers a code generation framework imple-mented in Java as part of the compilers. The framework facilitatesdevelopment of custom code generation modules and is based on

templates and tags. A template is used to specify the structure ofthe generated code and tags are used to define elements of thetemplate which is to be replaced by generated code. In order todevelop a custom code generation module, the compiler developerneeds to define a template and a set of tags, and then implement the
Page 9: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

emica

atttt

umJeb

4

eniDssT(totoa(Tsito

DtfDoitf

4

cAuiffiXd2aPttatc

J. Åkesson et al. / Computers and Ch

ctual code generation behavior corresponding to each tag. In ordero perform the latter, the AST for the flattened Modelica model isypically used, where objects corresponding to declarations, equa-ions and functions are queried for information used to generatehe target code.

The JModelica.org platform contains two code generation mod-les, one for C and one for XML. The generated C code contains theodel equations and is intended to be compiled and linked with the

Modelica.org Model Interface (see below) in order to offer efficientvaluation of the model equations. The XML export is describedelow in Section 4.5.

.4. C API

The JModelica.org platform offers a C API, entitled the JMod-lica.org Model Interface (JMI5), suitable for integration withumerical algorithms. The interface provides functions for access-

ng and setting parameter and state values, for evaluation of theAE residual function and for evaluation of cost functions and con-

traints specified in an Optimica model. In addition, Jacobians andparsity patterns can be obtained for all functions in the interface.o meet this end, a package for automatic differentiation, CppADBell, 2008), has been integrated into JMI. Computation of deriva-ives may be done in several ways. One option is to use symbolicr automatic differentiation based on the ASTs in the compiler andhen generate C code for the differentiated expressions. Anotherption is to export an XML model representation and then definen automatic differentiation scheme as an XSLT transformationBischof, Bücker, Marquardt, Petera, & Wyes, 2006; Elsheikh, 2008).he choice of CppAD was done in order to provide derivatives andparsity patterns in a simple way in the context of the executionnterface. The JMI code is intended to be compiled with the C codehat is generated by the compiler into an executable, or into a sharedbject file.

The JMI interface consists of four parts: the ODE interface, theAE interface, the DAE initialization interface, and the Optimiza-

ion interface. These interfaces provide access to functions relevantor different parts of the optimization specification. The ODE andAE interfaces provide evaluation functions for the right hand sidef the ODE and the DAE residual function respectively. The DAEnitialization problem provides functions for solving the DAE ini-ialization problem, whereas the Optimization interface providesunctions for evaluation of the cost functions and the constraints.

.5. XML export

The XML output consists of model meta data such as specifi-ations of variables, including their names, attributes and type.lso, the XML output includes a separate file for parameter val-es. The XML output is similar to what is discussed within the FMI

nitiative (DLR Dynasim, ITI, & QTronic, 2009), and the intention isor the JModelica.org XML output to be compliant with FMI oncenalized. In addition, there is on-going work aimed to develop anML specification for flattened Modelica models, including variableeclarations, functions, and equations (Casella, Filippo, & Åkesson,009). This XML format is similar to CapeML (von Wedel, 2002),lthough geared towards representation of flat Modelica models.roviding XML export as a complement to the C model execu-

ion interface is motivated by the large body of general purposeools for transforming XML into various formats. As noted above,n automatic differentiation scheme may be encoded as an XSLTransformation. Also, XSLT transformations may be used to encodeode generation schemes.

5 Notice that this acronym is unrelated to Java Metadata interface.

l Engineering 34 (2010) 1737–1749 1745

4.6. Interactive environment—Python

Solution of engineering problems typically involves atomiza-tion of tasks in the form of user scripts. Common examples arebatch simulations, parameter sweeps, post-processing of simu-lation results and plotting. Given that JModelica.org is directedtowards scientific computing, Python, see P. S. Foundation (2009),is an attractive option. Python is a free open-source highly efficientand mature scripting language with strong support in the scien-tific community. Packages such as NumPy (Oliphant, 2009) andSciPy (Enthought, 2009), and bindings to state-of-the art numeri-cal codes implemented in C and Fortran make Python a convenientglue between JModelica.org and numerical algorithms. In addition,IPython (Enthought, 2009) with the visualization package mat-plotlib (Hunter, Dale, & Droettboom, 2009 and the PyLab mode offeran interactive numerical environment similar to the ones offeredby Matlab and Scilab.

The JModelica.org Python package includes sub packages forrunning the compilers, for managing file input/output of simula-tion/optimization results and for accessing the function providedby the JMI interface. The compilers are run in a Java Virtual Machine(JVM) which is connected to the Python environment by the pack-age JPype (Menard, 2009). One of JPype’s main features is to enabledirect access to Java objects from a Python shell or script. This fea-ture is used to communicate with the compilers, but can also beused to retrieve the ASTs generated by the compilers. The latter fea-ture enables the user to traverse and query the ASTs interactively,to perform analyses and transformations of models.

The integration of the JMI is based on the ctypes package (P. S.Foundation, 2009). Using ctypes, a dynamically linked library (DLL)can be loaded into Python, All the contained functions of the DLL arethen exposed and can be called directly from the Python shell. Inorder to enable use of NumPy arrays and matrices as arguments tothe JMI functions, the argument types have been explicitly encodedusing standard features of ctypes. In order to provide a more con-venient interface to the JMI functions, a Python class, Model hasbeen created. This class encapsulates loading of a DLL and typingof the JMI functions, and also provides wrapper functions support-ing Python exceptions. In addition, upon creation of a Model class,the generated XML meta data files are loaded and parameter val-ues and start attributes are set in the loaded model instance. Modelobjects can then be manipulated, e.g., by setting new parametervalues, or passed as an argument to a simulation or optimizationalgorithm.

4.7. Optimization algorithms

The JModelica.org platform offers two different algorithms forsolving dynamic optimization problems. The first is a simulta-neous optimization method based on orthogonal collocation onfinite elements (Biegler et al., 2002). Using this method, state andinput profiles are parametrized by Lagrange polynomials which arebased on Radau points. This method corresponds to a fully implicitRunge–Kutta method, and accordingly it possesses well known andstrong stability properties. By parameterizing the variable profilesby polynomials, the dynamic optimization problem is translatedinto a non-linear programming (NLP) problem which may be solvedby a numerical NLP solver. This NLP is, however, very large. In orderto efficiently find a solution to the NLP, derivative information aswell as the sparsity patterns of the constraint Jacobians need to beprovided to the solver. The simultaneous optimization algorithm

has been interfaced with the large-scale NLP solver Ipopt (Wächter& Biegler, 2006), which has been developed particularly to solveNLP problems arising in simultaneous dynamic optimization meth-ods. The algorithm is implemented in C as an extension of JMI, andprovides an example of how to implement algorithms based on the
Page 10: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

1 emica

Ji

iTtoTipmoPsvacePm

dtmscoa(Pm

4

uÅop(dmpwriias

bDa(pOmac

5

o

746 J. Åkesson et al. / Computers and Ch

MI functions. In particular, Jacobians computed by CppAD are used,ncluding sparsity patterns.

In addition to the simultaneous optimization algorithm, JModel-ca.org contains a multiple shooting algorithm (Bock & Plitt, 1984).he algorithm is based on an integrator which is used to simulatehe system dynamics and thereby evaluate the cost function, and anptimization algorithm which modifies the optimization variables.ypically, the optimization variables are Modelica parametersn the case of a design or parameter optimization problem, orarameters resulting from discretization of a control input. Theultiple shooting algorithm is implemented in Python, and relies

n the integrator SUNDIALS (SUNDIALS, 2009), its Python interfaceySUNDIALS (PySUNDIALS, 2009), and the optimization algorithmcipy slsqp, which is included in Scipy. In order to improve the con-ergence of the optimization algorithm sensitivities are computednd propagated to the optimization algorithm. The sensitivities areomputed using SUNDIALS. The implementation serves also as anxample of how to develop algorithms based on the JModelica.orgython interface. The multiple shooting algorithm is described inore detail in Rantil, Åkesson, Führer, and Gäfvert (2009).The above algorithms are both based on the availability of

erivatives. For some optimization problems, it is not possibleo reliably compute derivatives, and accordingly, numerical opti-

ization algorithms requiring derivative information may fail. Thisituation may occur for certain classes of hybrid systems. In suchases, heuristic methods which do not require derivative meth-ds may be better suited. Examples of such methods are geneticlgorithms, pattern matching, simulated annealing, and simplexNelder-Mead). Some methods of this class are freely available forython, see the OpenOpt project (Kroshko, 2009) for more infor-ation, and may be integrated with the JMI Python interface.

.8. Applications

Prototype versions of the JModelica.org software have beensed successfully in applications in different domains. In Haugwitz,kesson, and Hagander (2009), an application is reported whereptimal start-up trajectories are computed for a plate reactor. Theroblem is challenging not only due to the complexity of the modelapproximately 130 differential and algebraic equations), but alsoue to non-linear and in some conditions unstable dynamics. Aain challenge in this project was to obtain trajectories robust to

arameter variations. The procedure of finding acceptable solutionsas highly iterative in that the cost function and the constraints

equired several redesigns. The high-level specification frameworkn combination with automatic code generation offered by Optim-ca and the JModelica.org platform proved very useful in this respectnd motivated further efforts to develop the platform into an openource project.

The prototype software has as also been used in a num-er of other projects involving vehicle systems. For example, inanielsson (2007) optimal tracks for racing cars were optimized,nd in Tuszynskia, Persson, Åkesson, Andreasson, and Gäfvert2009), optimal rail profiles were computed for a novel mass trans-ortation system, the NoWait train concept. Other examples whereptimica has been used are reported in Hast et al. (2009) whereinimum time optimization for an industrial robot is considered

nd in Giselsson, Åkesson, and Robertsson (2009) where an optimalontrol application of a pendulum system is reported.

. Examples

The examples presented in this section, together with severalthers, are freely available at Modelon AB (2009).

l Engineering 34 (2010) 1737–1749

5.1. Model predictive control of a CSTR system

We consider the Hicks–Ray Continuously Stirred Tank Reactor(CSTR) containing an exothermic reaction (Hicks & Ray, 1971). Thestates of the system are the reactor temperature T and the reactantconcentration c. The reactant inflow rate, F0, concentration, c0, andtemperature, T0, are assumed to be constant. The input of the sys-tem is the cooling flow temperature Tc . The dynamics of the systemis then given by:

c(t) = F0(c0 − c(t))V

− k0e−EdivR/T(t)c(t)

T(t) = F0(T0 − T(t))V

− dH

�Cpk0e

−EdivR/T(t)c(t) + 2Ur�Cp

(Tc(t) − T(t))

(12)

where r, k0, EdivR, U, �, Cp, dH, and V are physical parameters.Based on the CSTR model, the following dynamic optimization

problem is formulated:

minTc(t)

∫ tf

0

(cref − c(t))2 + (Tref − T(t))2 + (Trefc − Tc(t))

2dt (13)

subject to the dynamics (12). The cost function corresponds to aload change of the system and penalizes deviations from a desiredoperating point given by target values cref ,Tref andTrefc for c, T andTcrespectively. Stationary operating conditions were computed basedon constant cooling temperatures Tc = 250 (initial conditions) andTc = 280 (reference point). The stationary points were computedusing a initialization algorithm available in JModelica.org.

The load change defined by (13) corresponds to ignition of thereactor, i.e., the initial conditions correspond to a cold reactor werelittle reaction takes place and the target set-point correspondsto production conditions. Due to the exothermic character of thereaction and the highly temperature dependent reaction kinetics,ignition of the reactor while avoiding temperature overshoot is achallenging control problem. An additional bound on the temper-ature was therefore added:

T(t) ≤ 350 (14)

The Modelica and Optimica descriptions for the CSTR model and theoptimal control problem, respectively, were translated into C codeby the Optimica compiler and the resulting NLP was solved usingIPOPT, see Section 4 for details on the collocation method imple-mented in JModelica.org. The optimal control profiles are shownin Fig. 5. As can be seen, the state profiles are converging to thereference set-point.

The optimal control problem formulated above can also be usedin conjunction with other algorithms available in JModelica.org. Todemonstrate this, a simple non-linear model predictive controller(NMPC) has been implemented. The NMPC control strategy is basedon the receding horizon principle, where an open loop optimalcontrol problem is solved in each sample. Simulation of an NMPCrequires joint simulation of the plant and solution of the optimalcontrol problem. Simulation is supported in JModelica.org by theSUNDIALS DAE integrator, see Section 4. The algorithm for execut-ing the NMPC and the simulation algorithm were implemented ina Python script.

In order to avoid numerical difficulties resulting from infeasible

initial conditions in operating conditions where the temperaturebound is active, the hard constraint was complemented by a softconstraint penalty term:

�(t) = if T(t)<= 345 then 0 else (T(t) − 345)4 (15)

Page 11: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

J. Åkesson et al. / Computers and Chemical Engineering 34 (2010) 1737–1749 1747

Fb

w

m

Ncmii

5

vHaTTi3AA

plant-wide coordinating optimization layer considering economic

ig. 5. Optimization result for the CSTR example. The target set-points are indicatedy dashed lines.

hich gives the augmented cost function:

inTc(t)

∫ tf

0

(cref − c(t))2 + (Tref − T(t))2 + (Trefc − Tc(t))

2

+ 1000�(t) dt. (16)

otice that the term � does not introduce any discontinuity in theost function. Also, the temperature bound was kept in the opti-ization formulation. The result of executing the NMPC is shown

n Fig. 6. The prediction horizon was set to 50 s and the samplingnterval was assumed to be 2 s.

.2. Distillation column load change

As a second example, we consider a distillation column pre-iously reported in Benallou, Seborg, and Mellichamp (1986) andahn and Edgar (2002). The distillation column consists of 30 traysnd separates a binary mixture containing components A and B.he relative volatility is assumed to have a constant value of 1.6.

he feed stream, xF , is introduced at the middle of the column,n tray 17, and has a constant composition of 0.5. The model has2 states corresponding to the liquid compositions of component, xi(t). The vapor compositions of component A are denoted yi(t).part from the 30 trays, volumes for the condenser and the reboiler,

Fig. 6. NMPC control of the Hicks–Ray CSTR.

Fig. 7. Optimal vapor composition profiles.

respectively, are included in the model. The controlled input of themodel is the reflux ratio, u(t).

A load change problem transferring the state of the distillationbetween two stationary operating points is considered. The oper-ating points correspond, respectively to reflux ratios of 3.0 and2.0. This in turn gives stationary values of the distillate and bot-tom purities of y1 = 0.96, y32 = 0.099 and y1 = 0.90, y32 = 0.23respectively. The control objective of the optimal control problemis defined:

minu(t)

∫ 50

0

˛(0.90 − y1(t))2 + (2.0 − u(t))2 dt (17)

where ˛ = 1000 is a constant weight. This objective penalizesdeviations from the target operating point in the distillate vaporcomposition of component A and in the reflux ratio. The refluxratio term is included in the cost function in order to guarantee aunique solution of the problem. In practice, the target values of thevapor composition and the reflux ratio are typically computed by a

objectives. In addition, the reflux ratio is assumed to be constrainedin the optimization by 1.0 ≤ u(t) ≤ 5.0.

The dynamics of the system was discretized on a mesh consist-ing of 50 elements by means of collocation based on cubic Lagrange

Fig. 8. Optimal reflux ratio profile.

Page 12: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

1 emica

pvivl

6

lmnic

btgoamnpaa

dwtijto

oiAeusa

tmepa

A

Htwn

R

Å

Å

Å

748 J. Åkesson et al. / Computers and Ch

olynomials, see Section 4 for details on the algorithm. The optimalapor composition profiles are shown in Fig. 7, and the correspond-ng reflux ratio profile is shown in Fig. 8. As can be seen, the distillateapor composition converges to the specified set-point. The prob-em was solved on a standard desktop computer in 230s.

. Summary and conclusions

This paper reports an extension of the Modelica modelinganguage, entitled Optimica, targeting dynamic optimization. Opti-

ica extends the Modelica language to also include constructseeded when formulating optimization problems, including spec-

fication of optimization interval, the cost function, and theonstraints.

The Optimica language is supported by the novel Modelica-ased open source project JModelica.org, featuring code generationo C, a C API for evaluation of model equations and a Python inte-ration. JModelica.org offers an accessible platform for modeling,ptimization and simulation of complex physical systems, whichre often encountered in process control applications. One of theain objectives of the JModelica.org project is to facilitate tech-

ology transfer between the academic community and industry byroviding a platform suitable for experimental algorithm design inn environment where relevant industrial applications are easilyccessible.

The capabilities of Optimica and JModelica.org have beenemonstrated by means of two examples. Firstly, a CSTR systemas controlled by an NMPC controller. This example demonstrates

he flexibility provided by the Python scripting environment, wheren this case, simulation and optimization tasks were executedointly. In a second example, an optimal control problem for a dis-illation column was solved. This example demonstrates the abilityf JModelica.org to solve large-scale problems.

Experiences from using Optimica and JModelica.org in a numberf projects in different application domains indicate that Model-ca/Optimica specifications are perceived as compact and intuitive.lso, students and engineers with a control background but lackingxpertise in dynamic optimization are typically able to quickly setp and solve realistic problems. In this respect, the use of Pythonerves as a convenient environment for development of prototypepplications involving dynamic optimization.

While the current version of JModelica.org features two par-icular methods for solving dynamic optimization problems, one

ultiple shooting method and one based on collocation, it isxpected that additional algorithms will be interfaced with thelatform. This will further extend the scope of the JModelica.orgnd increase its applicability.

cknowledgements

The authors would like to thank Professor Carl Laird and Gabrielackebeil at Texas A&M University, Texas, USA, for assistance with

he distillation column example presented in Section 5.2. This workas sponsored by LCCC—Lund Center for Control of Complex Engi-eering Systems funded by the Swedish Research Council.

eferences

kesson, J. (2007, November). Tools and languages for optimization of large-scale sys-tems. Ph.D. thesis, Department of Automatic Control, Lund University, Sweden.

kesson, J., Ekman, T., & Hedin, G. (2010). Implementation of a Modelica compiler

using jastadd attribute grammars. Science of Computer Programming, 75(1–2),21–38.

ström, K. J., Elmqvist, H., & Mattsson, S. E. (1998). Evolution of continuous-timemodeling and simulation. In Proceedings of the 12th European simulation mul-ticonference. ESM’98, Society for Computer Simulation International Manchester,UK, (pp. 9–18).

l Engineering 34 (2010) 1737–1749

Barton, P., & Lee, C. K. (2002). Modeling, simulation, sensitivity analysis, andoptimization of hybrid systems. ACM Transactions on Modeling and ComputerSimulation, 12 (4).

Bell, B. M. (2008). CppAD home page. http://www.coinor.org/CppAD/.Bellman, R. (1957). Dynamic programming. Princeton, NJ: Princeton University Press.Benallou, A., Seborg, D., & Mellichamp, D. (1986). Dynamic compartmental models

for separation processes. AIChE Journal, 32(7), 1067–1078.Bertsekas, D. P. (2000). Dynamic programming and optimal control (Vol. 1). Athena

Scientific.Bertsekas, D. P. (2000). Dynamic programming and optimal control (Vol. 2). Athena

Scientific.Betts, J. T. (2001). Practical methods for optimal control using nonlinear programming.

Society for Industrial and Applied Mathematics.Biegler, L., Cervantes, A., & Wächter, A. (2002). Advances in simultaneous strategies

for dynamic optimization. Chemical Engineering Science, 57, 575–593.Binder, T., Blank, L., Bock, H., Bulirsch, R., Dahmen, Diehl, M., et al. (2001). Introduc-

tion to model based optimization of chemical processes on moving horizons.In Online optimization of large scale systems (pp. 295–339). Berlin/Heidelberg:Springer-Verlag.

Bischof, C., Bücker, H. M., Marquardt, W., Petera, M., & Wyes, J. (2006). Transform-ing equation-based models in process engineering. In Automatic differentiation:Applications theory and tools (pp. 189–198). Springer.

Bock, H., & Plitt, K. J. (1984). A multiple shooting algorithm for direct solution ofoptimal control problems. In Ninth IFAC world congress Budapest,

Bock, H., Eich, E., & Schlöder, J. (1988). Numerical solution of constrained leastsquares boundary value problems in differential-algebraic equations. In Numer-ical treatment of differential equations. Teubner.

Casella, F., Filippo, D., & Åkesson, J. (2009). n XML representation of DAE systemsobtained from Modelica models. In Seventh international Modelica conference2009. Modelica Association.

Clabaugh, J. A. (2001). ABACUSS II syntax manual. Massachusetts Institute of Tech-nology. http://yoric.mit.edu/abacuss2/syntax.html.

Danielsson, H. (2007, June). Vehicle path optimisation. Master’s thesis, ISRNLUTFD2/TFRT-5797-SE, Department of Automatic Control, Lund University,Sweden.

Dassault Systémes. (2009). iSIGHT home page. http://www.simulia.com/products/isight.html.

Diehl, M., Bock, H., Schloder, J., Findeisen, R., Nagy, Z., & Allgower, F. (2002). Realtimeoptimization and nonlinear model predictive control of processes governed bydifferential-algebraic equations. Journal of Process Control, 12(4), 577–585.

DLR Dynasim, ITI, & QTronic. (2009). The functional model interface, draft.Dynasim, A. B. (2009). Dynasim AB home page. http://www.dynasim.se.Ekman, T., & Hedin, G. (2004). Rewritable reference attributed grammars. In Pro-

ceedings of the ECOOP 2004, Vol. 3086 of LNCS (pp. 144–169). Springer-Verlag.Ekman, T., & Hedin, G. (2007). The jastadd extensible java compiler. In Proceedings

of OOPSLA 2007Ekman, T., Hedin, G., & Magnusson, E. (2006). JastAdd. http://jastadd.cs.lth.se/web/.Elmqvist, H., Olsson, H., Mattsson, S., Brück, D., Schweiger, C., Joos, D., et al. (2005).

Optimization for design and parameter estimation. In Seventh international Mod-elica conference 2009. Modelica Association.

Elsheikh, A. (2008). Sensitivity analysis of Modelica applications via automatic differ-entiation. In Sixth international Modelica conference 2008. Modelica Association.

Enthought, I. (2009). SciPy. http://www.scipy.org/.Enthought, I. (2009). IPython frontpage. http://ipython.scipy.org/moin/.ESTECO. (2009). modeFRONTIER home page. http://www.esteco.com/.P. S. Foundation. (2009). Python programming language—Official website.

http://www.python.org/.P. S. Foundation. (2009). ctypes: A foreign function library for Python. http://docs.

python.org/library/ctypes.html.Fritzson, P. (2004). Principles of object-oriented modeling and simulation with Modelica

2.1. John Wiley & Sons.Giselsson, P., Åkesson, J., & Robertsson, A. (2009). Optimization of a pendulum system

using Optimica and Modelica. In Seventh international Modelica conference 2009.Modelica Association.

Hahn, J., & Edgar, T. (2002). An improved method for nonlinear model reductionusing balancing of empirical gramians. Computers and Chemical Engineering,26(10), 1379–1397.

Hast, M., Åkesson, J., & Robertsson, A. (2009). Optimal robot control using Model-ica and Optimica. In Seventh international Modelica conference 2009. ModelicaAssociation.

Haugwitz, S., Åkesson, J., & Hagander, P. (2009). Dynamic start-up optimization of aplate reactor with uncertainties. Journal of Process Control, 19(4), 686–700.

Hedin, G., & Magnusson, E. (2003). JastAdd: An aspect-oriented compilerconstruction system. Science of Computer Programming, 47 (1), 37–58.http://dx.doi.org/10.1016/S0167–6423(02)00109–0.

Hicks, G. A., & Ray, W. H. (1971). Approximation methods for optimal control syn-thesis. Canadian Journal of Chemical Engineering, 20, 522–529.

Hunter, J., Dale, D., & Droettboom, M. (2009). matplotlib: python plotting.http://matplotlib.sourceforge.net/.

IEEE. (1997). Standard VHDL analog and mixed-signal extensions (Tech. rep.). IEEE.

ITI GmbH. (2009). ITI GmbH home page. http://www.iti.de/.Karnopp, D., & Rosenberg, R. (1968). Analysis and simulation of multiport systems—The

bond graph approach to physical system dynamics. Cambridge, MA, USA: MITPress.

Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., & Griswold, W. G. (2001).An overview of AspectJ. LNCS, 2072, 327–355.

Page 13: Modeling and optimization with Optimica and …€¦ ·  · 2012-01-26high-level modeling languages, ... and that they require the dynamic system to be mod-eled as an ODE/DAE, which

emica

K

K

KL

M

M

M

MMM

N

N

NOOOP

P

von Wedel, L. (2002). CapeML—A model exchange language for chemical pro-

J. Åkesson et al. / Computers and Ch

nuth, D. E. (1968). Semantics of context-free languages. Mathematical Systems The-ory, 2 (2), 127–145 [Correction: Mathematical Systems Theory 5 (1), 95–96(March 1971)].

raft, D. (1994). Algorithm 733: Tmp-fortran modules for optimal control calcula-tions. ACM Transactions on Mathematical Software, 20 (3).

roshko, D. L. (2009). OpenOpt home page. http://openopt.org/Welcome.ang, Y., & Biegler, L. (2007). A software environment for simultaneous dynamic

optimization. Computers and Chemical Engineering, 31(8), 931–942.aplesoft. (2009). MapleSim—High-performance multi-domain modeling and simula-

tion. http://www.maplesoft.com/products/maplesim/index.aspx.attsson, S. E., & Andersson, M. (1992). Omola—An object-oriented modelling lan-

guage. In Colloquium on open systems: The way forward in computer aided controlengineering. London, UK: The Institution of Electrical Engineers.

attsson, S. E., & Söderlind, G. (1993). Index reduction in differential-algebraicequations using dummy derivatives. SIAM Journal of Scientific and StatisticalComputing, 14(3), 677–692.

enard, S. (2009). JPype home page. http://jpype.sourceforge.net/.odelon AB. (2009). JModelica home page. http://www.jmodelica.org.SC Software. (2007). ADAMS home page. http://www.mscsoftware.com/

products/adams.cfm.agel, L., & Pederson, D. O. (1973). Simulation program with integrated circuit empha-

sis (spice) (Tech. rep.). Electronics Research Laboratory, College of Engineering,University of California Berkeley, CA, USA [Memorandum ERLM382].

umerica Technology. (2007). Jacobian. http://www.numericatech.com/jacobian.htm.

ytsch-Geusen, C. (2007). MosiLab home page. http://www.mosilab.de/.liphant, T. (2009). Numpy home page. http://numpy.scipy.org/.

PTEC K.U. Leuven. (2009). ACADO home page. http://www.acadotoolkit.org/.ptiY. (2009). OptiY home page. http://www.optiy.de/.ELAB. (2009). The OpenModelica project. http://www.ida.liu.se/pelab/modelica/

OpenModelica.html.hoenix Integration. (2009). ModelCenter home page. http://www.phoenixint.

com/software/phx modelcenter.php.

l Engineering 34 (2010) 1737–1749 1749

Pontryagin, L. S., Boltyanskii, V. G., Gamkrelidze, R. V., & Mishchenko, E. F. (1962).The mathematical theory of optimal processes. John Wiley & Sons Inc.

Process Systems Enterprise. (2007). gPROMS home page. http://www.psenterprise.com/gproms/index.html.

T.-J. G. f. M. C. P. University of Stellenbosch. (2009). PySUNDIALS: Python SUiteof Nonlinear and DIfferential/ALgebraic equation Solvers. http://pysundials.sourceforge.net/.

Rantil, J., Åkesson, J., Führer, C., & Gäfvert, M. (2009). Multiple-shooting optimizationusing the JModelica.org platform. In Seventh international Modelica conference2009. Modelica Association.

C. f. A. S. C. Lawrence Livermore National Laboratory. SUNDIALS (SUite of Non-linear and DIfferential/ALgebraic equation Solvers). https://computation.llnl.gov/casc/sundials/main.html.

Tarjan, R. (1972). Depth-first search and linear graph algorithms. SIAM Journal ofComputing, 1(2), 146–160.

The Modelica Association. (2007). The Modelica Association home page.http://www.modelica.org.

Tuszynskia, J., Persson, M., Åkesson, J., Andreasson, J., & Gäfvert, M. (2009). Mod-elbased approach for design and validation of a novel concept of public masstransport. In 21st International symposium on dynamics of vehicles on roads andtracks.

University of Heidelberg. (2009). MUSCOD-II home page. http://www.iwr.uniheidelberg.de/agbock/RESEARCH/muscod.php.

Vassiliadis, V. (1993). Computational solution of dynamic optimization problem withgeneral differential-algebraic constraints. Ph.D. thesis, Imperial Collage, London,UK.

cess modeling (Tech. rep.). Lehrstuhl für Prozesstechnik, RWTH AachenUniversity.

Wächter, A., & Biegler, L. T. (2006). On the implementation of an interior-point fil-ter line-search algorithm for large-scale nonlinear programming. MathematicalProgramming, 106(1), 25–58.