Optimizer OR

Dear Community,

is there a possibilitly to use the logical OR in a constraint for the optimizer? I am trying to compare a variable to a constant. The constraint should default to TRUE if the varible equals zero or is the variable equals the constant. I came up with a non-linar equation (x * (x-y) = 0), but I do not know how to convert it for a linar contraint.

Thanks for your help!

Tagged:

Best Answer

  • devrathahuja
    edited February 11 Answer ✓

    Hi @FabianEbner ,
    You can create it as follows-

    The C3 takes care of either empty or full truck. V2 in the optimizer action should be set to Binary as 0/1. Here's the output-

    So demand is 1500, Capacity is 1800 but since truck 3 is 600 we have that empty & it can max serve 1200 of demand only.

    Hope this helps!😊

Answers

  • Hello @FabianEbner,
    Constraints can only have the 3 operators mentioned (< =, =, > =)

    The constraint mentioned by you can have infinite solutions where x=0, may I check what is the use case that you're trying to solve for here?

  • Hello,

    thanks for the answer. I am working on a demo use case to optimize shipments. In my simple example, I want to allocate products into trucks. Trucks should only drive if they are at maximum capacity, but to find a solution it needs to be possible for some trucks not to drive. So I need a constraint, which says that the product inside a truck has to be equal to the maximum capacity, or to zero. The objective function tries to maximize the amount of product shipped.

  • Thank you for your great expanation. This makes a lot of sense and was very helpful!