8.5.17. MDOCallback

class MDOCallback

The base class of user defined callback.

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

getSolution

Retrieve value 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

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(const MDOLinExpr &lhs, char sense, double rhs)

Add a new cutting plane to the MIP model.

Parameters
  • const 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(what)

Retieve a double value of solver process specified by what code

Parameters

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(const MDOVar *v, int len)

Retrieve solution values of the current relaxed problem.

Parameters
  • const MDOVar* v – The variables to be retrieve solution values.

  • int len – The number of variables.

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(const MDOVar *v, int len)

Retrieve values of the best solution found so far.

Parameters
  • const MDOVar* v – The variables to be retrieve solution values.

  • int len – the number of variables.

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(const MDOVar *var, const double *val, int len)

Provide a new feasible solution for a MIP model.

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

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

  • int len – The number of variables to provide solution.

int useSolution(double *obj)

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

Parameters

double* obj – [out] The objective value of submitted solution.

Returns

  • 0: Successful submission.

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

  • 2: Submission is correct but not being accepted.