Can gurobi optimize an external function?
ユーザーの入力を待っています。Hi, I want to use gurobi to optimize the distributed energy resource (DER) capacity to minimize loss. I I use pandapower function to calculate the power loss, I tried to write a model that recive the DER capacity from gurobi, solve the function via panapower and return the objective value to gurobi again. Is it possible? I elaborated my problem in the following example.
import pandapower as pp
import pandapower.networks as nw
from gurobipy import Model, GRB, quicksum
def loss_function(x):
net = nw.case33bw()
pp.create_sgen(net,bus=10,p_mw=x)
pp.runpp(net)
return net.res_line["pl_mw"].sum()
m=Model()
Gen_capacity = m.addVar(vtype=GRB.CONTINUOUS)
loss = m.addVar(vtype=GRB.CONTINUOUS)
m.update()
m.setObjective(loss,GRB.MINIMIZE)
m.addConstrs(loss=loss_function(Gen_capacity))
-
正式なコメント
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. -
Unfortunately, Gurobi does not optimize arbitrary external functions like this. Gurobi can solve problems of the form described in the What types of models can Gurobi solve? article. Are you able to explicitly write/reformulate your problem in that form (i.e., with a linear or quadratic objective function and linear, quadratic, and/or second-order cone constraints)?
0
投稿コメントは受け付けていません。
コメント
2件のコメント