Cbc  2.8.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Cbc_C_Interface.h File Reference
#include "Coin_C_defines.h"
#include <stddef.h>
+ Include dependency graph for Cbc_C_Interface.h:

Go to the source code of this file.

Functions

Constructors and destructor

This is a "C" interface to Cbc.

The user does not need to know structure of Cbc_Model.

COINLIBAPI Cbc_Model *COINLINKAGE Cbc_newModel (void)
 Default Cbc_Model constructor. More...
 
COINLIBAPI void COINLINKAGE Cbc_deleteModel (Cbc_Model *model)
 Cbc_Model Destructor. More...
 
COINLIBAPI const char *COINLINKAGE Cbc_getVersion (void)
 Current version of Cbc. More...
 
Getting and setting model data

Note that problem access and modification methods, such as getColLower and setColLower, are not valid after calling Cbc_solve().

Therefore it is not recommended to reuse a Cbc_Model object for multiple solves. A workaround is to call Cbc_clone() before solving.

COINLIBAPI void COINLINKAGE Cbc_loadProblem (Cbc_Model *model, const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
 Loads a problem (the constraints on the rows are given by lower and upper bounds). More...
 
COINLIBAPI int COINLINKAGE Cbc_readMps (Cbc_Model *model, const char *filename)
 Read an mps file from the given filename. More...
 
COINLIBAPI void COINLINKAGE Cbc_writeMps (Cbc_Model *model, const char *filename)
 Write an mps file from the given filename. More...
 
COINLIBAPI void COINLINKAGE Cbc_setInitialSolution (Cbc_Model *model, const double *sol)
 Provide an initial feasible solution to accelerate branch-and-bound Note that feasibility of the solution is not verified. More...
 
COINLIBAPI void COINLINKAGE Cbc_problemName (Cbc_Model *model, int maxNumberCharacters, char *array)
 Fills in array with problem name. More...
 
COINLIBAPI int COINLINKAGE Cbc_setProblemName (Cbc_Model *model, const char *array)
 Sets problem name. More...
 
COINLIBAPI int COINLINKAGE Cbc_getNumElements (Cbc_Model *model)
 Number of nonzero elements in constraint matrix. More...
 
COINLIBAPI const CoinBigIndex
*COINLINKAGE 
Cbc_getVectorStarts (Cbc_Model *model)
 "Column start" vector of constraint matrix. More...
 
COINLIBAPI const int *COINLINKAGE Cbc_getIndices (Cbc_Model *model)
 "Row index" vector of constraint matrix More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getElements (Cbc_Model *model)
 Coefficient vector of constraint matrix. More...
 
COINLIBAPI size_t COINLINKAGE Cbc_maxNameLength (Cbc_Model *model)
 Maximum lenght of a row or column name. More...
 
COINLIBAPI void COINLINKAGE Cbc_getRowName (Cbc_Model *model, int iRow, char *name, size_t maxLength)
 Fill in first maxLength bytes of name array with a row name. More...
 
COINLIBAPI void COINLINKAGE Cbc_getColName (Cbc_Model *model, int iColumn, char *name, size_t maxLength)
 Fill in first maxLength bytes of name array with a column name. More...
 
COINLIBAPI void COINLINKAGE Cbc_setColName (Cbc_Model *model, int iColumn, const char *name)
 Set the name of a column. More...
 
COINLIBAPI void COINLINKAGE Cbc_setRowName (Cbc_Model *model, int iRow, const char *name)
 Set the name of a row. More...
 
COINLIBAPI int COINLINKAGE Cbc_getNumRows (Cbc_Model *model)
 Number of constraints in the model. More...
 
COINLIBAPI int COINLINKAGE Cbc_getNumCols (Cbc_Model *model)
 Number of variables in the model. More...
 
COINLIBAPI void COINLINKAGE Cbc_setObjSense (Cbc_Model *model, double sense)
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) More...
 
COINLIBAPI double COINLINKAGE Cbc_getObjSense (Cbc_Model *model)
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore) More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getRowLower (Cbc_Model *model)
 Constraint lower bounds. More...
 
COINLIBAPI void COINLINKAGE Cbc_setRowLower (Cbc_Model *model, int index, double value)
 Set the lower bound of a single constraint. More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getRowUpper (Cbc_Model *model)
 Constraint upper bounds. More...
 
COINLIBAPI void COINLINKAGE Cbc_setRowUpper (Cbc_Model *model, int index, double value)
 Set the upper bound of a single constraint. More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getObjCoefficients (Cbc_Model *model)
 Objective vector. More...
 
COINLIBAPI void COINLINKAGE Cbc_setObjCoeff (Cbc_Model *model, int index, double value)
 Set the objective coefficient of a single variable. More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getColLower (Cbc_Model *model)
 Variable lower bounds. More...
 
COINLIBAPI void COINLINKAGE Cbc_setColLower (Cbc_Model *model, int index, double value)
 Set the lower bound of a single variable. More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getColUpper (Cbc_Model *model)
 Variable upper bounds. More...
 
COINLIBAPI void COINLINKAGE Cbc_setColUpper (Cbc_Model *model, int index, double value)
 Set the upper bound of a single variable. More...
 
COINLIBAPI int COINLINKAGE Cbc_isInteger (Cbc_Model *model, int i)
 Determine whether the ith variable is integer restricted. More...
 
COINLIBAPI void COINLINKAGE Cbc_setContinuous (Cbc_Model *model, int iColumn)
 Set this variable to be continuous. More...
 
COINLIBAPI void COINLINKAGE Cbc_setInteger (Cbc_Model *model, int iColumn)
 Set this variable to be integer. More...
 
COINLIBAPI void COINLINKAGE Cbc_addSOS (Cbc_Model *model, int numRows, const int *rowStarts, const int *colIndices, const double *weights, const int type)
 Add SOS constraints to the model using row-order matrix Unable to confirm that this function is working. More...
 
COINLIBAPI void COINLINKAGE Cbc_printModel (Cbc_Model *model, const char *argPrefix)
 Print the model. More...
 
COINLIBAPI Cbc_Model *COINLINKAGE Cbc_clone (Cbc_Model *model)
 Return a copy of this model. More...
 
Solver parameters
COINLIBAPI void COINLINKAGE Cbc_setParameter (Cbc_Model *model, const char *name, const char *value)
 Set parameter "name" to value "value". More...
 
Message handling. Call backs are handled by ONE function
COINLIBAPI void COINLINKAGE Cbc_registerCallBack (Cbc_Model *model, cbc_callback userCallBack)
 Pass in Callback function. More...
 
COINLIBAPI void COINLINKAGE Cbc_clearCallBack (Cbc_Model *model)
 Unset Callback function. More...
 
Solving the model
COINLIBAPI int COINLINKAGE Cbc_solve (Cbc_Model *model)
 
Accessing the solution and solution status
COINLIBAPI double COINLINKAGE Cbc_sumPrimalInfeasibilities (Cbc_Model *model)
 Sum of primal infeasibilities. More...
 
COINLIBAPI int COINLINKAGE Cbc_numberPrimalInfeasibilities (Cbc_Model *model)
 Number of primal infeasibilities. More...
 
COINLIBAPI void COINLINKAGE Cbc_checkSolution (Cbc_Model *model)
 Just check solution (for external use) - sets sum of infeasibilities etc. More...
 
COINLIBAPI int COINLINKAGE Cbc_getIterationCount (Cbc_Model *model)
 Number of iterations. More...
 
COINLIBAPI int COINLINKAGE Cbc_isAbandoned (Cbc_Model *model)
 Are there a numerical difficulties? More...
 
COINLIBAPI int COINLINKAGE Cbc_isProvenOptimal (Cbc_Model *model)
 Is optimality proven? More...
 
COINLIBAPI int COINLINKAGE Cbc_isProvenInfeasible (Cbc_Model *model)
 Is infeasiblity proven (or none better than cutoff)? More...
 
COINLIBAPI int COINLINKAGE Cbc_isContinuousUnbounded (Cbc_Model *model)
 Was continuous solution unbounded? More...
 
COINLIBAPI int COINLINKAGE Cbc_isNodeLimitReached (Cbc_Model *model)
 Node limit reached? More...
 
COINLIBAPI int COINLINKAGE Cbc_isSecondsLimitReached (Cbc_Model *model)
 Time limit reached? More...
 
COINLIBAPI int COINLINKAGE Cbc_isSolutionLimitReached (Cbc_Model *model)
 Solution limit reached? More...
 
COINLIBAPI int COINLINKAGE Cbc_isInitialSolveAbandoned (Cbc_Model *model)
 Are there numerical difficulties (for initialSolve) ? More...
 
COINLIBAPI int COINLINKAGE Cbc_isInitialSolveProvenOptimal (Cbc_Model *model)
 Is optimality proven (for initialSolve) ? More...
 
COINLIBAPI int COINLINKAGE Cbc_isInitialSolveProvenPrimalInfeasible (Cbc_Model *model)
 Is primal infeasiblity proven (for initialSolve) ? More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getRowActivity (Cbc_Model *model)
 "row" solution This is the vector A*x, where A is the constraint matrix and x is the current solution. More...
 
COINLIBAPI const double
*COINLINKAGE 
Cbc_getColSolution (Cbc_Model *model)
 Best feasible solution vector. More...
 
COINLIBAPI double COINLINKAGE Cbc_getObjValue (Cbc_Model *model)
 Objective value of best feasible solution. More...
 
COINLIBAPI double COINLINKAGE Cbc_getBestPossibleObjValue (Cbc_Model *model)
 Best known bound on the optimal objective value. More...
 
COINLIBAPI int COINLINKAGE Cbc_getNodeCount (Cbc_Model *model)
 Number of nodes explored in B&B tree. More...
 
COINLIBAPI void COINLINKAGE Cbc_printSolution (Cbc_Model *model)
 Print the solution. More...
 
COINLIBAPI int COINLINKAGE Cbc_status (Cbc_Model *model)
 Final status of problem Some of these can be found out by is...... More...
 
COINLIBAPI int COINLINKAGE Cbc_secondaryStatus (Cbc_Model *model)
 Secondary status of problem -1 unset (status_ will also be -1) 0 search completed with solution 1 linear relaxation not feasible (or worse than cutoff) 2 stopped on gap 3 stopped on nodes 4 stopped on time 5 stopped on user event 6 stopped on solutions 7 linear relaxation unbounded 8 stopped on iteration limit. More...
 

Function Documentation

COINLIBAPI Cbc_Model* COINLINKAGE Cbc_newModel ( void  )

Default Cbc_Model constructor.

COINLIBAPI void COINLINKAGE Cbc_deleteModel ( Cbc_Model *  model)

Cbc_Model Destructor.

COINLIBAPI const char* COINLINKAGE Cbc_getVersion ( void  )

Current version of Cbc.

COINLIBAPI void COINLINKAGE Cbc_loadProblem ( Cbc_Model *  model,
const int  numcols,
const int  numrows,
const CoinBigIndex *  start,
const int *  index,
const double *  value,
const double *  collb,
const double *  colub,
const double *  obj,
const double *  rowlb,
const double *  rowub 
)

Loads a problem (the constraints on the rows are given by lower and upper bounds).

If a pointer is NULL then the following values are the default:

  • colub: all columns have upper bound infinity
  • collb: all columns have lower bound 0
  • rowub: all rows have upper bound infinity
  • rowlb: all rows have lower bound -infinity
  • obj: all variables have 0 objective coefficient

The constraint matrix is given in standard compressed sparse column (without gaps).

  • start[i] stores the starting index of the ith column
  • index[k] stores the row index of the kth nonzero element
  • value[k] stores the coefficient of the kth nonzero element
COINLIBAPI int COINLINKAGE Cbc_readMps ( Cbc_Model *  model,
const char *  filename 
)

Read an mps file from the given filename.

COINLIBAPI void COINLINKAGE Cbc_writeMps ( Cbc_Model *  model,
const char *  filename 
)

Write an mps file from the given filename.

COINLIBAPI void COINLINKAGE Cbc_setInitialSolution ( Cbc_Model *  model,
const double *  sol 
)

Provide an initial feasible solution to accelerate branch-and-bound Note that feasibility of the solution is not verified.

COINLIBAPI void COINLINKAGE Cbc_problemName ( Cbc_Model *  model,
int  maxNumberCharacters,
char *  array 
)

Fills in array with problem name.

COINLIBAPI int COINLINKAGE Cbc_setProblemName ( Cbc_Model *  model,
const char *  array 
)

Sets problem name.

array must be a null-terminated string.

COINLIBAPI int COINLINKAGE Cbc_getNumElements ( Cbc_Model *  model)

Number of nonzero elements in constraint matrix.

COINLIBAPI const CoinBigIndex* COINLINKAGE Cbc_getVectorStarts ( Cbc_Model *  model)

"Column start" vector of constraint matrix.

Same format as Cbc_loadProblem()

COINLIBAPI const int* COINLINKAGE Cbc_getIndices ( Cbc_Model *  model)

"Row index" vector of constraint matrix

COINLIBAPI const double* COINLINKAGE Cbc_getElements ( Cbc_Model *  model)

Coefficient vector of constraint matrix.

COINLIBAPI size_t COINLINKAGE Cbc_maxNameLength ( Cbc_Model *  model)

Maximum lenght of a row or column name.

COINLIBAPI void COINLINKAGE Cbc_getRowName ( Cbc_Model *  model,
int  iRow,
char *  name,
size_t  maxLength 
)

Fill in first maxLength bytes of name array with a row name.

COINLIBAPI void COINLINKAGE Cbc_getColName ( Cbc_Model *  model,
int  iColumn,
char *  name,
size_t  maxLength 
)

Fill in first maxLength bytes of name array with a column name.

COINLIBAPI void COINLINKAGE Cbc_setColName ( Cbc_Model *  model,
int  iColumn,
const char *  name 
)

Set the name of a column.

COINLIBAPI void COINLINKAGE Cbc_setRowName ( Cbc_Model *  model,
int  iRow,
const char *  name 
)

Set the name of a row.

COINLIBAPI int COINLINKAGE Cbc_getNumRows ( Cbc_Model *  model)

Number of constraints in the model.

COINLIBAPI int COINLINKAGE Cbc_getNumCols ( Cbc_Model *  model)

Number of variables in the model.

COINLIBAPI void COINLINKAGE Cbc_setObjSense ( Cbc_Model *  model,
double  sense 
)

Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore)

COINLIBAPI double COINLINKAGE Cbc_getObjSense ( Cbc_Model *  model)

Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore)

COINLIBAPI const double* COINLINKAGE Cbc_getRowLower ( Cbc_Model *  model)

Constraint lower bounds.

COINLIBAPI void COINLINKAGE Cbc_setRowLower ( Cbc_Model *  model,
int  index,
double  value 
)

Set the lower bound of a single constraint.

COINLIBAPI const double* COINLINKAGE Cbc_getRowUpper ( Cbc_Model *  model)

Constraint upper bounds.

COINLIBAPI void COINLINKAGE Cbc_setRowUpper ( Cbc_Model *  model,
int  index,
double  value 
)

Set the upper bound of a single constraint.

COINLIBAPI const double* COINLINKAGE Cbc_getObjCoefficients ( Cbc_Model *  model)

Objective vector.

COINLIBAPI void COINLINKAGE Cbc_setObjCoeff ( Cbc_Model *  model,
int  index,
double  value 
)

Set the objective coefficient of a single variable.

COINLIBAPI const double* COINLINKAGE Cbc_getColLower ( Cbc_Model *  model)

Variable lower bounds.

COINLIBAPI void COINLINKAGE Cbc_setColLower ( Cbc_Model *  model,
int  index,
double  value 
)

Set the lower bound of a single variable.

COINLIBAPI const double* COINLINKAGE Cbc_getColUpper ( Cbc_Model *  model)

Variable upper bounds.

COINLIBAPI void COINLINKAGE Cbc_setColUpper ( Cbc_Model *  model,
int  index,
double  value 
)

Set the upper bound of a single variable.

COINLIBAPI int COINLINKAGE Cbc_isInteger ( Cbc_Model *  model,
int  i 
)

Determine whether the ith variable is integer restricted.

COINLIBAPI void COINLINKAGE Cbc_setContinuous ( Cbc_Model *  model,
int  iColumn 
)

Set this variable to be continuous.

COINLIBAPI void COINLINKAGE Cbc_setInteger ( Cbc_Model *  model,
int  iColumn 
)

Set this variable to be integer.

COINLIBAPI void COINLINKAGE Cbc_addSOS ( Cbc_Model *  model,
int  numRows,
const int *  rowStarts,
const int *  colIndices,
const double *  weights,
const int  type 
)

Add SOS constraints to the model using row-order matrix Unable to confirm that this function is working.

COINLIBAPI void COINLINKAGE Cbc_printModel ( Cbc_Model *  model,
const char *  argPrefix 
)

Print the model.

COINLIBAPI Cbc_Model* COINLINKAGE Cbc_clone ( Cbc_Model *  model)

Return a copy of this model.

COINLIBAPI void COINLINKAGE Cbc_setParameter ( Cbc_Model *  model,
const char *  name,
const char *  value 
)

Set parameter "name" to value "value".

Note that this translates directly to using "-name value" as a command-line argument to Cbc.

COINLIBAPI void COINLINKAGE Cbc_registerCallBack ( Cbc_Model *  model,
cbc_callback  userCallBack 
)

Pass in Callback function.

Message numbers up to 1000000 are Clp, Coin ones have 1000000 added

COINLIBAPI void COINLINKAGE Cbc_clearCallBack ( Cbc_Model *  model)

Unset Callback function.

COINLIBAPI int COINLINKAGE Cbc_solve ( Cbc_Model *  model)
COINLIBAPI double COINLINKAGE Cbc_sumPrimalInfeasibilities ( Cbc_Model *  model)

Sum of primal infeasibilities.

COINLIBAPI int COINLINKAGE Cbc_numberPrimalInfeasibilities ( Cbc_Model *  model)

Number of primal infeasibilities.

COINLIBAPI void COINLINKAGE Cbc_checkSolution ( Cbc_Model *  model)

Just check solution (for external use) - sets sum of infeasibilities etc.

COINLIBAPI int COINLINKAGE Cbc_getIterationCount ( Cbc_Model *  model)

Number of iterations.

COINLIBAPI int COINLINKAGE Cbc_isAbandoned ( Cbc_Model *  model)

Are there a numerical difficulties?

COINLIBAPI int COINLINKAGE Cbc_isProvenOptimal ( Cbc_Model *  model)

Is optimality proven?

COINLIBAPI int COINLINKAGE Cbc_isProvenInfeasible ( Cbc_Model *  model)

Is infeasiblity proven (or none better than cutoff)?

COINLIBAPI int COINLINKAGE Cbc_isContinuousUnbounded ( Cbc_Model *  model)

Was continuous solution unbounded?

COINLIBAPI int COINLINKAGE Cbc_isNodeLimitReached ( Cbc_Model *  model)

Node limit reached?

COINLIBAPI int COINLINKAGE Cbc_isSecondsLimitReached ( Cbc_Model *  model)

Time limit reached?

COINLIBAPI int COINLINKAGE Cbc_isSolutionLimitReached ( Cbc_Model *  model)

Solution limit reached?

COINLIBAPI int COINLINKAGE Cbc_isInitialSolveAbandoned ( Cbc_Model *  model)

Are there numerical difficulties (for initialSolve) ?

COINLIBAPI int COINLINKAGE Cbc_isInitialSolveProvenOptimal ( Cbc_Model *  model)

Is optimality proven (for initialSolve) ?

COINLIBAPI int COINLINKAGE Cbc_isInitialSolveProvenPrimalInfeasible ( Cbc_Model *  model)

Is primal infeasiblity proven (for initialSolve) ?

COINLIBAPI const double* COINLINKAGE Cbc_getRowActivity ( Cbc_Model *  model)

"row" solution This is the vector A*x, where A is the constraint matrix and x is the current solution.

COINLIBAPI const double* COINLINKAGE Cbc_getColSolution ( Cbc_Model *  model)

Best feasible solution vector.

COINLIBAPI double COINLINKAGE Cbc_getObjValue ( Cbc_Model *  model)

Objective value of best feasible solution.

COINLIBAPI double COINLINKAGE Cbc_getBestPossibleObjValue ( Cbc_Model *  model)

Best known bound on the optimal objective value.

COINLIBAPI int COINLINKAGE Cbc_getNodeCount ( Cbc_Model *  model)

Number of nodes explored in B&B tree.

COINLIBAPI void COINLINKAGE Cbc_printSolution ( Cbc_Model *  model)

Print the solution.

COINLIBAPI int COINLINKAGE Cbc_status ( Cbc_Model *  model)

Final status of problem Some of these can be found out by is......

functions -1 before branchAndBound 0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found (or check value of best solution) 1 stopped - on maxnodes, maxsols, maxtime 2 difficulties so run was abandoned (5 event user programmed event occurred)

COINLIBAPI int COINLINKAGE Cbc_secondaryStatus ( Cbc_Model *  model)

Secondary status of problem -1 unset (status_ will also be -1) 0 search completed with solution 1 linear relaxation not feasible (or worse than cutoff) 2 stopped on gap 3 stopped on nodes 4 stopped on time 5 stopped on user event 6 stopped on solutions 7 linear relaxation unbounded 8 stopped on iteration limit.