问题
I have to solve the following problem using CPLEX Java API:
I need to write a condition that will return a minimum of a set of integer variables (let's say x[i], i=1,2,...,n) but considering only the positive ones.
In other words:
min{x[i] | x[i]>0}
I know that CPLEX has the minimum function, but the problem is how to pass it the mentioned condition.
回答1:
Create a single continuous variable. Add constraints that this new variable must be <= all of the integer variables. Then just maximise the continuous variable.
回答2:
TimChippingtonDerrick's answer is missing the non-negativity constraint for the continuous variable. Moreover, that method does not accommodate the OP's original objective function.
An (expensive) way of doing this is to introduce additional binary variables, one for each integer variable and write big M constraints:
x[i] >= y >= x[i] - M(1-z[i])
SUM(i,z[i]) = 1
来源:https://stackoverflow.com/questions/17164039/cplex-getting-minimum-of-a-set-of-variables-over-a-condition