MiniZinc / MiniSearch

the source code for the MiniSearch meta-search language
Other
5 stars 0 forks source link

Problem with output of var-array for sol() call in MiniSearch #4

Open Alexander-Schiendorfer opened 8 years ago

Alexander-Schiendorfer commented 8 years ago

When running LNS, it seems that an array of var int isn't correctly sent to the output model.

This refers to the feature/minisearch branch at commit https://github.com/MiniZinc/libminizinc/commit/18a7cb257babb23c1cc24eccd1e6da2c9f54f2b3

When trying to run the following minimal LNS,

include "minisearch.mzn";
array[1..2] of var 0..10: xs;
constraint xs[2] <= 8;

var 0..18: obj;

constraint obj = xs[1] + xs[2];

constraint xs[1] < xs[2];

output["XS = \(xs), obj = \(obj)"];

solve 

search lns_max(obj, xs, 5, 0.5) 
/\ if hasSol() then print() 
   else print("No solution found\n") 
   endif;

I get the error

MiniZinc: evaluation error: could not find solution for unknown identifier: X_INTRODUCED_0

where X_INTRODUCED_0 isxs[1], according to the compiled FlatZinc.

However, substituting the IntVar-Array by individual identifiers works:

include "minisearch.mzn";
var 0..10: x;
var 0..8: y; 
var 0..18: obj;

constraint obj = x + y;

constraint x < y;

output["x = \(x), y = \(y), obj = \(obj)"];

solve 

search lns_max(obj, [x,y], 5, 0.5) 
        /\ if hasSol() then print() 
           else print("No solution found\n") 
       endif;

The problem is not prevalent in commit 218a0cf36c6bd657b47fbcc3f613fb753058d287 .

I found that the error is output in line 2108 of builtins.cpp. I could not localize the bug further, though.

Cheers, Alex

Alexander-Schiendorfer commented 8 years ago

This should basically fix it :

https://github.com/MiniZinc/libminizinc/pull/78