我的代码的后两个功能有问题。有人可以帮我吗?
project.c:25:文字集中的语法错误Context:... C;服从 setofitem {N中的j}:Yj [j]> = sum {MathProg模型中的j 处理错误
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;
答案 0 :(得分:0)
subject to setofitem {j in N}:
Yj[j] >= sum {j in N} Xij[i,j] - (|S[j]|-1) ;
您对约束和总和使用相同的索引j,而i未定义。请检查您的索引。
没有|| GLPK中的运算符。使用abs()。