TypeError: unsupported operand type(s) for *: 'IntVar' and 'float'

159 views
Skip to first unread message

Mohammad Mufassir Khan

unread,
Dec 11, 2022, 2:34:05 AM12/11/22
to or-tools-discuss
Hi,

I'm trying to implement a constraint as follows:

routing.solver().Add(capacity_dimension.CumulVar(idx) * routing.ActiveVar(idx) >= capacity_dimension.CumulVar(routing.End(v)) * 0.5 )

It gives error:

TypeError: unsupported operand type(s) for *: 'IntVar' and 'float'

How can I resolve this. I want to implement capacity_dimension.CumulVar(idx) * routing.ActiveVar(idx) should be more than half of capacity_dimension.CumulVar(routing.End(v)).

TIA

Mohammad Mufassir Khan

unread,
Dec 11, 2022, 2:41:14 AM12/11/22
to or-tools...@googlegroups.com
This is solved. Just needed to multiply the constraint by 2 on both sides.

2 * capacity_dimension.CumulVar(idx) * routing.ActiveVar(idx) >= capacity_dimension.CumulVar(routing.End(v))

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/b6683e41-2f64-444a-b939-e04c998f325en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages