Skip to main content

Output solutions during solve

Answered

Comments

7 comments

  • Eli Towle
    • Gurobi Staff Gurobi Staff

    Here are two ways to view new incumbent solutions as Gurobi finds them:

    0
  • Aaron Slobodin
    • Gurobi-versary
    • First Comment
    • First Question

    Awesome. Thanks so much Eli. SolFile is perfect.

    0
  • Javier Salmeron
    • First Comment

    Hi Eli.  I'd like to follow up on this. 

    I want to use the SolFiles option because I am calling Gurobi from Python-Pyomo, that is, I'm not using the native Gurobi callable library. 

    The problem I see is that the .sol files contain the solution in the internal storage form x[1], x[2], … instead of the way in which I name the variables in Pyomo.  Is there a way to obtain those original names in the .sol files?  (I looked for other Gurobi name-related parameters but did not find anything).

    Thank you.

    0
  • Eli Towle
    • Gurobi Staff Gurobi Staff

    The variable names in the .sol files match the names Pyomo gives Gurobi when it is creating the Gurobi model. You need to direct Pyomo to preserve the names of the Pyomo components when passing the model to Gurobi. For example, when using the GurobiPersistent interface:

    solver = pyo.SolverFactory("gurobi_persistent")
    solver.set_instance(model, symbolic_solver_labels=True)
    results = solver.solve(model, tee=True, options={"SolFiles": "foo"})
    0
  • Javier Salmeron
    • First Comment

    Thank you, Eli and Maliheh.  I am using the standard gurobi (not gurobi_persistent). 

    opt = SolverFactory("gurobi")
    opt.options["symbolic_solver_labels"] = True
    result = opt.solve(myModel)

    This causes an error that “symbolic_solver_labels” is not recognized by gurobipy.

    Is there another way to pass this request to gurobi or do I need to (install and) use gurobi_persistent to enable this feature?

    0
  • Eli Towle
    • Gurobi Staff Gurobi Staff

    Can you try passing Pyomo's \(\texttt{symbolic_solver_labels}\) setting like this instead?

    opt = SolverFactory("gurobi")
    results = opt.solve(
        model, tee=True, options={"SolFiles": "foo"}, symbolic_solver_labels=True
    )
    0
  • Javier Salmeron
    • First Comment

    Hi Eli, 

    This definitely did the trick.  Thank you very much!

     

    0

Please sign in to leave a comment.