我正在尝试在AMPL中编写一个约束,在MATLAB中如下所示:
if ((T[t+1, 1] <= T[t, 1]) and (T[t+1, 1] <= T_set - 1))
status[t+1] = 0;
elseif ((T[t+1, 1] > T[t, 1]) and (T[t+1, 1] >= T_set + 2))
status[t+1] = 1;
else
status[t+1] = status[t];
end
我在AMPL中尝试了以下尝试但没有成功:
subject to status01 {t in 1..duration}: ind01[t] = if (T[t+1, 1] <= T[t, 1]) then 1;
subject to status02 {t in 1..duration}: ind02[t] = if (T[t+1, 1] <= T_set - 1) then 1;
subject to status0 {t in 1..duration}: Status[t+1] = if (ind01[t] + ind02[t] == 2) then 0;
subject to status03 {t in 1..duration}: ind0[t] = if (ind01[t] + ind02[t] <> 2) then 1;
subject to status11 {t in 1..duration}: ind11[t] = if (T[t+1, 1] >= T[t, 1]) then 1;
subject to status12 {t in 1..duration}: ind12[t] = if (T[t+1, 1] >= T_set + 2) then 1;
subject to status1 {t in 1..duration}: Status[t+1] = if (ind11[t] + ind12[t] == 2) then 1;
subject to status13 {t in 1..duration}: ind1[t] = if (ind11[t] + ind12[t] <> 2) then 1;
subject to status2 {t in 1..duration}: Status[t+1] = Status[t] * ind0[t] * ind1[t];
代码无法设置任何指标的值,即ind01
,ind02
等。
请帮助我在哪里做错了。