GLPK在约束中使用变量



我试图写一个约束,但我得到这个错误:

    Main.mod:25: operand preceding < has invalid type
    Context: ...es : sum { ta in Task_Names } Time_Source [ ti , ma , ta ] <MathProg model processing error
    >Exit code: 1    Time: 0.241

这是代码:

set Tasks dimen 4;
set endTimes := setof{(t,s,e,d) in Tasks}e;
set Task_Names := setof{(t,s,e,d) in Tasks}t;
set Machines dimen 2;
set Machine_Names := setof{(m,a) in Machines}m;
set Task_Machines dimen 3;

param lastTime := max{t in endTimes}(t);
set time_slots := 1..lastTime;
var Start_Time{ti in time_slots,ta in Task_Names},binary;
var Time_Source{ti in time_slots,ma in Machine_Names,ta in Task_Names},integer;
s.t. c1{ti in time_slots,ma in Machine_Names,ta in Task_Names,(ta,ma,co) in Task_Machines}:Time_Source[ti,ma,ta] = co*Start_Time[ti,ta];
s.t. c2{ti in time_slots,(t,s,e,d) in Tasks : ti>=s and ti<=e and ti<=e-d}:Start_Time[ti,t]=1;
s.t. c3{ti in time_slots,(t,s,e,d) in Tasks : ti<s or ti>e or ti>e-d}:Start_Time[ti,t]=0;
s.t. c4{ti in time_slots,ma in Machine_Names,(ma,num) in Machines: sum{ta in Task_Names} Time_Source[ti,ma,ta]<num};


solve;
display:Start_Time;
display:Time_Source;
display:Machine_Names;
display:Task_Machines;
data;
set Tasks :=
(T1,3,20,1)
(T2,3,30,5)
(T3,12,40,10);
set Machines :=
(M1,2)
(M2,3)
(M3,2)
(M4,1);
set Task_Machines :=
(T1,M1,1)
(T1,M2,1)
(T2,M1,2)
(T3,M4,5);
end;

错误是针对"C4"约束的。我的问题是在"c4"我如何在其条件下使用变量?如何解决这个错误?

在我看来,好像只有两个小的拼写错误在c4 (}的位置,使用<=而不是<):

s.t. c4{ ti in time_slots,
         ma in Machine_Names,
        (ma,num) in Machines}: 
            sum{ta in Task_Names} Time_Source[ti,ma,ta] <= num;

我将整个固定示例复制到浏览器内的MathProg编辑器中(包含GLPK.js求解器)。

相关内容

  • 没有找到相关文章

最新更新