Skip to main content

Retrieve the objective function value for multiple solutions

Answered

Comments

2 comments

  • Official comment
    Gwyneth Butera
    Gurobi Staff Gurobi Staff

    Hi Ana - Please see Retrieving Solutions in the Reference Manual:

    Sub-optimal solutions can be obtained by first setting the SolutionNumber parameter and then querying the Xn attribute to obtain the solution or the PoolObjVal attribute to obtain the objective value for the corresponding solution.

    Gwyneth

  • Ana Guasque Ortega
    Gurobi-versary
    Investigator
    Conversationalist

    Many thanks! That was the solution. 

    Is there any way of obtaining not-repeated solutions? For example, in a classical multiple Knapsack problem, if I have 2 bins and 4 items, I'll get these solutions:

    Solution 1: 

          Bin0: item0, item2, item3

          Bin1: item 1

    Solution 2: 

          Bin0: item 1

          Bin1: item0, item2, item3

    , and they are equal. I also get other solutions, which are exactly the same, for example Solution3 = Solution 2. Is they any way of avoiding this if I don't know the actual number of solutions or should I evaluate them later?

    Thanks.

    0

Please sign in to leave a comment.