Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | List of all members
LindoSolver Class Reference

the LindoSolver class solves problems using Lindo. More...

#include <OSLindoSolver.h>

Inheritance diagram for LindoSolver:
Inheritance graph
[legend]
Collaboration diagram for LindoSolver:
Collaboration graph
[legend]

Public Member Functions

 LindoSolver ()
 the LindoSolver class constructor More...
 
 ~LindoSolver ()
 the LindoSolver class destructor More...
 
virtual void solve ()
 solve results in an instance being read into the Lindo data structures and optimized More...
 
virtual void buildSolverInstance () throw (ErrorClass)
 buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverInstance method – the solver instance is the instance the individual solver sees in its API More...
 
virtual void setSolverOptions () throw (ErrorClass)
 The implementation of the virtual functions. More...
 
bool optimize ()
 invoke the Lindo API solver More...
 
bool processVariables ()
 read the OSiL instance variables and put these into the LINDO API variables More...
 
bool processConstraints ()
 read the OSiL instance constraints and put these into the LINDO API constraints More...
 
bool generateLindoModel ()
 create the LINDO environment and read the problem into the internal LINDO data structures More...
 
bool addSlackVars ()
 LINDO does not handle constraints with upper and lower bounds this method is part of kludge where we add a new variable to handle the bounds. More...
 
bool processQuadraticTerms ()
 read the quadratic terms in the model More...
 
bool processNonlinearExpressions ()
 read the nonlinear terms in the model More...
 
void dataEchoCheck ()
 use this for debugging, print out the instance that the solver thinks it has and compare this with the OSiL file More...
 
- Public Member Functions inherited from DefaultSolver
 DefaultSolver ()
 default constructor. More...
 
virtual ~DefaultSolver ()=0
 default destructor. More...
 

Public Attributes

OSiLReaderm_osilreader
 m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed More...
 
- Public Attributes inherited from DefaultSolver
std::string osil
 osil holds the problem instance as a std::string More...
 
std::string osol
 osol holds the options for the solver More...
 
std::string osrl
 osrl holds the solution or result of the model More...
 
OSInstanceosinstance
 osinstance holds the problem instance in-memory as an OSInstance object More...
 
OSOptionosoption
 osoption holds the solver options in-memory as an OSOption object More...
 
OSResultosresult
 osresult holds the solution or result of the model in-memory as an OSResult object More...
 
std::string sSolverName
 sSolverName is the name of the Coin solver used, e.g. More...
 
bool bCallbuildSolverInstance
 bCallbuildSolverInstance is set to true if buildSolverService has been called More...
 
bool bSetSolverOptions
 bSetSolverOptions is set to true if setSolverOptions has been called, false otherwise More...
 

Protected Member Functions

void lindoAPIErrorCheck (std::string errormsg)
 Lindo's generalized error Reporting function. More...
 

Private Attributes

pLSenv pEnv_
 declare an instance of the LINDO environment object More...
 
pLSmodel pModel_
 declare an instance of the LINDO model object More...
 
int m_iLindoErrorCode
 m_iErrorCode is a variable for LINDO error codes More...
 
intm_miSlackIdx
 because LINDO API does not take row ranges we need some extra stuff m_miSlackIdx indexes the rows that get additional slack variable More...
 
int m_iNumberNewSlacks
 m_iNumberNewSlacks is the number of slack variables to add More...
 
double * m_mdRhsValue
 m_mdRhsValue is used to the store the constraint rhs if we do not use row upper and lower bounds More...
 
char * m_mcRowType
 m_mcRowType - E for equality, L for less than, G for greater than – used if we do not store rows using upper and lower bounds More...
 
double * m_mdVarLB
 m_mdLb holds an array of variable lower bounds. More...
 
double * m_mdVarUB
 m_mdUb holds an array of variable upper bounds. More...
 
double * m_mdConLB
 m_mdLhs holds an array of the constraint lower bounds. More...
 
double * m_mdConUB
 m_mdRhs holds an array of the constraint upper bounds. More...
 
char ** m_mmcVarName
 m_mmcVarName holds an array of char arrays. More...
 
std::string * m_msVarName
 m_msVarName holds an array of variable std::string names. More...
 
std::string * m_msConName
 m_msConName holds an array of constraint std::string names. More...
 
char * m_mcVarType
 m_vcVarType holds an array of variable types (character), e.g. More...
 
double m_mdObjConstant
 m_mdObjConstant holds an array of objective function constants. More...
 
OSrLWriterosrlwriter
 osrlwriter object used to write osrl from an OSResult object More...
 
double cpuTime
 

Detailed Description

the LindoSolver class solves problems using Lindo.

Author
Robert Fourer, Jun Ma, Kipp Martin
Version
1.0, 03/14/2004
Since
OS 1.0
Remarks
this class takes an OSiL instance and optimizes it using the Lindo API

Definition at line 49 of file OSLindoSolver.h.

Constructor & Destructor Documentation

LindoSolver::LindoSolver ( )

the LindoSolver class constructor

Definition at line 86 of file OSLindoSolver.cpp.

LindoSolver::~LindoSolver ( )

the LindoSolver class destructor

Definition at line 113 of file OSLindoSolver.cpp.

Member Function Documentation

void LindoSolver::solve ( )
virtual

solve results in an instance being read into the Lindo data structures and optimized

Implements DefaultSolver.

Definition at line 240 of file OSLindoSolver.cpp.

void LindoSolver::buildSolverInstance ( )
throw (ErrorClass
)
virtual

buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverInstance method – the solver instance is the instance the individual solver sees in its API

Implements DefaultSolver.

Definition at line 148 of file OSLindoSolver.cpp.

void LindoSolver::setSolverOptions ( )
throw (ErrorClass
)
virtual

The implementation of the virtual functions.

Returns
void.

Implements DefaultSolver.

Definition at line 223 of file OSLindoSolver.cpp.

bool LindoSolver::optimize ( )

invoke the Lindo API solver

Returns
true if an exception is not thrown.

Definition at line 542 of file OSLindoSolver.cpp.

bool LindoSolver::processVariables ( )

read the OSiL instance variables and put these into the LINDO API variables

Returns
true if an exception is not thrown.

Definition at line 404 of file OSLindoSolver.cpp.

bool LindoSolver::processConstraints ( )

read the OSiL instance constraints and put these into the LINDO API constraints

Returns
true if an exception is not thrown.

Definition at line 261 of file OSLindoSolver.cpp.

bool LindoSolver::generateLindoModel ( )

create the LINDO environment and read the problem into the internal LINDO data structures

Returns
true if an exception is not thrown.

Definition at line 439 of file OSLindoSolver.cpp.

bool LindoSolver::addSlackVars ( )

LINDO does not handle constraints with upper and lower bounds this method is part of kludge where we add a new variable to handle the bounds.

Returns
true if an exception is not thrown.

Definition at line 314 of file OSLindoSolver.cpp.

bool LindoSolver::processQuadraticTerms ( )

read the quadratic terms in the model

Returns
true if an exception is not thrown.

Definition at line 717 of file OSLindoSolver.cpp.

bool LindoSolver::processNonlinearExpressions ( )

read the nonlinear terms in the model

Returns
true if an exception is not thrown.

LINDO wants a unique list of the nonzero elements that appear in the nonlinear terms. To do this we index on the nonzero element and point to a number that counts where this unique element is in the list

pos is an iteratior for mapNewNumber

We don't know at compile time the number of instructions in a problem use a vector to dynamically allocate the instructions (OP_Codes). This eventually gets copied into a LINDO array paiInsList

We get a map of all of the Expression trees where the index is row or objective number that points to an expression tree for that row or objective function that contains at least one nonlinear term.

The map allExpTrees indexes by row and objective function all of the expression trees. For each nonlinear constraint or objective function we convert the associated expresssion tree into a vector of OSnLNodes in postfix format

define an iterator for the expression trees map allExpTrees

KEY ASSUMPTION: We have already defined the model including all variables, constraints, bounds, objective functions, etc.

Define the local variables used by LINDO

Direction of optimization

Lower bounds of variables. Since we aren't adding any new variables to our model, we can set this to NULL

Upper bounds of variables. Since we aren't adding any new variables to our model, we can set this to NULL

The initial values of the variables

Variable type. Since we aren't adding any new variables to our model, we can set this to NULL

Constraint type Since we aren't changing or adding the constraint types in our model, we can set this to NULL

The number of nonzeros in the nonlinear terms is given by iNumNonlinearNonz

A pointer to the nonzeros in the nonlinear terms is given by padNonlinearNonz

The number of constraints with nonlinear terms is given by iNumberOfNonlinearConstraints

A pointer to the start of each nonlinear constraint in the instructions list paiOp_Codes is given by paiConsBegin

A pointer to the length of each nonlinear constraint in the instructions list paiOp_Codes is given by paiConsLength

The number of objectives with nonlinear terms is given by iNumberOfNonlinearObjectives

A pointer to the start of each objective function in the instructions list paiOp_Codes is given by paiObjsBegin

A pointer to the length of each objective function in the instructions list paiOp_Codes is given by paiObjsLength

The number of new variables in the nonlinear terms is given by iNumberOfNewVariables In our implementation we assume all the variables are added prior to adding the nonlinear terms so this should always be zero

The nonlinear terms are held in postfix format via op codes in the pointer array paiInsList

The length the instruction list, paiInstList is iInstListLength

The length the instruction list, paiInstList is iInstListLength

Definition at line 818 of file OSLindoSolver.cpp.

void LindoSolver::dataEchoCheck ( )

use this for debugging, print out the instance that the solver thinks it has and compare this with the OSiL file

Definition at line 1187 of file OSLindoSolver.cpp.

void LindoSolver::lindoAPIErrorCheck ( std::string  errormsg)
protected

Lindo's generalized error Reporting function.

Definition at line 1261 of file OSLindoSolver.cpp.

Member Data Documentation

OSiLReader* LindoSolver::m_osilreader

m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed

Definition at line 129 of file OSLindoSolver.h.

pLSenv LindoSolver::pEnv_
private

declare an instance of the LINDO environment object

Definition at line 143 of file OSLindoSolver.h.

pLSmodel LindoSolver::pModel_
private

declare an instance of the LINDO model object

Definition at line 146 of file OSLindoSolver.h.

int LindoSolver::m_iLindoErrorCode
private

m_iErrorCode is a variable for LINDO error codes

Definition at line 149 of file OSLindoSolver.h.

int* LindoSolver::m_miSlackIdx
private

because LINDO API does not take row ranges we need some extra stuff m_miSlackIdx indexes the rows that get additional slack variable

Definition at line 153 of file OSLindoSolver.h.

int LindoSolver::m_iNumberNewSlacks
private

m_iNumberNewSlacks is the number of slack variables to add

Definition at line 156 of file OSLindoSolver.h.

double* LindoSolver::m_mdRhsValue
private

m_mdRhsValue is used to the store the constraint rhs if we do not use row upper and lower bounds

Definition at line 161 of file OSLindoSolver.h.

char* LindoSolver::m_mcRowType
private

m_mcRowType - E for equality, L for less than, G for greater than – used if we do not store rows using upper and lower bounds

Definition at line 166 of file OSLindoSolver.h.

double* LindoSolver::m_mdVarLB
private

m_mdLb holds an array of variable lower bounds.

Definition at line 171 of file OSLindoSolver.h.

double* LindoSolver::m_mdVarUB
private

m_mdUb holds an array of variable upper bounds.

Definition at line 176 of file OSLindoSolver.h.

double* LindoSolver::m_mdConLB
private

m_mdLhs holds an array of the constraint lower bounds.

Definition at line 181 of file OSLindoSolver.h.

double* LindoSolver::m_mdConUB
private

m_mdRhs holds an array of the constraint upper bounds.

Definition at line 186 of file OSLindoSolver.h.

char** LindoSolver::m_mmcVarName
private

m_mmcVarName holds an array of char arrays.

Definition at line 191 of file OSLindoSolver.h.

std::string* LindoSolver::m_msVarName
private

m_msVarName holds an array of variable std::string names.

Definition at line 196 of file OSLindoSolver.h.

std::string* LindoSolver::m_msConName
private

m_msConName holds an array of constraint std::string names.

Definition at line 201 of file OSLindoSolver.h.

char* LindoSolver::m_mcVarType
private

m_vcVarType holds an array of variable types (character), e.g.

'C' for continuous type, 'I' for integer type, 'B' for binary type, 'S' for std::string type).

Definition at line 207 of file OSLindoSolver.h.

double LindoSolver::m_mdObjConstant
private

m_mdObjConstant holds an array of objective function constants.

Definition at line 211 of file OSLindoSolver.h.

OSrLWriter* LindoSolver::osrlwriter
private

osrlwriter object used to write osrl from an OSResult object

Definition at line 214 of file OSLindoSolver.h.

double LindoSolver::cpuTime
private

Definition at line 216 of file OSLindoSolver.h.


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