【问题标题】:Declaring 3 sets in GLPK->syntax error in literal set在 GLPK-> 文字集中的语法错误中声明 3 个集合
【发布时间】:2016-04-22 21:07:06
【问题描述】:

我有这个小代码:

 param n, integer, > 0; # number of clients
param m, integer, > 0; # number of facilities
param g, integer, > 0;

set I := 1..n;
set J := 1..m;
set G := 1..g;

param d{i in I, j in J};/* distance for client i to factory j*/
param w{i in I, j in J};/* distance for client i to factory j*/
param l{j in J}; # distance from factory j to factory 1
param F{j in J}; # cost of open a factory in J
param s{i in I, g in G};

问题出在 s 上,它总是说 drdrd.mod:13: syntax error in literal set ,如果我将 G 中的 g 更改为 J 中的 j,一切正常。不可能有3个不同的集合吗?

还有一个我无法解决的问题,如果我在 I 中输入 2 而不是 i(因为我想考虑前 2 个数字),它也会显示相同的错误消息。

感谢您的宝贵时间。

【问题讨论】:

    标签: set glpk mathprog


    【解决方案1】:

    g被定义为参数

    param g, integer, > 0;
    

    所以你不能用它作为索引名

    param s{i in I, g in G};
    

    要修复这个重命名索引(或参数):

    param s{i in I, gg in G};
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-04
      • 2017-06-25
      • 2023-01-12
      • 1970-01-01
      • 2021-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多