[ library(minizinc) | Reference Manual | Alphabetic Index ]

# mzn_load_string(++MznModel, ++SolverOrOptions, ++ParMap, +VarMap, -FznState)

Load a MiniZinc model given as a string or list

MznModel
  String, Atom or List of constants
SolverOrOptions
  Name of solver mapping module, or zn_options-structure
ParMap
  List of FznId=ECLiPSeGroundTerm correspondences
VarMap
  List of FznId=ECLiPSeVarTerm correspondences
FznState
  FlatZinc state descriptor

## Description

Loads the MiniZinc model MznModel, given in the simplest form as a string in MiniZinc syntax. The problem is set up using a mapping to a concrete ECLiPSe solver, as specified in the SolverOrOptions argument. Neither search nor output are done.

Note that, because of the rules for escaping characters within ECLiPSe strings, any backslashes in the MiniZinc source have to be doubled, and double quotes must be escaped with a backslash!

To pass parameters into the model, a ParMap can be given, consisting of a list of FznId=ECLiPSeGroundTerm correspondences. Here, FznId is an atom (the FlatZinc parameter identifier within the model), and ECLiPSeGroundTerm is the corresponding ECLiPSe constant.

To access the ECLiPSe variables corresponding to the model's variables, VarMap can be given, consisting of a list of FznId=ECLiPSeTerm correspondences. Here, FznId is an atom (the FlatZinc variable identifier within the model), and ECLiPSeTerm is the corresponding ECLiPSe constant, variable or array.

The mzn_load_string/5 predicate returns a FlatZinc solver state which can be used to lookup further information about the model (fzn_var_lookup/3, fzn_obj_lookup/2), to perform the standard search (fzn_search/1), or to perform the model's output actions (fzn_output/1).

### Modes and Determinism

- mzn_load_string(++, ++, ++, +, -) is semidet

### Fail Conditions

Fails if the constraint setup fails

## Examples

        ?- mzn_load_string("
    		int: n;
    		array [1..n] of var 1..n: q;
    		constraint
    		    forall (i in 1..n, j in i+1..n) (
    			q[i]     != q[j]     /\\
    			q[i] + i != q[j] + j /\\
    			q[i] - i != q[j] - j
    		    );
    		solve satisfy;
    	    ",
    	    fzn_ic,
    	    [n=8],
    	    [q=Q],
    	    FznState).

        Q = [](_2492{1..8}, _2512{1..8}, _2532{1..8}, _2552{1..8}, ...]
        FznState = state(...)
        There are 84 delayed goals.
        Yes (0.02s cpu)

        ?- mzn_load_string("...", fzn_ic, [n=8], [q=Q], FznState),
           ic:labeling(Q).

        Q = [](1, 5, 8, 6, 3, 7, 2, 4)
        FznState = state(...)
        Yes (0.03s cpu, solution 1, maybe more)

        ?- mzn_load_string("...", fzn_ic, [n=8], [q=Q], FznState),
           ic:labeling(Q),
           fzn_output(FznState).

        % output from fzn_output:
        q = [1,5,8,6,3,7,2,4];
        % Total time 0.030s cpu (0.020 setup)

        % output from ECLiPSe toplevel:
        Q = [](1, 5, 8, 6, 3, 7, 2, 4)
        FznState = state(...)
        Yes (0.03s cpu, solution 1, maybe more)
    </PRE>

## See Also

mzn_run / 2, mzn_run / 3, mzn_run_string / 2, flatzinc : struct(zn_options)