Вопрос

Is there any way (direct or indirect) by which pow constraints can be supported in minizinc. Gecode supports the pow constraint with float and int variables, however Minizinc and FlatZinc does not support pow for variables. Minizinc and Flatzinc supports pow only for parameters to the model. Any pointers on where to look to add support in MiniZinc to Flatzinc (mzn2fzn) parser to do this.

I want to have a constraint such as - " pow( 4, x ) == y " , i.e. 4^x == y .

Это было полезно?

Решение

What I know it's not possible in current version of MiniZinc to use pow/2 with decision variables.

Perhaps it would be enough to emulate it with "exists"? Here's a simple example (the domain of "i" is too large in this example).

var 0..10000: x;
var 0..10000: y;
solve satisfy;

constraint
      exists(i in lb(x)..ub(x)) (
         i = x /\
         pow(4,i) = y
      )
;

output [ show([x,y]) ];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top