New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid(?) evaluation error in 2.0.8, compiles in 2.0.2. #57

Closed
EmilGedda opened this Issue Oct 24, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@EmilGedda

EmilGedda commented Oct 24, 2015

The following piece of code is an excerpt from some example code provided by my uni. Although, trying to compile it with MiniZinc 2.0.8 results in this error.

MiniZinc: evaluation error:
cannot evaluate expression 'labs'

Whereas compiling it with MiniZinc 2.0.2 works great.
Tried it on both Win7 with MiniZinc 2.0.8 (bundle) and on Arch Linux with the 64bit binary, both yielding the same error in 2.0.8, and compiling flawlessly in 2.0.2.

I'm fairly new to MiniZinc, my best guess though, is that the problem is related to the code inside the let-block.

include "globals.mzn";

int: solutions;
array [Solutions] of int: solution_lab;
array [Solutions] of set of int: solution_group;

set of int: Solutions = 1..solutions;
set of int: Labs = {lab | lab in solution_lab};

array [Labs] of int: student_lab_count = 
   [sum (sol in Solutions where solution_lab[sol] = l) (card(solution_group[sol])) | l in Labs];

array [Labs] of int: presentations_per_lab = [student_lab_count[l] div 2 | l in Labs];
int: presentations = sum(presentations_per_lab);

function array[int] of Labs: compute_presentations(set of Labs: labs) =
          if card(labs) == 0 then
             []
          else
             let {
               int: next_lab = min(labs),               
               array[int] of Labs: result = [next_lab | i in 1..presentations_per_lab[next_lab]] ++ 
                                            compute_presentations(labs diff {next_lab})
             } in
             result
          endif;

array [int] of Labs: presentation_lab = compute_presentations(Labs);
solve satisfy;

Example data:

solutions = 2;
solution_lab = [1, 2,];
solution_group = [{1,2}, {1,3}];

(this code by itself is useless, and is just an example to highlight the issue at hand)

@guidotack guidotack closed this in df0da84 Dec 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment