简体   繁体   English

CPLEX:如何在 OPL 中运行子集约束?

[英]CPLEX: How to run subset constraints in OPL?

CPLEX; CPLEX; Mixed Integer Linear Programming;混合 Integer 线性规划; Constraint Formulation:约束公式:

There are 150 towns in the dataset, each town having several markets (or "mandis").数据集中有 150 个城镇,每个城镇都有几个市场(或“mandis”)。 Total number of mandis in the dataset = 1800. I have a binary decision variable y[mandi][days].数据集中的 mandis 总数 = 1800。我有一个二元决策变量 y[mandi][days]。 I want to add a constraint which states that y[mandi][days] is equal for all mandis within any given town on any given day.我想添加一个约束条件,即 y[mandi][days] 在任何给定日期对任何给定城镇内的所有 mandis 都是相等的。 y[mandi][days] could be different/same for the mandis in different towns on the same day. y[mandi][days] 对于同一天不同城镇的 mandis 可能不同/相同。

Sample Data样本数据

I'm inputting the data from Excel.我从 Excel 输入数据。 Please see the attached image.请看附图。 Can you help me out with how to formulate this constraint in OPL?你能帮我解决如何在 OPL 中制定这个约束吗?

One way to achieve the above is to specify individual constraints on the set of mandis within each town.实现上述目标的一种方法是在每个城镇内的一组 mandis 上指定单独的约束。 However, the number of constraints, in that case, would become 150, each referring to one town.但是,在这种情况下,约束的数量将变为 150,每个都指一个城镇。 Also, we might receive from the client an additional list of mandis for some towns, which would distort the mandi-town mapping numbering, and I would have to change the mapping in CPLEX again.此外,我们可能会从客户端收到一些城镇的附加 mandis 列表,这会扭曲 mandi-town 映射编号,我将不得不再次更改 CPLEX 中的映射。 Is there a better way to do this, which could take the mapping directly from excel in the attached image format?有没有更好的方法来做到这一点,它可以直接从 excel 以附加的图像格式获取映射?

Instead of the decision variable而不是决策变量

dvar boolean y[mandi][days]

why not use为什么不使用

dvar boolean y[town][days]

? ?

And then when you need the y for a given mandi, you first get the town of that mandi and then get its y.然后,当您需要给定 mandi 的 y 时,您首先获取该 mandi 的城镇,然后获取它的 y。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM