Install JModelica on Lubuntu 15.04
(This entry has been updated to discuss installing JModelica on XSEDE's Comet supercomputer: see below. Many of the initial steps are the same.)
My computer had 8GB of RAM. It may be that this simply will not work with 2GB of RAM or less.
Update package list
sudo apt-get update
Download and install
screen, so we can work quickly, and
subversion, so we
can start downloading stuff:
sudo apt-get -y install screen subversion
Run screen (with automatic logging!):
Download and install required packages
sudo apt-get -y install g++ gfortran ipython cmake swig ant python-dev python-numpy python-scipy python-matplotlib cython python-lxml python-nose python-jpype libzip-dev openjdk-7-jdk libboost-dev jcc pkg-config
We modify the JModelica required packages to include:
openjdk-7-jdk- we are trying this instead of JModelica's recommended openjdk-6-jdk. Keepin' up with the times.
libzip-devis necessary for JModelica as well.
libboost-devprovisions boost-flyweight, which is needed to run
Download JModelica on one screen (I've set it here to a revision where I know things worked for my purposes):
svn co https://svn.jmodelica.org/trunk@7885 JModelica.org
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.
Get IPOPT on another screen:
Unpack IPOPT in the home directory. It must be in the home directory.
tar xvzf Ipopt-3.12.4.tgz
Get IPOPT third-party packages:
cd ~/Ipopt-3.12.4/ThirdParty/Blas ./get.Blas cd ../Lapack ./get.Lapack cd ../Mumps ./get.Mumps cd ../Metis ./get.Metis cd ../../ #Go back to the IPOPT base dir
If you have access to the HSL codes MA57 or MA27 (you'll need to fetch them from here) you'll want to install them. I had them on my local machine and was installing to a server, so I used scp to move them over:
scp -C coinhsl-2014.01.10.tar.gz root@IP_ADDRESS:~/
Unpack the archive and move the contents to a place where IPOPT will see them.
cd ~/Ipopt-3.12.4/ThirdParty/HSL tar xvzf ~/coinhsl-2014.01.10.tar.gz mv coinhsl-2014.01.10 coinhsl
cd ~/Ipopt-3.12.4/ mkdir build cd build ../configure make -j 4 #Compile using 4 cores (if you have them) make install
Hopefully JModelica is done downloading by now.
cd ~/JModelica.org mkdir build cd build ../configure --with-ipopt=$HOME/Ipopt-3.12.4/build --prefix=$HOME make make install make install_casadi
Depending on how you have your Java set up, you may need to set up some environment variables as follows. That should not be necessary for the process described here, since we have installed the correct version of Java and set up expected paths.
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 export LD_LIBRARY_PATH="$JAVA_HOME/jre/lib/amd64/server:$LD_LIBRARY_PATH"
On XSEDE these paths are:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-22.214.171.124.x86_64 export LD_LIBRARY_PATH="$JAVA_HOME/jre/lib/amd64/server:$LD_LIBRARY_PATH"
Once you have the paths set up, finish installing.
make install casadi_interface
Woo! It should be working!
But probably it isn't. When I did the above process, IPOPT did not find HSL,
even though it was supposed to be baked in. If you get complaints about
libhsl.so being missing try the following first, then look below in "Compilation & Execution Issues" for another important debugging step.
cd ~ tar xvzf coinhsl-2014.01.10.tar.gz cd coinhsl-2014.01.10 ./configure LIBS="-llapack" --with-blas="-L/usr/lib -lblas" CXXFLAGS="-g -O2 -fopenmp" FCFLAGS="-g -O2 -fopenmp" CFLAGS="-g -O2 -fopenmp" make -j 4 make install
The library will be installed to
/usr/local/lib, but IPOPT won't detect it
because it will have the wrong name. Let's fix that:
ln -s /usr/local/lib/libcoinhsl.so /usr/local/lib/libhsl.so
And IPOPT still won't detect it because you need to set
You can check on your dynamically loading libraries with
HSL will run with a single core unless you set the OpenMP environmental variable:
export OMP_NUM_THREADS=7 #or the number of cores you want to use
Compilation & Execution Issues
You get the message
ImportError: cannot import name transfer_optimization_problem
You didn't run
make install casadi_interface. Shame on you.