IntVar as index in constraints

28 views
Skip to first unread message

Vijaya Krishna Kasula (Vijju)

unread,
Jul 5, 2023, 8:16:08 AM7/5/23
to Gecode
Hello Experts,

Is there a way to use IntVar as an index in the constraint to further solve based on the current value of IntVar?

For example:

IntVar idx, a;
rel(*this, a == array[idx]);
rel(*this, a <= 10);

`a` and `idx` should be solved in pair such that they point to index and value from an array, while also satisfying some constraints on `a` by itself.

PS: This throws a compile time error saying `IntVar` is not implemented for operator `[]`

-
Krishna

Mikael Zayenz Lagerkvist

unread,
Jul 5, 2023, 8:18:50 AM7/5/23
to gec...@googlegroups.com
Hi,

This is called the element constraint. See
https://www.gecode.org/doc-latest/reference/group__TaskModelMiniModelArith.html#ga4af99d4cf5b1874681710bd7233ec5d0
for documentation.

Cheers,
Mikael
> --
> You received this message because you are subscribed to the Google Groups "Gecode" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gecode+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gecode/42d0fd3c-fc8b-424c-b2dc-4bd48e080a83n%40googlegroups.com.



--
Mikael Zayenz Lagerkvist
Reply all
Reply to author
Forward
0 new messages