Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
using_matlab_from_prolog [2013/02/04 12:13] – created tenorthusing_matlab_from_prolog [2014/08/08 09:36] (current) admin
Line 1: Line 1:
-*Use the MATLAB-Prolog interface from http://www.swi-prolog.org/contrib/SamerAbdallah/index.html +====== Using Matlab from Prolog ======
-* set the following values in the MAKEFILE+
  
- export MATLAB=/usr/local/lehrstuhl/DIR/matlab-2007b +\\ 
- export MLARCH=glnxa64 +**Note: This page describes experimental code that has not been used in a while. Please try it at your own risk. ** 
- export MLLIBS=-leng -lmx -lmat -licuuc -licudata -licui18n -lz -lreadline +\\
- export SO=so +
- export INCLUDES= +
- export PLLD=/usr/local/lehrstuhl/DIR/pl/lib/pl/bin/x86_64-linux/plld +
- export INSTALL_LIB_TO=~/work/owl/lib +
- export INSTALL_PL_TO=~/work/owl/lib +
- export INSTALL_FLAGS='-bp'+
  
-*generate a new file and call it: setPathMatlab.m this file should have the following:+The Matlab-Prolog interface [[http://www.swi-prolog.org/contrib/SamerAbdallah/index.html|PLML]] allows to call Matlab functions from Prolog. The following steps describe the setup as it worked in our labYou will need to adapt the paths to your setup and possibly change other values if you have a different configuration. 
  
- p=genpath('/the/path/where/is/plml/matlab/'); +You need to set the following values in the Makefile (adapt the pa:
- addpath(p);+
  
-* move/copy the new file "setPathMatlab.m" to the following address:~/work/owl+  export MATLAB=/usr/local/lehrstuhl/DIR/matlab-2007b 
 +  export MLARCH=glnxa64 
 +  export MLLIBS=-leng -lmx -lmat -licuuc -licudata -licui18n -lz -lreadline 
 +  export SO=so 
 +  export INCLUDES= 
 +  export PLLD=/usr/local/lehrstuhl/DIR/pl/lib/pl/bin/x86_64-linux/plld 
 +  export INSTALL_LIB_TO=~/work/owl/lib 
 +  export INSTALL_PL_TO=~/work/owl/lib 
 +  export INSTALL_FLAGS='-bp'
  
-*Enter the file plml.cpp and add the following (~line 179)+Generate a new file and call it: setPathMatlab.m this file should have the following: 
 + 
 +  p=genpath('/the/path/where/is/plml/matlab/'); 
 +  addpath(p); 
 + 
 +Then move/copy the new file "setPathMatlab.m" to the following address: ~/work/owl 
 + 
 +Enter the file plml.cpp and add the following (~line 179)
    
    if (ep) {    if (ep) {
Line 28: Line 35:
  
  
-* configure, make, make install+Configure, make, make install. Set the library path to include the MATLAB directories 
 +  export LD_LIBRARY_PATH=/usr/local/lehrstuhl/DIR/matlab-2007b/bin/glnxa64:$LD_LIBRARY_PATH
  
-* set the library path to include the MATLAB directories +Move to the ~/work/owl directorystart Prolog and run the following commands 
- export LD_LIBRARY_PATH=/usr/local/lehrstuhl/DIR/matlab-2007b/bin/glnxa64:$LD_LIBRARY_PATH +  ?- assert(user:file_search_path(foreign, '/usr/wiss/tenorth/work/owl/lib')),  
- +     assert(user:file_search_path(library, '/usr/wiss/tenorth/work/owl/lib')). 
-* move to the ~/work/owl directory +  true. 
- +   
-start Prolog and run the following commands +  ?- use_module(library(plml)). 
- ?- assert(user:file_search_path(foreign, '/usr/wiss/tenorth/work/owl/lib')), assert(user:file_search_path(library, '/usr/wiss/tenorth/work/owl/lib')). +  % hostname set to atradig131 
- true. +  %  library(hostname) compiled into hostname 0.03 sec, 403,152 bytes 
- +  %   library(ops) compiled into ops 0.00 sec, 8,104 bytes 
- ?- use_module(library(plml)). +  %  library(utils) compiled into utils 0.01 sec, 65,408 bytes 
- % hostname set to atradig131 +  %  library(flists) compiled into flists 0.00 sec, 10,456 bytes 
-  library(hostname) compiled into hostname 0.03 sec, 403,152 bytes +  % library(plml) compiled into plml 0.08 sec, 619,872 bytes 
-   library(ops) compiled into ops 0.00 sec, 8,104 bytes +  true. 
-  library(utils) compiled into utils 0.01 sec, 65,408 bytes +   
-  library(flists) compiled into flists 0.00 sec, 10,456 bytes +  ?- ml_open(ml). 
- % library(plml) compiled into plml 0.08 sec, 619,872 bytes +  Matlab engine (ml) open. 
- true. +  true. 
- +   
- ?- ml_open(ml). +  ?- float(A)===2*pi. 
- Matlab engine (ml) open. +  A = 6.28319.
- true. +
- +
- ?- float(A)===2*pi. +
- A = 6.28319.+
  
-NOTE: Just in case you have the following error:+NOTE: In case you have the following error:
   ?- ml_open(ml).   ?- ml_open(ml).
   ERROR: Unhandled exception: Unknown message: open engine failed   ERROR: Unhandled exception: Unknown message: open engine failed
  
-This means that you need to do the following:+This means that you need to do the following:
   $ sudo apt-get install csh.    $ sudo apt-get install csh. 
-By default c-shell is installed in /bin/csh. +By default c-shell is installed in /bin/csh. That is necessary because you need to have C shell installed in your system as /bin/csh for the matlab engine program to function correctly. You can use any shell, but just that C shell has to be there in the system so that the engine program can use it.
-That is necessary because you need to have C shell installed +
-in your system as /bin/csh for the matlab engine program +
-to function correctly. You can use any shell, but just that +
-C shell has to be there in the system so that the engine +
-program can use it.+