polymorphic (var to par) functions

17 views
Skip to first unread message

Samrat Kadge

unread,
Nov 4, 2025, 5:39:26 PMNov 4
to MiniZinc
Given a function which takes var inputs, and returns a var output,
can I uses the same function with par inputs and return a par output?

I want to reuse, the function in multi-objective optimization,
to generate hints for variables in stage2, using outputs from stage1,
which have a functional dependence.

I have currently tried is_defined/defines_var, but the time to first solution
is too long.

As a hack, I try to introduce variables of stage2 in stage1. This seems to work
amazingly well. But I may not be aware of all subsequent stages.

Thanks

guido.tack

unread,
Nov 5, 2025, 8:24:20 PMNov 5
to MiniZinc
There's currently no way to define a function to work with both var and par arguments of a concrete type (such as int or an enumerated type). You will have to duplicate (i.e., overload) the function definition for par and var.

Cheers,
Guido

Reply all
Reply to author
Forward
0 new messages