Modeling and Optimization with Modelica and Optimica Using the Jmodelica.Org Open Source Platform
Total Page:16
File Type:pdf, Size:1020Kb
Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009 Modeling and Optimization with Modelica and Optimica Using the JModelica.org Open Source Platform Johan Åkessona,b Tove Bergdahla Magnus Gäfverta Hubertus Tummescheita a Modelon AB, Sweden b Department of Automatic Control, Lund University, Sweden Abstract devoted to encapsulating expert knowledge in model libraries encoded in domain specific languages such This paper reports a new Modelica-based open source as VHDL-AMS [30] and Modelica [44]. While such project entitled JModelica.org, targeted towards dy- model libraries have been primarily intended for sim- namic optimization. The objective of the project is ulation, it is desirable to enable also other usages, in- to bridge the gap between the need for high-level de- cluding optimization. From a user’s perspective, it scription languages and the details of numerical opti- is desirable that the optimization specification is ex- mization algorithms. JModelica.org is also intended pressed in a high-level language in order to provide a as an extensible platform where algorithm developers, comprehensive description both of the dynamic model particularly in the academic community, may integrate to be optimized and of the optimization problem. An- new and innovative methods. In doing so, researchers other aspect that requires attention is that of enabling gain access to a wealth of industrially relevant opti- flexible use of the wealth of numerical algorithms mization problems based on existing Modelica mod- for dynamic optimization, based on the high-level de- els, while at the same time facilitating industrial use scriptions specified by the user. of state of the art algorithms. In this contribution, an Several common engineering tasks are conveniently overview of the platform is presented and the main fea- cast as optimization problems. This includes param- tures of JModelica.org are highlighted. eter estimation problems to obtain models that match Keywords: Modelica; Optimica; Optimization; plant data, design optimization for improving product Model Predictive Control performance, and controller parameter tuning. In ad- dition, dynamic optimization is a key to implementing for example model predictive controllers and receding 1 Introduction horizon state estimators. Optimization is becoming a standard methodology in This contribution reports a new Modelica-based many engineering disciplines to improve products and open source initiative targeted at dynamic optimiza- processes. The need for optimization is driven by tion entitled JModelica.org. JModelica.org [36] is a factors such as increased costs for raw materials and novel open source project with the mission: stricter environmental regulations as well as a general “To offer a community-based, free, open source, ac- need to meet increased competition. As model-based cessible, user and application oriented Modelica en- design processes are being used increasingly in indus- vironment for optimization and simulation of complex try, the prerequisites for optimization are often ful- dynamic systems, built on well-recognized technology filled. However, current tools and languages used to and supporting major platforms.” model dynamic systems are not always well suited for integration with state of the art numerical optimization JModelica.org is primarily focused on dynamic opti- algorithms. As a result, optimization is not used as fre- mization of Modelica models. To meet this end, JMod- quently as it could, or less efficient, but easier to use, elica.org supports Optimica, which is an extension to algorithms are employed. the Modelica language that offers language constructs More often than not, systems to be optimized are for encoding of cost functions, constraints and the op- complex and dynamic. Such problems offer several timization interval with fixed or free end points. The challenges at different levels. Much effort has been platform consists of compilers for translating Model- © The Modelica Association, 2009 29 DOI: 10.3384/ecp09430057 Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009 ica and Optimica models into C and XML code, a complexity of the target models, models are usually C API for evaluation of model equations and Python treated as black boxes, i.e. the result of a computation bindings to enable scripting and custom algorithm de- is propagated to the tool, but the structure of a par- velopment. The software is distributed freely under ticular model is not explored. Accordingly, heuristic the GPL license. optimization algorithms which do not require deriva- The paper is outlined as follows. In Section 2, a tive information or detailed structural information, are review of optimization tools and the Optimica exten- usually employed. In addition, model integration tools sion are given. Section 3 describes the JModelica.org often have sophisticated features supporting model ap- platform. Previous case studies performed based on proximation and visualization. JModelica.org, and the opportunities provided by ab- Several Simulation tools comes with optimization stract syntax tree access are discussed in Section 4. In add-ons, e.g., Dymola [14], gPROMS [42] and Jaco- Section 5, an example of a model predictive control bian [37]. Such tools typically offer strong support application is given. The paper ends with a summary for modeling of physical systems and simulation. The and comments on future work in Section 6. level of support for optimization in this category dif- fers between different tools. Dymola, for example, offers add-ons for parameter identification and design 2 Background optimization, [18]. gPROMS, on the other hand, also offers support for solution of optimal control prob- It is typical that numerical algorithms for dynamic op- lems. Tools in this category are usually limited to a timization is written in C or Fortran. Often, the user predefined set of optimization algorithms. Integration is required to encode the dynamic model and the opti- of new algorithms may be difficult if the tools do not mization specification in the same languages. While C provide the necessary API:s. and Fortran enables efficient compilation to executable code, such languages are not well suited for encoding In the third category we have numerical packages of dynamic models and optimization problems. In par- for dynamic optimization, often developed as part of ticular, it is difficult to write the code in a modular way research programs. Examples are ACADO [39], Mus- that enables reuse. This observation was made several cod II [46], and DynoPC [33], which is based on decades ago in the context of modeling and simulation Ipopt [48]. Such packages are typically focused on and resulted in high-level modeling languages, includ- efficient implementation of an optimization algorithm ing ACSL and later Omola, [4], VHDL-AMS [30], and for a particular class of dynamic systems. Also, de- Modelica [44]. See [5] for a comprehensive overview tailed information about the model to optimize is gen- of the evolution of continuous-time simulation lan- erally required in order for such algorithms to work, guages and tools. including accurate derivatives and in some cases also sparsity patterns. Some of the packages in this cate- gory are also targeting optimal control and estimation 2.1 Optimization Tools problems in real-time, e.g., non-linear model predic- There are several tools for optimization on the market, tive control, which require fast convergence. While offering different features. In essence, three different these packages offer state of the art algorithms, they categories of tools can be distinguished, although the typically come with simple or no user interface. Their functionality is sometimes overlapping. Model inte- usage is therefore limited due to the effort required to gration tools addresses the problem of interfacing sev- code the model and optimization descriptions. eral design tools into a a single computation environ- The JModelica.org platform is positioned to fill the ment, where analysis, simulation and optimization can gap left between simulation tools offering optimiza- be performed. Examples are ModelCenter, [41], Op- tion capabilities and state of the art numerical algo- tiY, [40], modeFRONTIER [21], and iSIGHT, [11]. rithms. Primarily, target algorithms are gradient based Typically, such tools are dedicated to design opti- methods offering fast convergence. Never the less, mization of extremely complex systems which may JModelica.org is well suited for use also with heuristic be composed from subsystems encoded in different direct search methods; the requirements with respect tools. Accordingly, model integration tools typically to execution interface is typically a subset of the re- offers interfaces to CAD and finite element software as quirements for gradient based methods. The problems well as simulation tools for, e.g., mechanical and hy- addressed by model integration tools is currently be- draulic systems. As a result of the heterogeneity and yond the scope of JModelica.org, even though its in- © The Modelica Association, 2009 30 Proceedings 7th Modelica Conference, Como, Italy, Sep. 20-22, 2009 model VDP The dynamic model (2) of the problem is a van Der Real x1(start=0); Pol oscillator, and the optimization problem corre- Real x2(start=1); sponds to bringing the system from initial conditions input Real u; x1(0)= 0, x2(0)= 1 to the origin in minimum time. In equation addition, the transition is to be performed with limited der(x1)