5.2.9. MILP Solution Pool

In the process of solving mixed-integer programming problems, multiple feasible solutions may be found. MindOpt provides a Solution Pool which enables users to know the actual number of solutions found during the solving process, as well as helps users retrieve these solutions.

5.2.9.1. The Size of the Solution Pool

You can prompt MindOpt to strive to find a specified number of feasible solutions during the solving process by setting the MIP/SolutionPoolSize parameter to a desired value. When the problem-solving is complete, you can use the attribute SolCount to obtain the actual number of feasible solutions that MindOpt has found.

5.2.9.2. Retrieving the K-th Solution

In the solution pool, solutions are ordered from best to worst. After the problem is solved, you can obtain the k-th suboptimal solution as follows: First, set the value of the parameter SolutionNumber to k, and then use the attribute Xn to get the k-th solution. Note that you should take care not to set SolutionNumber to a value that exceeds SolCount. Here is an example in Python:

from mindoptpy import *

model = read('problem.mps')
model.setParam(MDO.Param.MIP_SolutionPoolSize, 10)
model.optimize()

firstVar = model.getVars()[0]

if (model.status == MDO.Status.OPTIMAL):
    print("Best solution for first variable: {}".format(firstVar.X))

if (model.status in (MDO.Status.OPTIMAL, MDO.Status.SUB_OPTIMAL)):
    print("Found {} suboptimal solution(s)".format(model.SolCount))

for i in range(model.SolCount):
    model.setParam(MDO.Param.SolutionNumber, i)
    print("  The kth (k = {}) suboptimal solution for first variable is {}".format(i, firstVar.Xn))