Concept overview

Technology

JModelica.org relies on the established modeling language Modelica. Modelica targets modeling of complex heterogeneous physical systems, and is becoming a de facto standard for dynamic model development and exchange. There are numerous model libraries for Modelica, both free and commercial, including the freely available Modelica Standard Library (MSL).

A unique feature of JModelica.org is the support for the innovative extension Optimica. Optimica enables you to conveniently formulate optimization problems based on Modelica models using simple but powerful constructs for encoding of optimization interval, cost function and constraints.

The JModelica.org compilers are developed in the compiler construction framework JastAdd. JastAdd is based on established concepts, including object orientation, aspect orientation and reference attributed grammars. Compilers developed in JastAdd are specified in terms of declarative attributes and equations which together form an executable specification of the language semantics. In addition, JastAdd targets extensible compiler development which makes it easy to experiment with language extensions.

For user interaction, JModelica.org relies on the Python language. Python offers an interactive environment suitable for scripting, development of custom applications and prototype algorithm integration. The Python packages Numpy and Scipy provide support for numerical computation, including matrix and vector operations, basic linear algebra and plotting. The JModelica.org compilers as well as the model executables/dlls integrate seemlessly with Python and Numpy.

Architecture

Architecture: JModelica platform architecture.Architecture: JModelica platform architecture. The JModelica.org platform consists of a number of different parts:

  • Modelica compiler
    • Modelica 3.1 compliant parser
    • Open Java interface to syntax trees
    • Code generation back-end for C-code
    • Code generation back-end for models in XML format
    • Aspect-based language extensions
  • Optimica compiler
    • Extension based on Modelica 3.1 for formulation of dynamic optimization problems
    • Code generation to C and XML 
  • JModelica.org Model Interface (JMI) C Runtime library
    • Well defined API to generated C code
    • Automatic differentiation for efficient Jacobian computations, including sparsity patterns
  • Optimization algorithm
    • Solution of optimal control and parameter estimation problems are solved by a collocation algorithm implemented in C
    • Direct interface to NLP solver IPOPT
  • Python user environment
    • User friendly Python classes to load and access JMI model DLLs and XML meta data
    • Numpy support
    • Compiler API to access and manipulate model Java AST
  • Functional Mockup Interface (FMI) compliance
    • Full FMI import support
    • Full FMI export support
  • XML export
    • Flattened Modelica models, including equations, can be exported in XML format, which allows for flexible integration with tools and algorithms

Extensibility

The JModelica.org platform is extensible in a number of different ways:

  • JModelica.org features a C interface for efficient evaluation of model equations, the cost function and the constraints: the JModelica Model Interface (JMI). JMI also contains functions for evaluation of derivatives and sparsity and is intended to offer a convenient interface for integration of numerical algorithms.
  • In addition to the the C interface, model meta data can be exported in XML. In the future this feature is intended to be extended to include full model export in XML, which in turn enables use of XML techniques such as XPATH and XSLT.
  • JastAdd produces compilers encoded in pure Java. As a result, the JModelica.org compilers are easily embedded in other applications aspiring to support Modelica and Optimica. In particular, a Java API for accessing the flat model representation and an extensible template-based code generation framework is offered.
  • The JModelica.org compilers are developed using the compiler construction framework JastAdd. JastAdd features extensible compiler construction, both at the language level and at the implementation level. This feature is explored in JModelica.org where the Optimica compiler is implemented as a fully modular extension of the core Modelica compiler. The JModelica.org platform is a suitable choice for experimental language design and research.

An overview of the JModelica.org platform is given in the paper Modeling and Optimization with Optimica and JModelica.org-Languages and Tools for Solving Large-Scale Dynamic Optimization Problem.