8.7.16. MDOCallback

MDOCallback

A base class for user to define MIP callback.

Properties

Where

The where code

Where

The where code

Methods

Abort

Send a stop request to solver in a MIP callback function

AddBranch

Indicate a new branching by specifying a variable and a split point between the lower and upper bounds of this variable

AddCut

Add a new cutting plane to the MIP model

GetDoubleInfo

Retieve a double value of solver process specified by what code

GetIntInfo

Retrieve an integer value of solver process specified by what code

GetNodeRel

Retrieve solution value of the current relaxed problem

GetNodeRel

Retrieve solution values of the current relaxed problem

GetNodeRel

Retrieve solution values of the current relaxed problem

GetSolution

Retrieve value of the best solution found so far

GetSolution

Retrieve values of the best solution found so far

GetSolution

Retrieve values of the best solution found so far

SetSolution

Provide a new feasible solution for a MIP model

SetSolution

Provide a new feasible solution for a MIP model

UseSolution

If you have already provided solution by SetSolution, you can optionally call this method to immediately submit solution to MIP solver

void Abort()

Send a stop request to solver in a MIP callback function. After solver terminated, an error code ABORT_CTRL_C will be returned from MDOModel.Optimize .

int AddBranch(MDOVar var, double value, int way)

Indicate a new branching by specifying a variable and a split point between the lower and upper bounds of this variable.

Parameters
  • MDOVar var – The variable.

  • double value – The split point. It should be between the lower and upper bounds of variable.

  • int way

    The branch to consider first. Valid options are:

    • <0: the down-way branch is considered first.

    • >0: the up-way branch is considered first.

Returns

A submission status:

  • 0: Successful submission.

  • 1: Submission is valid but incorrect (infeasible, etc)

  • 2: Submission is correct but not being accepted.

int AddCut(MDOLinExpr lhs, char sense, double rhs)

Add a new cutting plane to the MIP model.

Parameters
  • MDOLinExpr lhs – Left-hand-side value for new cutting plane.

  • char sense – Sense for new cutting plane.

  • double rhs – Right-hand-side value for new cutting plane.

Returns

A submission status:

  • 0: Successful submission.

  • 1: Submission is valid but incorrect (infeasible, etc)

  • 2: Submission is correct but not being accepted.

double GetDoubleInfo(int what)

Retieve a double value of solver process specified by what code

Parameters

int what – The data code to be retrieved.

Returns

The value to be retrieved.

int GetIntInfo(what)

Retrieve an integer value of solver process specified by what code

Parameters

what – The data code to be retrieved.

Returns

The value to be retrieved.

double GetNodeRel(MDOVar v)

Retrieve solution value of the current relaxed problem.

Parameters

MDOVar v – The variable to be retrieve solution value.

Returns

The solution value of specified variable.

double[] GetNodeRel(MDOVar[] v)

Retrieve solution values of the current relaxed problem.

Parameters

MDOVar[] v – The variables to be retrieve solution values.

Returns

The solution values of specified variables.

double[,] GetNodeRel(MDOVar[,] v)

Retrieve solution values of the current relaxed problem.

Parameters

MDOVar[,] v – The variables to be retrieve solution values.

Returns

The solution values of specified variables.

double GetSolution(MDOVar v)

Retrieve value of the best solution found so far.

Parameters

MDOVar v – The variable to be retrieved solution value.

Returns

The solution value of specified variable.

double[] GetSolution(MDOVar[] v)

Retrieve values of the best solution found so far.

Parameters

MDOVar[] v – The variables to be retrieve solution values.

Returns

The solution values of specified variables.

double[,] GetSolution(MDOVar[,] v)

Retrieve values of the best solution found so far.

Parameters

MDOVar[,] v – The variables to be retrieve solution values.

Returns

The solution values of specified variables.

void SetSolution(MDOVar var, double val)

Provide a new feasible solution for a MIP model.

Parameters
  • MDOVar var – Indicate variable to be provide solution.

  • double val – The solution value to be provided.

void SetSolution(MDOVar[] var, double[] val)

Provide a new feasible solution for a MIP model.

Parameters
  • MDOVar[] var – A array of Var object to indicate variables to be provide solution.

  • double[] val – A array of double value to indicate new feasible solution to be provided.

MDO.Result<double> UseSolution()

If you have already provided solution by SetSolution , you can optionally call this method to immediately submit solution to MIP solver.

Returns

The submission result. It consists of 2 fields: code and objective value. Code can be:

  • 0: Successful submission.

  • 1: Submission is valid but incorrect (infeasible, etc)

  • 2: Submission is correct but not being accepted.