CNDSM  1.00
MCFCplex Class Reference

The MCFCplex class derives from the abstract base class MCFClass, thus sharing its (standard) interface, and solves (Linear) Min Cost Flow problems via calls to Cplex Callable Library functions. More...

#include <MCFCplex.h>

Inheritance diagram for MCFCplex:
MCFClass

Public Types

- Public Types inherited from MCFClass
typedef unsigned int Index
 index of a node or arc ( >= 0 )
 
typedef IndexIndex_Set
 set (array) of indices
 
typedef const Index cIndex
 a read-only index
 
typedef cIndexcIndex_Set
 read-only index array
 
typedef double FNumber
 type of arc flow
 
typedef FNumberFRow
 vector of flows
 
typedef const FNumber cFNumber
 a read-only flow
 
typedef cFNumbercFRow
 read-only flow array
 
typedef double CNumber
 type of arc flow cost
 
typedef CNumberCRow
 vector of costs
 
typedef const CNumber cCNumber
 a read-only cost
 
typedef cCNumbercCRow
 read-only cost array
 
typedef double FONumber
 type of the objective function: has to hold sums of products of FNumber(s) by CNumber(s)
 
typedef const FONumber cFONumber
 a read-only o.f. value
 
typedef MCFStateMCFStatePtr
 pointer to a MCFState
 

Public Member Functions

 MCFCplex (cIndex nmx=0, cIndex mmx=0, CPXENVptr extenv=NULL)
 Constructor of the class. More...
 
void LoadNet (cIndex nmx=0, cIndex mmx=0, cIndex pn=0, cIndex pm=0, cFRow pU=NULL, cCRow pC=NULL, cFRow pDfct=NULL, cIndex_Set pSn=NULL, cIndex_Set pEn=NULL)
 Inputs a new network, as in MCFClass::LoadNet(). More...
 
virtual void SetPar (int par, int val)
 Set integer parameters of the algorithm. More...
 
virtual void SetPar (int par, double val)
 Set float parameters of the algorithm. More...
 
virtual void GetPar (int par, int &val)
 This method returns one of the integer parameter of the algorithm. More...
 
CPXENVptr GetCplexEnv (void)
 Returns a pointer to the internal Cplex environment. More...
 
- Public Member Functions inherited from MCFClass
 MCFClass (cIndex nmx=0, cIndex mmx=0)
 Constructor of the class. More...
 
virtual void LoadDMX (istream &DMXs, bool IsQuad=false)
 Read a MCF instance in DIMACS standard format from the istream. More...
 
virtual void PreProcess (void)
 Extract a smaller/easier equivalent MCF problem. More...
 
virtual void GetPar (int par, double &val)
 This method returns one of the integer parameter of the algorithm. More...
 
virtual void SetMCFTime (bool TimeIt=true)
 Allocate an OPTtimers object [see OPTtypes.h] to be used for timing the methods of the class. More...
 
int MCFGetStatus (void)
 Returns an int describing the current status of the MCF solver. More...
 
virtual cFRow MCFGetX (void)
 Return a read-only pointer to an internal data structure containing the flow solution in "dense" format. More...
 
virtual bool HaveNewX (void)
 Return true if a different (approximately) optimal primal solution is available. More...
 
virtual cCRow MCFGetPi (void)
 Return a read-only pointer to an internal data structure containing the node potentials. More...
 
virtual bool HaveNewPi (void)
 Return true if a different (approximately) optimal dual solution is available. More...
 
virtual cCRow MCFGetRC (void)
 Return a read-only pointer to an internal data structure containing the reduced costs. More...
 
virtual FONumber MCFGetDFO (void)
 Return the objective function value of the dual solution currently returned by MCFGetPi() / MCFGetRC(). More...
 
virtual FNumber MCFGetUnfCut (Index_Set Cut)
 Return an unfeasibility certificate. More...
 
virtual Index MCFGetUnbCycl (Index_Set Pred, Index_Set ArcPred)
 Return an unboundedness certificate. More...
 
virtual MCFStatePtr MCFGetState (void)
 Save the state of the MCF solver. More...
 
virtual void MCFPutState (MCFStatePtr S)
 Restore the solver to the state in which it was when the state `S' was created with MCFGetState() [see above]. More...
 
void TimeMCF (double &t_us, double &t_ss)
 Time the code. More...
 
double TimeMCF (void)
 Like TimeMCF(double,double) [see above], but returns the total time. More...
 
void CheckPSol (void)
 Check that the primal solution returned by the solver is primal feasible. More...
 
void CheckDSol (void)
 Check that the dual solution returned by the solver is dual feasible. More...
 
Index MCFnmax (void)
 Return the maximum number of nodes for this instance of MCFClass. More...
 
Index MCFmmax (void)
 Return the maximum number of arcs for this instance of MCFClass. More...
 
Index MCFn (void)
 Return the number of nodes in the current graph. More...
 
Index MCFm (void)
 Return the number of arcs in the current graph. More...
 
virtual cIndex_Set MCFSNdes (void)
 Return a read-only pointer to an internal vector containing the starting (tail) nodes for each arc. More...
 
virtual cIndex_Set MCFENdes (void)
 Return a read-only pointer to an internal vector containing the ending (head) nodes for each arc. More...
 
virtual cCRow MCFCosts (void)
 Return a read-only pointer to an internal vector containing the arc costs. More...
 
virtual cCRow MCFQCoef (void)
 Return a read-only pointer to an internal vector containing the arc costs. More...
 
virtual cFRow MCFUCaps (void)
 Return a read-only pointer to an internal vector containing the arc capacities. More...
 
virtual cFRow MCFDfcts (void)
 Return a read-only pointer to an internal vector containing the node deficits. More...
 
virtual void WriteMCF (ostream &oStrm, int frmt=0)
 Write the current MCF problem to an ostream. More...
 
virtual ~MCFClass ()
 Destructor of the class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MCFClass
template<class T >
bool ETZ (T x, const T eps)
 true if flow x is equal to zero (possibly considering tolerances). More...
 
template<class T >
bool GTZ (T x, const T eps)
 true if flow x is greater than zero (possibly considering tolerances). More...
 
template<class T >
bool GEZ (T x, const T eps)
 true if flow x is greater than or equal to zero (possibly considering tolerances). More...
 
template<class T >
bool LTZ (T x, const T eps)
 true if flow x is less than zero (possibly considering tolerances). More...
 
template<class T >
bool LEZ (T x, const T eps)
 true if flow x is less than or equal to zero (possibly considering tolerances). More...
 
template<class T >
bool GT (T x, T y, const T eps)
 true if flow x is greater than flow y (possibly considering tolerances).
 
template<class T >
bool LT (T x, T y, const T eps)
 true if flow x is less than flow y (possibly considering tolerances). More...
 
- Protected Attributes inherited from MCFClass
Index n
 total number of nodes
 
Index nmax
 maximum number of nodes
 
Index m
 total number of arcs
 
Index mmax
 maximum number of arcs
 
int status
 return status, see the comments to MCFGetStatus() above. More...
 
bool Senstv
 true <=> the latest optimal solution should be exploited
 
OPTtimers * MCFt
 timer for performances evaluation
 
FNumber EpsFlw
 precision for comparing arc flows / capacities
 
FNumber EpsDfct
 precision for comparing node deficits
 
CNumber EpsCst
 precision for comparing arc costs
 
double MaxTime
 max time (in seconds) in which MCF Solver can find an optimal solution (0 = no limits)
 
int MaxIter
 max number of iterations in which MCF Solver can find an optimal solution (0 = no limits)
 

Detailed Description

The MCFCplex class derives from the abstract base class MCFClass, thus sharing its (standard) interface, and solves (Linear) Min Cost Flow problems via calls to Cplex Callable Library functions.

Member Enumeration Documentation

enum MCFCParam

Public enum describing the possible parameters of the MCF solver, "extended" from MCFClass::MCFParam, to be used with the methods SetPar() and GetPar().

Enumerator
kQPMethod 

solution method

Constructor & Destructor Documentation

MCFCplex ( cIndex  nmx = 0,
cIndex  mmx = 0,
CPXENVptr  extenv = NULL 
)

Constructor of the class.

For the meaning of nmx and mmx see MCFClass::MCFClass().

If extenv != NULL, it is taken as a pointer to a valid Cplex environment [see GetCplexEnv() below] that will be used for all the lifetime of the object. Otherwise, a Cplex environment is possibly initialized in the constructor. The environment is shared among all the active instances of MCFCplex objects; this is done in order to save on the number of (costly) Cplex licenses required to have multiple MCF solvers active at the same time, since any environment consumes a licence. Thus, the environment is actually initialized only when the first instance is constructed, and it is released when the last destructor (of an instance using it) is invoked.

The possibility of passing an external environment is let because having all the instances to share the same environment has the drawback that all changes made to optimization parameters of the environment [see SetPar() below] are "seen" be all active instances, even though the changes are invoked for one specific object. If for some reason this is unacceptable, the user should provide each "sensitive" instance with its own private environment, letting all the others to share the "static" one. Of course, it is then user's responsibility to initialize and free the environment.

Member Function Documentation

void LoadNet ( cIndex  nmx = 0,
cIndex  mmx = 0,
cIndex  pn = 0,
cIndex  pm = 0,
cFRow  pU = NULL,
cCRow  pC = NULL,
cFRow  pDfct = NULL,
cIndex_Set  pSn = NULL,
cIndex_Set  pEn = NULL 
)
virtual

Inputs a new network, as in MCFClass::LoadNet().

Passing pC[ i ] == C_INF means that the arc `i' does not exist in the problem. These arcs are just "closed" and their cost is set to 0: this is done for being (if DYNMC_MCF_CPX > 0) subsequently capable of "opening" them back with OpenArc(). If the corresponding pU[ i ] is == F_INF then the arc is just "deleted".

Implements MCFClass.

void SetPar ( int  par,
int  val 
)
inlinevirtual

Set integer parameters of the algorithm.

Parameters
paris the parameter to be set;
valueis the value to assign to the parameter.

Apart from the parameters of the base class, this method handles:

  • kQPMethod: the alorithm used to solve the QP, possible values are defined in the enum QPMethod.
  • <any other>="">: any unrecognized value is taken to be one of the the many "int" algorithmic parameters of Cplex and passed right away via CPXsetintparam() [see the documentation in the Cplex manual for details.

Reimplemented from MCFClass.

References MCFClass::SetPar().

void SetPar ( int  par,
double  val 
)
inlinevirtual

Set float parameters of the algorithm.

Parameters
paris the parameter to be set;
valueis the value to assign to the parameter.

Apart from the parameters of the base class, this method handles:

  • <any other>="">: any unrecognized value is taken to be one of the the many "int" algorithmic parameters of Cplex and passed right away via CPXsetintparam() [see the documentation in the Cplex manual for details.

Reimplemented from MCFClass.

References MCFClass::SetPar().

void GetPar ( int  par,
int &  val 
)
inlinevirtual

This method returns one of the integer parameter of the algorithm.

Parameters
paris the parameter to return [see SetPar( int ) for comments];
valupon return, it will contain the value of the parameter.

Apart from the parameters of the base class, this method handles kQPMethod.

Reimplemented from MCFClass.

References MCFClass::GetPar().

CPXENVptr GetCplexEnv ( void  )
inline

Returns a pointer to the internal Cplex environment.

This method is provided as an alternative to the two forms of SetPar() [see above]; by getting the pointer to the internal Cplex environment with GetCplexEnv(), CPXset***param() can be called directly. This also allows to perform any other operation with the environment, such as reading the value of the parameters with CPXgetintparam() and CPXgetdbqparam(), so care must be taken.

The returned pointer is the same passed to the constructor [see above], if any; otherwise it is the "static" environment shared by all the active MCFCplex instances. In the latter case, any change in the environment simultaneously affect all the existing (and future) MCFCplex instances which have not been given a "private" environment.

References MCFClass::MCFQCoef().