Error: syntax error, unexpected any; when using OR-Tools solver with Minizinc - or-tools

I want to use the OR-Tools solver in combination with MiniZinc (IDE or CLI).
I followed the steps in this answer. My MiniZincIDE is now set up like this: .
When I select the OR tools solver and try to run it on a simple .mzn model I get the following error:
(included from file '/home/my_username/lib/MiniZincIDE-2.5.5-bundle-linux-x86_64/share/minizinc/std/solver_redefinitions.mzn')
/home/my_username/lib/MiniZincIDE-2.5.5-bundle-linux-x86_64/bin/or-tools/share/minizinc/redefinitions-2.0.mzn:104.9-11:
any: xx = [ x[i] | i in index_set(x) where occurs(v[i])];
^^^
Error: syntax error, unexpected any
(included from file '/home/my_username/lib/MiniZincIDE-2.5.5-bundle-linux-x86_64/share/minizinc/std/solver_redefinitions.mzn')
/home/my_username/lib/MiniZincIDE-2.5.5-bundle-linux-x86_64/bin/or-tools/share/minizinc/redefinitions-2.0.mzn:111.9-11:
any: xx = [ x[i] | i in index_set(x) where occurs(v[i])];
^^^
Error: syntax error, unexpected any
Process finished with non-zero exit code 1
How can I solve this?

There is a conflict between the version of OR-tools FlatZinc and the MiniZinc version you have installed (version 2.5.5). The any keyword in the FlatZinc definitions requires at least MiniZinc version 2.6.0.
If you update MiniZinc to the current version it should work.

Related

How to load shared library created in Matlab

I tried to create an OpenModelica model with liquid flow and Media.
And I have a function in Matlab that calculates the PDE (partial differential equation) in pdetool.
I would like to create a shared dynamic library (.so file) in Matlab by MCR and load it in the model.
My platform: OpenModelica used on Linux or Mac OS. MCR on Linux and Mac OS installed.
In Matlab I can generate only DLL (may be it's possible to generate libmyfunc.so?).
When I try to compile the model with extern C function I got an error:
#omc +s test_matlab_so.mo func_mathlab.mo
#make -f test_matlab_so.makefile
/usr/bin/clang -Wimplicit-function-declaration -O0 -falign-functions -march=native -I"/opt/openmodelica/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o test_matlab_so_functions.o test_matlab_so_functions.c
clang: warning: optimization flag '-falign-functions' is not supported
clang: warning: argument unused during compilation: '-falign-functions'
In file included from test_matlab_so_functions.c:7:
In file included from ./test_matlab_so_includes.h:4:
./shared_train/src/lib_summ.c:90:8: warning: implicit declaration of function 'GetModuleFileName' is invalid in C99 [-Wimplicit-function-declaration]
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:90:26: warning: implicit declaration of function 'GetModuleHandle' is invalid in C99 [-Wimplicit-function-declaration]
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:90:55: error: use of undeclared identifier 'path_to_dll'
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:90:68: error: use of undeclared identifier '_MAX_PATH'
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:94:37: error: use of undeclared identifier 'path_to_dll'
mclGetEmbeddedCtfStream(path_to_dll);
^
test_matlab_so_functions.c:19:16: warning: implicit declaration of function '_mlfSumm' is invalid in C99 [-Wimplicit-function-declaration]
_v_out_ext = _mlfSumm(_v_a_ext, _v_b_ext);
^
3 warnings and 3 errors generated.
make: *** [test_matlab_so_functions.o] Error 1
Can someone help me with integrating OpenModelica and Matlab?
I don't have much experience with Linux but I did the same thing in Windows using MCR. Check this out:
http://de.mathworks.com/matlabcentral/answers/94471-how-do-i-create-a-c-c-shared-library-with-matlab-compiler-that-can-be-used-in-a-microsoft-visual-c
When you do this, you will get a DLL as well as a static library. You need to copy both of them into the folder that your modelica code is located at and then set the library in the "Library" attibute of your modelica function which calls the external function.
Keep in mind that if you are using a 64 or 32 bit dymola, you are supposed to create the DLL using the same version of matlab correspondingly.

Standard ML syntax error: illegal token on hello world program -- incorrect SML installation?

The SML file: "test.sml"
(* here is a comment *)
val x = 123;
I've installed SMLNJ 110.76 from here: http://www.smlnj.org/dist/working/110.76/, Emacs 24.3.1 from here: http://ftp.gnu.org/gnu/emacs/windows/emacs-24.3-bin-i386.zip, and SML Mode for Emacs through the Emacs GUI.
The Emacs stack trace is this:
test.sml:1.2 Error: illegal token
test.sml:1.3 Error: illegal token
test.sml:1.5 Error: illegal token
test.sml:1.7 Error: illegal token
test.sml:1.9 Error: illegal token
and so on, ending with:
uncaught exception Compile [Compile: "syntax error"]
raised at: ../compiler/Parse/main/smlfile.sml:15.24-15.46
../compiler/TopLevel/interact/evalloop.sml:44.55
../compiler/TopLevel/interact/evalloop.sml:296.17-296.20
I also tried the same program via Sublime Text 3 with the SML and sublimeREPL packages as laid out here: http://developerinmotion.wordpress.com/2013/02/07/sublime-text-2-and-sml/. But I'm getting the same problem: a long list of illegal token syntax errors followed by:
C:\Program Files (x86)\SMLNJ\\bin\.run\run.x86-win32.exe: Fatal error -- Uncaught exception Compile with "syntax error" raised at ../compiler/Parse/main/smlfile.sml:15.24-15.46
What's the problem? Have I installed SMLNJ incorrectly?
I put your two lines in a file (test.sml) and opened in a standard SML REPL. It compiles normally:
- use "test.sml";
[opening test.sml]
val x = 123 : int
val it = () : unit
It seems that you have problems with setting your tools.
This problem may result from creating .sml file using UTF-8 character encoding. pls use ANSI instead.

VHDL/ModelSim - Could Not Find Entity

I am trying to simulate my VHDL file, but am running into the following error:
# ** Error: (vcom-11) Could not find work.lab1.
#
# ** Error: (vcom-1195) Cannot find expanded name "work.lab1".
#
# ** Error: Unknown expanded name.
# ** Error: VHDL Compiler exiting
# ** Error: c:/altera/12.1/modelsim_ase/win32aloem/vcom failed.
# Error in macro ./DE2_TOP_run_msim_rtl_vhdl.do line 8
# c:/altera/12.1/modelsim_ase/win32aloem/vcom failed.
# while executing
# "vcom -93 -work work"
I compiled the code successfully through both Quartus II and the ModelSim compiler before attempting to simulate. I do have a lab1 entity and architecture in my code (I can even see it in the Design Units tab of the Quartus Project Navigator), so I don't really understand this error. Anyone know what's causing this?
When the simulator is compiling the toplevel (DE2_TOP) it want to know how the used components are like. So, you should have compiled the lowerlevel components before compiling the upperlevel components.
What I do most of the times to fix this is compiling all components in correct order and then use the 'vmake' ('vmake -work work > work.vmake') command of Modelsim to generate a makefile out of the library (work). Once you have the makefile you can execute it with (make -f work.vmake). And all files will be compiled in order.
Note: Verilog is much more relaxed in those things...

Vedaldiā€˜s SIFT in MATLAB - error in sift_compile

When I tried to compile Vedaldi's SIFT algorithm in MATLAB, I got the following error while compiling:
sift_compile
D:\PROGRA~1\MATLAB\R2010A~1\BIN\MEX.PL: Error: 'imsmooth.c' not found.
??? Error using ==> mex at 222
Unable to complete successfully.
Error in ==> sift_compile at 33
mex('imsmooth.c',opts{:}) ;
I did got mex to run on other cases, the compiler I used is VS2008. And the path of the imsmooth.c and other source code is also included in the MATLAB path. Could someone give me some hints how should I get it work?
C:\Program Files\MATLAB\R2011a\sift\
add in the pathnames helps!

Converting MATLAB files to Octave

I have a series of experiments that were written for MATLAB, but recently we are trying to run them through Octave instead. I realize they are mostly compatible, but I have been running into a few problems, and none of the online FAQs or directions I have found have addressed these at all. It's complicated a bit because there are multiple .m files that interact; however, for now I am going to focus on the main program. Anyway, so when I try to run the file (MLP.m) through octave, I get the following errors in the Terminal window:
error: dir: expecting directory or filename to be a char array
error: called from:
error: /Applications/Octave.app/Contents/Resources/share/octave/3.2.3/m/miscellaneous/dir.m at line 128, column 5
error: /Applications/MATLAB_R2008a/toolbox/psychoacoustics/MLParameters.m at line 86, column 7
error: /Applications/MATLAB_R2008a/toolbox/psychoacoustics/MLP.m at line 9, column 3
The lines it is referencing are as follows:
1)
d = dir([cd myslash 'Experiments_MLP' myslash '*.m']);
2)
s = MLParameters;
What about these lines is incompatible with Octave? I can't find anything online that indicates that these won't work.
After that, the Terminal window gives me this batch of nonsense:
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71: 1077 Trace/BPT trap GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$#"
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71: 1083 Trace/BPT trap GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$#"
error: you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the 'gnuplot_binary' function
I have GNUPlot installed, and I checked the gnuplot_binary function, which didn't give me any answers. GNUPlot is installed in my /Applications directory, along with Octave itself. Why shouldn't this work? The README file that came with GNUPlot didn't indicate a special directory for it to be installed in. What about the the dyld library not loaded errors? Is that related to the GNUPlot problem, or is it something else?
Anyway, thanks for your help
I know you already solved your problem, but if you have problems again here are some links with basic information about the differences between Matlab and Octave:
Porting programs from Matlab to Octave
Differences between Octave and MATLAB
Addressing your first error, it's easier to explain with an example:
dirName = '/some/path'; %# base directory
filesPath = fullfile(dirName, 'MLP', '*.m'); %# full path string
d = dir(filesPath); %# expand/enumerate files
for i=1:numel(d)
disp( d(i).name )
end
You also could have built the path using string concatenation yourself:
%# '/some/path/MLP/*.m'
filesPath = [dirName filesep 'MLP' filesep '*.m'];
The above should work for both MATLAB and Octave