BlockIPPlatform
 All Classes Files Functions Variables
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OsiSolver Class Reference

Class to solve problems through Osi. More...

#include <OsiSolver.h>

Inheritance diagram for OsiSolver:
Inheritance graph
[legend]

Public Member Functions

 OsiSolver ()
 Constructor.
 
 ~OsiSolver ()
 Destructor.
 
void setMaxTime (double time)
 Set maximum time allowed to solve the problem.
 
double getMaxTime ()
 Get maximum time allowed to solve the problem.
 
void setNumThreads (int numThreads)
 Set the maximum number of threads that the solver can use to solve the problem.
 
int getNumThreads ()
 Get the maximum number of threads that the solver can use to solve the problem.
 
void setFirstFeasible (bool stopAtFirstFeasible)
 Set if the execution must be stopped at first feasible solution.
 
bool getFirstFeasible ()
 Get if the execution must be stopped at first feasible solution.
 
void setLogFileName (char *filename)
 Set the name of the log file.
 
const char * getLogFileName ()
 Get the name of the log file.
 
OsiSolverInterface * getSolverInterface ()
 Get solver interface.
 
virtual void readMps (const char *filename)
 Load a problem from a mps file.
 
void loadProblem (int numRows, int numColumns, int nz, double obj[], double qobj[], double lb[], double ub[], double lhs[], double rhs[], int begRows[], int indCols[], double values[], bool copy_vectors=true)
 Load a problem.
 
virtual STATUS solve ()
 Solve the problem loaded.
 
double getObjValue ()
 Get the objective function value.
 
virtual const double * getSolution ()
 Get the solution.
 
int getNumVars ()
 Get the number of variables.
 
virtual const string * getVarNames ()
 Get the name of variables.
 

Protected Member Functions

void freeMemory ()
 Free all allocated memory.
 
virtual void loadQuadraticObj (double qobj[])
 Load the quadratic objective function cost.
 

Protected Attributes

double maxTime
 Maximum time allowed to solve the problem.
 
bool stopAtFirstFeasible
 True if the execution must be stopped at first feasible solution.
 
bool solved
 True if at least a initial solve has been done.
 
int numThreads
 Number of threads to use.
 
OsiSolverInterface * si
 Osi environment.
 
CoinMessageHandler * cmh
 To redirect the output.
 
FILE * f
 Output file.
 
char * filename
 Name of file.
 
double fobj
 Objective function value.
 

Detailed Description

Class to solve problems through Osi.

Note
Virtual class, not must be instantiated

Member Function Documentation

bool OsiSolver::getFirstFeasible ( )
inline

Get if the execution must be stopped at first feasible solution.

Note
This option only will be used when the problem loaded contains binary variables
Returns
If the execution must be stopped at first feasible solution
double OsiSolver::getMaxTime ( )
inline

Get maximum time allowed to solve the problem.

Returns
Maximum time allowed to solve the problem
int OsiSolver::getNumThreads ( )
inline

Get the maximum number of threads that the solver can use to solve the problem.

Returns
Maximum number of threads that the solver can use to solve the problem, -1 if unlimited
int OsiSolver::getNumVars ( )
inline

Get the number of variables.

Returns
Number of variables
const double * OsiSolver::getSolution ( )
virtual

Get the solution.

Returns
Solution

Reimplemented in OsiXpress.

OsiSolverInterface * OsiSolver::getSolverInterface ( )
inline

Get solver interface.

Returns
Solver interface
const string * OsiSolver::getVarNames ( )
virtual

Get the name of variables.

Returns
Name of variables

Reimplemented in OsiXpress, and OsiCplex.

void OsiSolver::loadProblem ( int  numRows,
int  numColumns,
int  nz,
double  obj[],
double  qobj[],
double  lb[],
double  ub[],
double  lhs[],
double  rhs[],
int  begRows[],
int  indCols[],
double  values[],
bool  copy_vectors = true 
)

Load a problem.

Parameters
numRowsNumber of rows
numColumnsNumber of columns
nzNumber of non-zero elements in the sparse matrix
objObjective function values, if NULL, all variables have 0 objective coefficient
qobjQuadratic coefficients of the separable quadratic objective, if NULL, all variables have 0 quadratic coefficients
lbLower bound of variables
ubUpper bound of variables, if NULL, all columns have upper bound infinity.
lhsLower bound of restrictions, if NULL, all columns have lower bound 0
rhsUpper bound of restrictions, if NULL, all rows have upper bound infinity
begRowsIndex to the begining of each row, if NULL, all rows have lower bound -infinity
indColsIndex of each column
valuesValue of each non-zero element
copy_vectorsif false the vectors will be used freed with delete[] after optimization TODO
void OsiSolver::loadQuadraticObj ( double  qobj[])
protectedvirtual

Load the quadratic objective function cost.

Parameters
qobjQuadratic coefficients of the separable quadratic objective

Reimplemented in OsiXpress, OsiCplex, and OsiClp.

void OsiSolver::setFirstFeasible ( bool  stopAtFirstFeasible)
inline

Set if the execution must be stopped at first feasible solution.

Note
This option only will be used when the problem loaded contains binary variables

The documentation for this class was generated from the following files: