How to print the cost function in every step of optimization in Gurobipy?
回答済みI am going to plot cost function (feval) in terms of iterations in Gurobipy?
Could you please help me how to do that?
The code is in the foolowing:
import gurobipy as gp
gurobipy_model = gp.Model("gurobi")
x = [gurobipy_model.addVar(vtype=gp.GRB.CONTINUOUS, name="x%s" % i, lb=0, ub=1) for i in range(len(Sigma))]
objective = sum([Mu[i][0] * x[i] for i in range(len(Mu))])
objective -= 2 * sum(
[Sigma[i][j] * x[i] * x[j] for i in range(len(Mu)) for j in range(len(Mu))]
)
gurobipy_model.setObjective(objective,gp. GRB.MAXIMIZE)
GurobiOptimizer().solve(qp2)
Thanks
0
-
Hi Shadi,
The better approach is probably to use grblogtools to read your logfiles and produce plots. This is what we're using on a daily basis internally at Gurobi.
Do you think that would get you what you're after?
- Riley
0
サインインしてコメントを残してください。
コメント
1件のコメント