"fix" with "all_equal"

17 views
Skip to first unread message

Samrat Kadge

unread,
Nov 4, 2025, 2:58:44 PMNov 4
to MiniZinc
include "globals.mzn";
array[1..4] of int: seq = 1..4;

var bool: v1 = all_equal(seq);
output["v1: \(v1)\n"];

bool: v2 = fix(v1);


Error: evaluation error: expression is not fixed
/mnt/Data/Documents/lab/par_func_to_var/test_all_equal.mzn:7.1-8
  in variable declaration for 'v2'
  in call 'fix'

version: 2.9.3

test_all_equal.mzn
test_all_equal.mzn

Samrat Kadge

unread,
Nov 4, 2025, 2:59:54 PMNov 4
to MiniZinc
both the attached files are same.

Jip Dekker

unread,
Nov 4, 2025, 5:04:22 PMNov 4
to MiniZinc
Hi Samrat,

I'm not fully sure what the aim of your model is. The error just suggests that the value of `v1` cannot be determined when the right-hand side of `v2` gets flattened. This will always be the case, as `v1` could be both `true` or `false` in valid solutions to the model instance, and it is up to a solver to make the search decisions (which happens after flattening).

Maybe you might have intended to use `v2` only once a solution has been found (for output purposes). In that case, you could annotate `v2` as `output_only` and fix would be possible:

bool: v2 ::output_only = fix(v1);

Cheers,
Jip

Samrat Kadge

unread,
Nov 4, 2025, 5:54:44 PMNov 4
to MiniZinc
Hi Jip,
Thanks for the reply.

I have written my motivation here. https://groups.google.com/g/minizinc/c/U2k-uNh-lpc
With respect to the current question,

function var bool :  func_var(list of var Teams: seq, set of Teams: teams) =
        let {
                bool : p = exists( [t in teams | t in seq ] );
                bool : q = all_equal(seq);
        } in
        p -> q
;
function bool :  func_par(list of Teams: seq, set of Teams: teams) =
        let {
                bool : p = exists( [t in teams | t in seq ] );
                bool : q = fix(all_equal(seq));
        } in
        p -> q
;

Note func_var: has var input(seq) and var output 
I want to use same or similar function to evaluate hints to variable(v2) in stage2, using hint to a variable(v1) in stage1.
v2 is functionally determined using func_var.
************************************************************

I tried the following example and it worked
function array[1..2] of var int: func(var int: x1, var int: x2)=
        [x1,x2];        

int: p1 = 1;
int: p2 = 2;

array[1..2] of int: p3 = fix(func(p1,p2));

output["p3: \(p3)\n"];

******************************************************************
Thanks,
Samrat
Reply all
Reply to author
Forward
0 new messages