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))
-
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
サインインしてコメントを残してください。
コメント
1件のコメント