This section describes a procedure for compiling JModelica.org from sources on Linux. The instructions have been verified to work on Ubuntu Linux release 12.04, 64bit.
It is convenient to use a package management system, if available, of the Linux distribution to install the prerequisites. On Ubuntu systems, the apt-get command line program may be used:
sudo apt-get -y install g++ sudo apt-get -y install subversion sudo apt-get -y install gfortran sudo apt-get -y install ipython sudo apt-get -y install cmake sudo apt-get -y install swig sudo apt-get -y install ant sudo apt-get -y install openjdk-6-jdk sudo apt-get -y install python-dev sudo apt-get -y install python-numpy sudo apt-get -y install python-scipy sudo apt-get -y install python-matplotlib sudo apt-get -y install cython sudo apt-get -y install python-lxml sudo apt-get -y install python-nose sudo apt-get -y install python-jpype sudo apt-get -y install zlib1g-dev sudo apt-get -y install libboost-dev
On Ubuntu 12.04, the bundled jcc version is too old. A new enough version can be installed using pip:
sudo apt-get -y install python-pip sudo pip install jcc
The following versions of each package have been tested and verified to work. Please note that in some cases, a minimum version is required.
Table 2.1. Package versions for Ubuntu
While Ipopt is available as a pre-compiled package for Ubuntu, it is recommended to build Ipopt from sources. The Ipopt packages provided for Ubuntu have had flaws (including the version provided for Ubuntu 12.04) that prevented usage with JModelica.org. Also, compiling Ipopt from sources is required when using the linear solvers MA27 or MA57 from the HSL library, since these are not available as open source software.
First, download the Ipopt sources from https://projects.coin-or.org/Ipopt and unpack the content:
tar xvf Ipopt-3.10.2.tgz
Then, retrieve the third party dependencies:
cd Ipopt-3.10.2/ThirdParty/Blas ./get.Blas cd ../Lapack ./get.Lapack cd ../Mumps ./get.Mumps cd ../Metis ./get.Metis cd ../../
If you have access to the HSL codes MA57 or MA27, copy their sources into the directory
ThirdParty/HSL. In the next step, configure and compile Ipopt:
mkdir build cd build ../configure --prefix=/home/<user_name>/<ipopt_installation_location> make install
<ipopt_installation_location> are replaced by the user directory and the installation directory of choice for Ipopt.
As an alternative to IPOPT for optimization, the CasADi framework in JModelica.org also has support for the solver WORHP. Note that WORHP is closed source, but offers free personal academic licenses. To compile JModelica.org with support for WORHP, first obtain the WORHP binaries and a license file from http://www.worhp.de. Set the environment variables
$WORHP to your directory containing the binaries and
$WORHP_LICENSE_FILE to your license file.
Normally, this would be sufficient, but for now the following additional measures are needed. Find the following six lines in
$JMODELICA_SRC/ThirdParty/CasADi/CasADi/interface/worhp/worhp_internal.cpp and remove them:
addOption("CutLength",OT_REAL,worhp_p_.CutLength,"Scaling factor for Cut recovery strategy"); addOption("Ma57PivotThresh",OT_REAL,worhp_p_.Ma57PivotThresh,"Pivoting tolerance for MA57 = CNTL(1)"); if (hasSetOption("CutLength")) worhp_p_.CutLength = getOption("CutLength"); if (hasSetOption("Ma57PivotThresh")) worhp_p_.Ma57PivotThresh = getOption("Ma57PivotThresh"); setOption("CutLength",worhp_p_.CutLength); setOption("Ma57PivotThresh",worhp_p_.Ma57PivotThresh);
Find the line
option(WITH_WORHP "Compile the WORHP interface" OFF)
$JMODELICA_SRC/ThirdParty/CasADi/CasADi/CMakeLists.txt and change OFF to ON.
Make sure that all prerequisites are installed before compiling the JModelica.org platform. First, check out the JModelica.org sources:
svn co https://svn.jmodelica.org/trunk JModelica.org
Then configure and build JModelica.org:
cd JModelica.org mkdir build cd build ../configure --prefix=/home/<user_name>/<jmodelica_install_location> \ --with-ipopt=/home/<user_name>/<ipopt_install_location> make install make casadi_interface
<jmodelica_installation_location> are replaced by the user directory and the installation directory of choice for JModelica.org.
In order to verify that JModelica.org has been installed correctly, start an IPython shell using the command
/home/<user_name>/<jmodelica_install_location>/bin/jm_ipython and run a few examples:
# Import and run the VDP_sim example and plot results from pyjmi.examples import VDP_sim VDP_sim.run_demo() # Import and run the CSTR example and plot results from pyjmi.examples import cstr cstr.run_demo() # Import and run the CSTR example using CasADi and plot results from pyjmi.examples import cstr_casadi cstr_casadi.run_demo()