Managing the Solution Repository

The solution repository

The GMP library maintains a solution repository for every generated mathematical program instance. You can use this repository, for instance, to store

  • a number of starting solutions for a NLP problem to be solved successively,

  • a number of incumbent solutions as reported by a MIP solver, or

  • let a solver store multiple solutions.

If you are using solver sessions to initiate a solver, you must explicitly transfer the initial, intermediate or final solutions between the model, the solution repository and the solver session. As discussed in Managing Generated Mathematical Program Instances, the function GMP::Instance::Solve performs these necessary solution transfer steps for you, and uses the fixed solution number 1 for all of its communication.

Some solvers are capable of finding multiple solutions instead of at most one. Examples of such solvers are BARON, COPT, CPLEX and Gurobi. When such a solver finds multiple solutions, these solutions are stored in the solution repository from number 1 on upwards. The control mechanism to let solvers find multiple solutions is solver specific:

  • BARON 21: For more information see the Help file for option Number of best solutions in option category Specific solvers - BARON 21 - General.

  • COPT 6.0: For more information see the Help file for option Pool size in option category Specific solvers - COPT 6.0 - MIP.

  • CPLEX 22.1: For more information see the Help file for option Do populate in option category Specific solvers - CPLEX 22.1 - MIP solution pool.

  • Gurobi 10.0: For more information see the Help file for option Pool search mode in option category Specific solvers - Gurobi 10.0 - Solution pool.

Solution repository functions

The procedures and functions of the GMP::Solution namespace are listed in this table. Through these functions you can

  • transfer a solution between the solution repository on the one side and the symbolic model or the solver on the other side,

  • obtain and set solution properties of a solution in the repository, or

  • perform a feasibility check on a solution in the repository.

Table 40 : GMP::Solution functions and procedures

Copy(GMP, fromSol, toSol)

Move(GMP, fromSol, toSol)

Delete(GMP, solNo)

DeleteAll(GMP)

GetSolutionsSet(GMP)\(\to\)Integers

Count(GMP)

RetrieveFromModel(GMP, SolNr)

SendToModel(GMP, SolNr[, merge][, evalInline])

SendToModelSelection(GMP, SolNr, Identifiers, Suffices[, merge][, evalInline])

RetrieveFromSolverSession(solverSession, SolNr)

SendToSolverSession(solverSession, SolNr)

GetObjective(GMP, SolNr)

GetBestBound(GMP, SolNr)

GetProgramStatus(GMP, SolNr)\(\to\)AllSolutionStates

GetSolverStatus(GMP, SolNr)\(\to\)AllSolutionStates

GetIterationsUsed(GMP, SolNr)

GetMemoryUsed(GMP, SolNr)

GetTimeUsed(GMP, SolNr)

SetObjective(GMP, SolNr, value)

SetProgramStatus(GMP, SolNr, PrStatus)

SetSolverStatus(GMP, SolNr, PrStatus)

SetIterationCount(GMP, SolNr, IterCnt)

GetColumnValue(GMP, SolNr, column[, valueType])

SetColumnValue(GMP, SolNr, column, value[, valueType])

GetRowValue(GMP, SolNr, row[, valueType])

SetRowValue(GMP, SolNr, row, value[, valueType])

Check(GMP, SolNr, NumInf, SumInf, MaxInf[, skipObj][, feasTol][, checkColumns])

IsInteger(GMP, SolNr)

IsPrimalDegenerated(GMP, SolNr)

IsDualDegenerated(GMP, SolNr)

SetMIPStartFlag(GMP, SolNr, flag[, effortLevel])

GetFirstOrderDerivative(GMP, SolNr, row, column)

ConstraintListing(GMP, SolNr, name)

Solution contents

Each solution in the repository is represented by a solution vector containing all relevant solution data, such as

  • solution status,

  • level values,

  • basis information,

  • marginals, and

  • other relevant requested sensitivity information.

Solution numbering

Each generated mathematical program instance has its own associated solution repository. Each solution in the repository is represented by an integer solution number. Through the function GMP::Solution::GetSolutionsSet you can retrieve a subset of the predefined set Integers containing the set of all solution numbers that are currently in use for the given mathematical program instance.

Solution transfer to the model

Through the functions

you can (re-)initialize a solution with the values currently contained in the symbolic model, and vice versa. The function SendToModelSelection allows you to only initialize a part of the model identifiers and suffices with a solution of from the solution repository.

Solution transfer to a solver session

Through the functions

you can set a solution in the repository equal to a solution reported by a given solver session, or initialize the (initial) solution of a solver session with a solution stored in the repository. Notice that these functions do not have a GMP argument. Because each solver session is uniquely associated with a single mathematical program instance, AIMMS is able to determine the correct solution repository.

Computing first order derivatives

Using the function GMP::Solution::GetFirstOrderDerivative, you can compute, for the given solution, first order derivative of a particular row in a mathematical program with respect to a given variable. You can use such a function, for instance, to implement a sequential linear programming approach for nonlinear programs, as outlined in Sequential Linear Programming.