Skip to main content

Pool Solution

Ongoing

Comments

2 comments

  • Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    Hi Mohammad,

    One cause might be that you look at the attribute instead of the Xn attribute for retrieving the solutions. will always contain the best solution irrespective of what you do with SolutionNumber. The values of Xn depend on how you set SolutionNumber.

    If that's not the issue, then do you have a small reproducible piece of code? 

    Kind regards,
    Ronald

    0
  • mohammad hemmati
    • First Comment
    • First Question

    Thank Ronald for your reply.

    My model is large MILP optimization. I already solved it with Gurobi, now I am going to provide some alternative solutions as follows:

    opt = SolverFactory("gurobi_persistent")
    opt.set_instance(model)

    opt.set_gurobi_param("PoolSolutions", 10)
    opt.set_gurobi_param("PoolSearchMode", 2)
    opt.set_gurobi_param("TimeLimit", 14400)
    opt.set_gurobi_param("MIPGap", 0.05)
    # حل مدل
    opt.solve()

    nSolutions = opt.get_model_attr("SolCount")
    print('Number of solutions found: ' + str(nSolutions))
    for e in range(nSolutions):
        opt.set_gurobi_param("SolutionNumber", e)
        print('%g ' % opt.get_model_attr("PoolObjVal"), end='')
    print('')

     

    I can see all 10 objectives, however, I don't know how I see the value of all variables in each solution. I use the following for this purpose:

    for e in range(nSolutions):  
        opt.set_gurobi_param("SolutionNumber", e)  

        cec_value = model.PipeOC.value 

        print(f'Solution {e + 1}: PipeOC = {cec_value}')

     

    But, in the output for all variables (in this example PipeOC) I see the same value in all solutions: 

    Solution 1: PipeOC = 147071.35583463698
    Solution 2: PipeOC = 147071.35583463698
    Solution 3: PipeOC = 147071.35583463698
    Solution 4: PipeOC = 147071.35583463698
    Solution 5: PipeOC = 147071.35583463698
    Solution 6: PipeOC = 147071.35583463698
    Solution 7: PipeOC = 147071.35583463698
    Solution 8: PipeOC = 147071.35583463698
    Solution 9: PipeOC = 147071.35583463698
    Solution 10: PipeOC = 147071.35583463698

     

    Thank you for your help.

    Mohammad

    0

Please sign in to leave a comment.