Hello优化人员!
我遇到以下约束的一些问题:
#The supply at node i equals what was present at the last time period + any new supply and subtracted by what has been extracted from the node.
subject to Constraint1 {i in I, t in T, c in C}:
l[i,t-1,c] + splus[i,t] - sum{j in J, v in V, a in A} x[i,j,v,t,c,a]= l[i,t,c];
自然导致此约束在第一次循环时提供错误,因为未定义t-1(对我来说,l [i,0,c]未定义。其中
var l{I,T,C} >= 0; # Supply at supply node I in time period T for company C.
param splus{I,T}; # Additional supply at i.
var x{N,N,V,T,C,A} integer >= 0; #Flow from some origin within N to a destination within N using vehicle V, in time T, for company C and product A.
并设置T; (在.mod中)是一个定义为:
的集合 set T := 1 2 3 4 5 6 7; in the .dat file
我试过:
subject to Constraint1 {i in I, t in T: t >= 2, c in C}:
all else same
这给我一个语法错误。我还试图为所有可能的组合包含“let l [1,0,1]:= 0”,这让我错误
error processing var l[...]:
no data for set I
我也试过
subject to Constraint1 {i in I, t in T, p in TT: p>t, c in C}:
l[i,t,c] + splus[i,p] - sum{j in J, v in V, a in A} x[i,j,v,p,c,a]= l[i,p,c];
其中
set TT := 2 3 4 5 6;
<。>在.dat文件中(并且仅设置TT;在.mod中)也会出错。有人知道怎么做吗?
答案 0 :(得分:1)
解决此问题的一种方法是在索引表达式的末尾指定条件t >= 2
:
subject to Constraint1 {i in I, t in T, c in C: t >= 2}:
...
有关索引表达式语法的更多详细信息,另请参阅Section A.3 Indexing expressions and subscripts。