Skip to content

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

Closed

Description

@EmilGedda

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)

Activity

  1. added a commit that references this issue on Oct 27, 2015
    df0da84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions