SOS constraint problem
回答済みDear community,
I'm trying to model the part-load efficiency (cop) of a heat pump as a function of the installed capacity and the load-level. In a simple case, let's take that the installed capacity is already a fixed parameter, then eff is a function of load-level only. Load-level is a variable of time (t).
model.addConstrs(v_hp_heat[t] == v_hp_power[t]*v_hp_cop[t] for t in T)
model.addConstrs(v_hp_cop[t] == 0.8*v_weight1[t]+2.0*v_weight2[t]+3.0*v_weight3[t]+3.65*v_weight4[t]
+3.85*v_weight5[t] for t in T)
model.addConstrs(1 == v_weight1[t]+v_weight2[t]+v_weight3[t]+v_weight4[t]+v_weight5[t] for t in T)
model.addSOS(GRB.SOS_TYPE2, [v_weight1[t], v_weight2[t], v_weight3[t], v_weight4[t], v_weight5[t]],
[0.1, 0.3, 0.5, 0.7, 0.9])
This last statement is where I get into trouble. I can't figure out how to assign the weight values at each time-step. I also tried adding "for t in T" inside SOS constraint but that didn't work. Maybe one of you have an idea?
Regards
Buddi
-
正式なコメント
This post is more than three 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 why not try our AI Gurobot?. -
Hi Buddi,
I assume the issue is that you are getting an error like "name 't' is not defined" in your addSOS line. Correct?
If you want to add one SOS constraint for each t, you will have to use a loop; e.g.:
for t in T:
model.addSOS(GRB.SOS_TYPE2, [v_weight1[t], v_weight2[t], v_weight3[t], v_weight4[t], v_weight5[t]],
[0.1, 0.3, 0.5, 0.7, 0.9])0
投稿コメントは受け付けていません。
コメント
2件のコメント