CPLEX - getting minimum of a set of variables over a condition

非 Y 不嫁゛ 提交于 2019-12-24 14:16:59

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!