1

I just tried to run mzn2fzn over the following MiniZinc file:

var float: x1;
var float: y1;
var float: x2;
var float: y2;
constraint (x1 / y1) = 6.0;
constraint x2 * y2 <= 5.0;
solve satisfy;

This is the resulting FlatZinc file:

var -1.7976931348623157e+308..5.0: FLOAT____00001 :: is_defined_var :: var_is_introduced;
var float: x1;
var float: x2;
var float: y1;
var float: y2;
constraint float_div(x1, y1, 6.0);
constraint float_times(x2, y2, FLOAT____00001) :: defines_var(FLOAT____00001);
solve satisfy;

The version of mzn2fzn is as follows:

~$ mzn2fzn --version
G12 MiniZinc to FlatZinc converter, version 1.6.0
Copyright (C) 2006-2012 The University of Melbourne and NICTA

I have the following questions:

Does any FlatZinc solver actually support them?


N.B. I actually found trace of these functions in the docs for FlatZinc 2.2.0, however, I don't understand why these are generated by the version 1.6 of mzn2fzn when its documentation does not seem to mention either of them.

Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40

1 Answers1

3

It seems to be oversight in the documentation of FlatZinc 1.6 that the constraints float_div and float_times are not documented. These constraints are necessary parts of the FlatZinc built-ins to be understood by solvers with support for floating point variables. They cannot be rewritten into other constraints that are among the FlatZinc builtins and that's why the compiler will use them. I would note that int_div and int_times are documented within the documentation of the old version of FlatZinc and the meaning of the constraints can be extrapolated from these constraints. (I'm also under the impression that their meaning has not changed in the conversion to FlatZinc 2.2.0)

Gecode, the CP solver shipped with MiniZinc, has support for these constraints.

Dekker1
  • 5,565
  • 25
  • 33
  • Just to confirm, since in FV we have several different practices.. what is the desired semantics in the case of `0.0/0.0` (*undefined*?) and `k/0.0, k != 0.0` (*unsat*?) in MiniZinc/FlatZinc with `float` variables? Gecode encounters some internal error whenever the divisor is equal to zero. I could not find other solvers handling the constraint. – Patrick Trentin Dec 21 '18 at 15:42
  • 1
    According to MiniZinc's relational semantics, no FlatZinc will be produced that can have a division by **0** (float or int). (or an array access out of bound for that matter). This means that the solver implement the semantics that are most natural and even strict semantics, where a solver claims `UNSAT` when it might need to evaluate undefined behaviour, would be possible. More information on this topic can be found in the paper: The proper treatment of undefinedness in constraint languages, by Frisch and Stuckey – Dekker1 Dec 24 '18 at 00:44