Re: [eclipse-clp-users] annotation "timeout" in minizinc model, Eclipse 6.185

From: Joachim Schimpf <>
Date: Thu, 23 Aug 2012 21:30:09 +0200
On 23/08/2012 18:10, Kostas Oikonomou wrote:
> I have one more question: I'm trying the example of using a
> MiniZinc/FlatZinc model in Eclipse, found on the lib(flatzinc)
> reference page.  So far, I have the following code:
> my_fzn_run_file(ModelFile, Options) :-
>           % initialize the solver state
>           fzn_init(Options, State),
>           % load the model and set up the constraints
>           open(ModelFile, read, S), fzn_load_stream(S, FznState),
>           % Get the objective
>           fzn_obj_lookup(FznState, Obj),
>           % Now suppose the mzn model has variables X, a 1-d
> array, and Y, a 2d-array.
>           fzn_var_lookup(FznState, X, Xe),
> fzn_var_lookup(FznState, Y, Ye),

Here you have to single-quote 'X' and 'Y' (the FlatZinc variable names),
otherwise they will be taken as ECLiPSe variables.

You could also use mzn_load/5 for part of the code above.

>           % How do I use Xe, Ye, and Obj in bb_min()?
>           % ????

The mapping of MiniZinc data structures to FlatZinc is explained in the
FlatZinc specification: basically, multi-dimensional arrays are flattened,
and the indices normalized to start at 1.
The mapping of FlatZinc data structures to ECLiPSe is described in the
table at
Together that means that MiniZinc arrays will all end up as one-dimensional
ECLiPSe arrays, i.e. structures with functor []/N.

A brute-force way of calling bb_min in this example would be

	term_variables([Xe,Ye], Vars),
	bb_min(labeling(Vars), Obj, bb_options{}),

>           % output solution, if found
>           fzn_output(State),
>           % increments solutions count, and succeeds if last
> one reached
>           fzn_last(State),
>           !.

-- Joachim
Received on Thu Aug 23 2012 - 19:30:20 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 30 2012 - 06:14:30 CEST