How to print the cost function in every step of optimization in Gurobipy?
AnsweredI 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
-
Official comment
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 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
Post is closed for comments.
Comments
2 comments