constraint the future state of a decision variable
回答済みHi guys,
Im trying to constraint state of a descicion variable but Im having problems please help and thank you!
for t in T:
for i in R:
if t==0:
m.addConstr((v_r[(i,t)]),gb.GRB.EQUAL,(data['Reservoir'][i]['Vmin'])+(data['Demand'][t]['Wat_inflow_r0'])-(w_s[(i,t)])-(w_d[(i,t)]),name="Volume in t+1 {}{}".format(i,t))
# restriction demand supply
else:
m.addConstr((v_r[(i,t)]),gb.GRB.EQUAL,(v_r[(i,t-1)])+(data['Demand'][t-1]['Wat_inflow_r0'])-(w_s[(i,t-1)])-(w_d[(i,t-1)]),name="Volume in t+1 {}{}".format(i,t))
when I try to do this
else:
m.addConstr((v_r[(i,t+1)]),gb.GRB.EQUAL,(v_r[(i,t)])+(data['Demand'][t]['Wat_inflow_r0'])-(w_s[(i,t)])-(w_d[(i,t)]),name="Volume in t+1 {}{}".format(i,t))# esto esta mal el estado t+1 del volumen debe depender del estado anterior
the error is TypeError: can only concatenate str (not "int") to str
0
-
正式なコメント
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Carlos,
This is a Python error and it happens when you try to add an integer to a string.
Since you are using the str.format() method, the error should not be related to the constraint names.
What are the values of the set \(\texttt{T}\)? If this set includes string values, \(\texttt{t+1}\) in \(\texttt{v_r[(i,t+1)]}\) can cause the error.
In case you need more help, please post a minimum working example.
Best regards,
Maliheh
0
投稿コメントは受け付けていません。
コメント
2件のコメント