or-toolsvehicle-routing

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


I am 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 tried capacity_dimension.CumulVar(routing.End(v)).Value() * 0.5 on RHS but this kills the kernel.


Solution

  • Fixed on https://groups.google.com/g/or-tools-discuss/c/LS2vixRsI_Y/m/7NnpJIRyAgAJ

    The solver is integral, instead of multiply one side by 0.5, multiply the other by 2.