【问题标题】:Create OPL CPLEX tuple set by joining tuple sets with an additional condition on supersets related to joining rows通过在与连接行相关的超集上使用附加条件连接元组集来创建 OPL CPLEX 元组集
【发布时间】:2021-12-03 00:50:21
【问题描述】:

我的模型中有一个元组集,定义如下:

tuple taskToolThTuple {string task; string tool; float throughput;};
{taskToolThTuple} taskToolTh = ...;

填充此元组集的数据如下所示:

taskToolTh = {
<"task1", "tool1", 10>
<"task1", "tool2", 11>
<"task1", "tool3", 12>
<"task2", "tool1", 8>
<"task3", "tool1", 9>
<"task3", "tool3", 14>
...
};

换句话说,任务需要特定的工具才能完成。有些任务需要 1 个工具,有些任务需要多个工具。

此外,任务只能在包含任务所需的所有工具的工作站上执行。每个站可以使用哪些工具的数据位于单独的元组集中:

tuple stationToolTuple {string station; string tool;};
{stationToolTuple } stationTool = ...;

数据看起来像这样:

stationTool = {
<"station1", "tool1">
<"station2", "tool1">
<"station2", "tool3">
<"station3", "tool2">
<"station3", "tool3">
<"station4", "tool1">
<"station4", "tool2">
<"station4", "tool3">
...
};

我需要做的是创建一个新的元组集,其中包括站、工具、任务、吞吐量,但只将任务添加到可以处理任务的站。例如,工位 2 有工具 1 和工具 3 可用,因此任务 2 和任务 3 都可以在那里执行。但是,任务 1 需要工具 1、2 和 3,因此无法在那里执行。

如果允许这种语法,我认为这会起作用:

{tuple} StationToolTaskThTuple = {string station; string tool; string task; float throughput;};
{StationToolTaskTuple} StationToolTask = {<s,to,ta,th> | <ta,to,th> in taskToolTh, <s,to> in stationTool : card({to2 | <ta,to2,th> in taskToolTh} inter {to2 | <s,to2> in stationTool}) == card({to2 | <ta,to2,th> in taskToolTh})};

上面的想法是我加入 taskToolTh 和 stationTool 中工具匹配的任何行,但只有当加入行也满足 station s 包含每个工具 to 这是任务 ta 所必需的。不幸的是,我在这一行遇到错误(“过滤器表达式当前不支持聚合集。”)。

如果可能的话,我想不使用脚本语言来做这件事。这可能吗?如果是这样,我将不胜感激如何做到这一点。

【问题讨论】:

    标签: mathematical-optimization cplex opl


    【解决方案1】:

    您可以在之前进行一些计算,以免在集合计算中进行切片。

    例如以下作品:

    .mod

    tuple taskToolThTuple {string task; string tool; float throughput;};
    {taskToolThTuple} taskToolTh = ...;
    
    tuple stationToolTuple {string station; string tool;};
    {stationToolTuple } stationTool = ...;
    
    int c1[t in taskToolTh, s in stationTool ]=
    card({s.tool | s2 in taskToolTh:t.task==s2.task } inter
     {t.tool | t2 in stationTool:t2.station==s.station});
    int c2[t in taskToolTh, s in stationTool ]=
    card({t2.tool |t2 in  taskToolTh:t2.task==t.task});
    
    tuple StationToolTaskThTuple  
    {string station; string tool; string task; float throughput;};
    {StationToolTaskThTuple} StationToolTask = 
    
    {<s,to_,ta,th> | <ta,to_,th> in taskToolTh, <s,to_> in stationTool 
    : 
    //card({to2 | <ta,to2,th> in taskToolTh} inter {to2 | <s,to2> in stationTool}) == card({to2 | <ta,to2,th> in taskToolTh})
    c1[<ta,to_,th> , <s,to_>  ]==c2[<ta,to_,th> , <s,to_>  ]
    };
    
    execute
    {
      writeln(StationToolTask);
    }
    

    .dat

    stationTool = {
    <"station1", "tool1">
    <"station2", "tool1">
    <"station2", "tool3">
    <"station3", "tool2">
    <"station3", "tool3">
    <"station4", "tool1">
    <"station4", "tool2">
    <"station4", "tool3">
    };
    
    taskToolTh = {
    <"task1", "tool1", 10>
    <"task1", "tool2", 11>
    <"task1", "tool3", 12>
    <"task2", "tool1", 8>
    <"task3", "tool1", 9>
    <"task3", "tool3", 14>
    
    };
    

    【讨论】:

      猜你喜欢
      • 2018-06-30
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-13
      • 1970-01-01
      相关资源
      最近更新 更多