How to make if in the objective function

First let me say this is a lot more readable, and therefore much more accessible to folks eager to help!
However, as @odow mentioned in the other thread, assuming _PRODUCTs_ALL or PRODAMOUNT contain variables, this is not possible. The result of sum1 is an expression containing variables, and this expression is not a number, so when you compare it to 0, the answer is always false. This is clearly not the behavior you want. Unfortunately, what you want to have happen is entirely impossible. You need to introduce a binary variable as discussed in that thread that will determine which branch to take based on the value of the expression. This is sometimes called a Big-M formulation, and @odow gave an example of the approach here

1 Like