I have a simple model written in minizinc and I use gecode to solve it by compiling it into flat-zinc first. As an input, the model takes some constants, arrays, and matrices (in the form of 2-dimensional arrays). The output of the model is another 2d matrix that has to satisfy some constraints.
Target optimization is to minimize the value of "target" which is a particular function of the output matrix and defined as following:
var float: target = sum(i in 1..nodes, j in 1..nodes) (F(i, j) * output_matrix[i, j]);
solve minimize target;
When I execute this model as follows:
mzn2fzn model.mzn model.dzn
fzn-gecode -a model.fzn
I can see a stream of possible solutions with the last one in the list to be the optimal. However, if I add an output statement into the model to print the value of the "target" variable - gecode hangs for hours without finding any solutions at all and prints ==UNKNOWN== if interrupted.
output [
"target: ", show(target), "\n"
];
Is this is an expected behavior, if so, could you explain why?
Cheers