【问题标题】:25: syntax error in literal set Context: ...C ; in MathProg model processing error25: 文字集合中的语法错误 Context: ...C ;在 MathProg 模型处理错误
【发布时间】:2019-08-29 02:13:59
【问题描述】:

我的代码的最后两个函数有问题。有人可以帮我吗?

project.c:25: 文字集中的语法错误 Context: ...C ;受制于 setofitem { j in N } : Yj [ j ] >= sum { j in MathProg 模型 处理错误

param m, integer, >=0;    #number of items
param n, integer, >=0;    #number of buyers
set M := 1..m;            #set of indices of items
set N := 1..n;            #set of indices of buyers
set S {1..n};             #subset of j

param k {M};             #seller's supply (fortinura venditore )
param v {N};             #given value of j for_SJ

var C >=0;  
var Pj {N} >=0;           #paymemt of buyer j 
var Yj {N}, binary;       #1if obtains preferred subset Sj
var Xij {M,N}, binary;    #1if J obtains an item i #supply costants

subject to production {i in M}:
sum {j in N} Xij[i,j] <= k[i];

subject to payment {j in N}:          #no more than Vj
Pj[j] <= v[j] * Yj[j];

subject to anyotherbuyer {j in N}:
Pj[j] <= C;

#subject to setofitem {j in N}:
#Yj[j] >= sum {j in N} Xij[i,j] - (|S[j]|-1)  ;

#subject to any {j in N}:
#C <= v[j]*Yj[j] +(1-Yj[j]) * sum {j in N} v[j]   ;

maximize revenue:
sum {j in N} Pj[j];


solve;
printf "the objective function value is %.3f\n", revenue;

end;

【问题讨论】:

    标签: glpk


    【解决方案1】:
    subject to setofitem {j in N}:
    Yj[j] >= sum {j in N} Xij[i,j] - (|S[j]|-1)  ;
    

    您对约束使用相同的索引 j,并且 sum 和 i 未定义。请检查您的索引。

    没有|| GLPK 中的运算符。使用 abs()。

    【讨论】:

      猜你喜欢
      • 2016-04-30
      • 2021-07-17
      • 1970-01-01
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-29
      相关资源
      最近更新 更多