Classes | Public Member Functions | Public Attributes | List of all members
OSBearcatSolverXij Class Reference

#include <OSBearcatSolverXij.h>

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

Classes

class  Factory
 

Public Member Functions

virtual OSInstancegetInitialRestrictedMaster ()
 OSInstance* OSBearcatSolverXij::getInitialRestrictedMaster( ){. More...
 
OSInstancegetSeparationInstance ()
 
double qrouteCost (const int &k, const int &l, const double *c, int *kountVar)
 kipp – document More...
 
void getOptL (double **c)
 
void getCutsTheta (const double *thetaVar, const int numThetaVar, int &numNewRows, int *&numNonz, int **&colIdx, double **&values, double *&rowLB, double *&rowUB)
 RETURN VALUES: int numNewRows – number of new rows generated int* numNonz – number of nonzeros in each row int** colIdx – vectors column indexes of new rows double** values – vectors of matrix coefficient values of new rows double* rowLB – vector of row lower bounds double* rowUB – vector of row upper bounds. More...
 
void getCutsX (const double *xVar, const int numXVar, int &numNewRows, int *&numNonz, int **&colIdx, double **&values, double *&rowLB, double *&rowUB)
 RETURN VALUES: int numNewRows – number of new rows generated int* numNonz – number of nonzeros in each row int** colIdx – vectors column indexes of new rows double** values – vectors of matrix coefficient values of new rows double* rowLB – vector of row lower bounds double* rowUB – vector of row upper bounds. More...
 
virtual void getBranchingCut (const double *thetaVar, const int numThetaVar, const std::map< int, int > &varConMap, int &varIdx, int &numNonz, int *&indexes, double *&values)
 RETURN VALUES: varIdx – the variable number x_{ij} for branching numNonz – number of theta indexes in the cut indexes – the indexes of the theta variables values – the number of times the theta indexed in indexes appears in the cut note – set numNonz to zero if the generated cut variable already appears in varConMap. More...
 
virtual void getBranchingCut (const int *thetaIdx, const double *theta, const int numThetaVar, const std::map< int, int > &varConMap, int &varIdx, int &numNonz, int *&indexes, double *&values)
 Sparse Version. More...
 
void getCutsMultiCommod (const double *thetaVar, const int numThetaVar, int &numNewRows, int *&numNonz, int **&colIdx, double **&values, double *&rowLB, double *&rowUB)
 This is the routine that generates the multi-item cuts. More...
 
int getBranchingVar (const double *theta, const int numThetaVar)
 RETURN VALUES: return the integer index of a fractional x_{ij} variable. More...
 
int getBranchingVar (const int *thetaIdx, const double *theta, const int numThetaVar)
 Sparse Version. More...
 
virtual void getColumns (const double *yA, const int numARows, const double *yB, const int numBRows, int &numNewColumns, int *&numNonz, double *&cost, int **&rowIdx, double **&values, double &lowerBound)
 RETURN VALUES: int numNewColumns – number of new columns generated int* numNonz – number of nonzeros in each column double* cost – the objective function coefficient on each new column double** rowIdx – vectors row indexes of new columns double** values – vectors of matrix coefficient values of new columns double lowerBound – the lowerBound, this is a value on the LP relaxation. More...
 
void getOptions (OSOption *osoption)
 
void getVariableIndexMap ()
 this method will populate: std::map<std::pair<int, int>,int>m_xVarIndexMap this gives us More...
 
void permuteHubs ()
 this method will calculate a permuation of the hubs so that they are in ascending order, this will make the dynamic program in the v variables faster More...
 
void calcReducedCost (const double *yA, const double *yB)
 calculate the reduced costs c – input of the objective function costs yA – dual values on node assignment – coupling constraints yB – dual values on tour breaking constraints d – reduced with convexity dual value More...
 
void createVariableNames ()
 
void createAmatrix ()
 
virtual void initializeDataStructures ()
 allocate memory and initialize arrays More...
 
void getInitialSolution ()
 generate an intitial feasible solution in theta space for the initial master More...
 
virtual void resetMaster (std::map< int, int > &inVars, OsiSolverInterface *si)
 INPUT: More...
 
double getRouteDistance (int numNodes, int hubIndex, CoinSolver *solver, std::vector< int > zk, double *xVar)
 call this method to get a minimum TSP tour for a given assignment of nodes to routes INPUT: int numNodes – number of cities/nodes in tour int hubIndex – indexes the hub index CoinSolver* solver – the coin solver numNodes*numNodes - numNodes entries, we are assuming zk – indexes the non-hub nodes assigned this route asymmetric More...
 
CoinSolvergetTSP (int numNodes, double *cost)
 call this method to get a TSP instance More...
 
CoinSolvergetMultiCommodInstance (int hubIndex)
 call this method to get an instance that is used to generate a multicommodity cut More...
 
void getFeasibleSolution ()
 call this method to get generate an instance of the generalized assignment problem and find a feasible solution to the problem More...
 
bool OneOPT ()
 try and find a feasible solution, return false if solution not feasible More...
 
virtual void pauHana (std::vector< int > &m_zOptIndexes, std::vector< double > &m_zRootLPx_vals, int numNodes, int numColsGen, std::string message)
 
double calcNonlinearRelax (std::vector< double > &m_zRootLPx_vals)
 calculate the nonlinear relaxation value for an LP solution More...
 
 OSBearcatSolverXij ()
 Default Constructor. More...
 
 OSBearcatSolverXij (OSOption *osoption)
 Second Constructor. More...
 
 ~OSBearcatSolverXij ()
 Default Destructor. More...
 
- Public Member Functions inherited from OSDecompSolver
 OSDecompSolver ()
 Default Constructor. More...
 
 OSDecompSolver (OSOption *osoption)
 Constructor with OSOption Arg. More...
 
virtual ~OSDecompSolver ()=0
 Default destructor. More...
 

Public Attributes

std::map< int, std::string > m_tmpVarMap
 
std::map< std::pair< int, int >
, int
m_xVarIndexMap
 m_xVarIndexMap takes a variable indexed by (i,j) and returns the index of the variable in one dimension More...
 
intm_hubPoint
 m_hubPoint[ k] points to the the k'th hub that we use in getOptL More...
 
std::string m_initOSiLFile
 
std::map< int, std::map< int,
std::vector< int > > > 
m_initSolMap
 the index on the outer map is on the solution number, the index on the inner map indexes the route number, the vector is the list of nodes assigned to that route More...
 
std::vector< CoinSolver * > m_multCommodCutSolvers
 m_multCommodCutSolvers is a vector of solvers, one solver for each hub, used to find multicommodity flow cuts for the given hub More...
 
bool m_use1OPTstart
 if m_use1OPTstart is true we use the option file to fix the nodes to hubs found by SK's 1OPT heuristic More...
 
int m_maxThetaNonz
 m_maxMasterNonz is the maximumn number of nonzero elements we allow in the transformation matrix betwee the theta variables and the xij variables More...
 
intm_routeCapacity
 the route capacity – bus seating limit this can vary with the route/hub More...
 
intm_routeMinPickup
 the minimum number of students that we pickup on a route this can vary with the route/hub More...
 
intm_upperBoundL
 largest possible L-value on a route – this will be the minimum of m_routeCapacity and total demand More...
 
intm_lowerBoundL
 smallest possible L-value on a route for now this will equal More...
 
int m_upperBoundLMax
 largest possible L-value over all routes More...
 
int m_minDemand
 m_minDemand is the value of the minimum demand node – it is not the minimum demand that must be carried on a route More...
 
intm_demand
 m_demand is the vector of node demands More...
 
std::string * m_nodeName
 m_nodeName is the vector of node names More...
 
double * m_cost
 the distance/cost vectors More...
 
bool m_costSetInOption
 m_costSetInOption is true if the costs are set using the OSOption file More...
 
double ** m_rc
 the reduced cost vector for each k, we asssume order is (l, i, j) More...
 
double * m_optValHub
 
double ** m_u
 
double ** m_v
 
int ** m_px
 
int ** m_tx
 
double ** m_g
 
intm_varIdx
 
intm_optL
 
intm_optD
 
double ** m_vv
 
int ** m_vvpnt
 
int m_totalDemand
 
int m_numberOfSolutions
 
intm_tmpScatterArray
 
double m_lowerBnd
 
intm_newColumnNonz
 
double * m_costVec
 
int ** m_newColumnRowIdx
 
double ** m_newColumnRowValue
 
intm_newRowNonz
 
int ** m_newRowColumnIdx
 
double ** m_newRowColumnValue
 
double * m_newRowUB
 
double * m_newRowLB
 
intbranchCutIndexes
 
double * branchCutValues
 
double * m_thetaCost
 
intm_convexityRowIndex
 m_convexityRowIndex holds the index of the convexity row that the theta columns are in. More...
 
intm_BmatrixRowIndex
 m_BmatrixRowIndex holds the index of the convexity row that the constraint corresponds to, this is for the multicommodity constraints – if the constraint applies to theta regardless of k, then the value is -1 More...
 
intm_separationIndexMap
 m_separationIndexMap maps the variable index into the appropriate row in the separation problem for the tour breaking constraints More...
 
OSInstancem_osinstanceSeparation
 
ClpSimplex * m_separationClpModel
 
- Public Attributes inherited from OSDecompSolver
OSInstancem_osinstanceMaster
 
int m_multiCommodCutLimit
 
int m_numMultCuts
 
OSDecompParam m_osDecompParam
 share the parameters with the decomposition solver More...
 
double m_bestIPValue
 
double m_bestLPValue
 
double m_rootLPValue
 
intm_thetaPnt
 
intm_thetaIndex
 
int m_numThetaVar
 
int m_numThetaNonz
 
intm_pntBmatrix
 
intm_BmatrixIdx
 
double * m_BmatrixVal
 
std::set< std::pair< int,
double > > 
intVarSet
 intVarSet holds and std::pair where the first element is the index of an integer variable and the second is the variable upper bound More...
 
int m_numHubs
 m_numHubs is the number of hubs/routes More...
 
int m_numNodes
 m_numNodes is the number of nodes (both pickup and hub) in the model More...
 
intm_pntAmatrix
 
intm_Amatrix
 
int m_numBmatrixCon
 m_numBmatrixCon is the number of constraints in B - 1, we have the -1 because: m_pntBmatrix[ k] points to the start of constraint k and m_pntBmatrix[ m_numBmatrixCon ] is equal to m_numBmatrixNonz More...
 
int m_numBmatrixNonz
 
int m_maxBmatrixNonz
 m_maxBmatrixNonz is the maximum number of nonzero elements in the B matrix constraints More...
 
int m_maxBmatrixCon
 m_maxBmatrixCon is the maximum number of B matrix constraints it is the number of tour breaking constraints plus variable branch constraints More...
 
int m_maxMasterColumns
 m_maxMasterColumns is the maximumn number of columns we allow in the master More...
 
int m_maxMasterRows
 m_maxMasterColumns is the maximumn number of rows we allow in the master, in this application it is equal to m_maxBmatrixCon plus m_numNodes – we therefore do not need to read this from an option file as we might for other problems More...
 
std::string * m_variableNames
 
OSOptionm_osoption
 

Detailed Description

Definition at line 31 of file OSBearcatSolverXij.h.

Constructor & Destructor Documentation

OSBearcatSolverXij::OSBearcatSolverXij ( )

Default Constructor.

Definition at line 68 of file OSBearcatSolverXij.cpp.

OSBearcatSolverXij::OSBearcatSolverXij ( OSOption osoption)

Second Constructor.

Definition at line 72 of file OSBearcatSolverXij.cpp.

OSBearcatSolverXij::~OSBearcatSolverXij ( )

Default Destructor.

Definition at line 360 of file OSBearcatSolverXij.cpp.

Member Function Documentation

OSInstance * OSBearcatSolverXij::getInitialRestrictedMaster ( )
virtual

OSInstance* OSBearcatSolverXij::getInitialRestrictedMaster( ){.

    std::cout << "Executing OSBearcatSolverXij::getInitialRestrictedMaster( )" << std::endl;

define the classes FileUtil *fileUtil = NULL; OSiLReader *osilreader = NULL; DefaultSolver *solver = NULL; OSInstance *osinstance = NULL;

end classes

    std::string testFileName;
    std::string osil;

std::vector< int> indexes; fileUtil = new FileUtil();

    std::map<int, std::map<int, std::vector<int> > >::iterator  mit;
    std::map<int, std::vector<int> >::iterator  mit2;
    std::vector<int>::iterator  vit;

    m_osinstanceMaster = NULL;

add linear constraint coefficients number of values will nodes.size() the coefficients in the node constraints plus coefficients in convexity constraints which is the number of varaibles int kountNonz; int kount; int numThetaVar = m_numberOfSolutions*m_numHubs; double values = new double[ m_numberOfSolutions(m_numNodes-m_numHubs) + numThetaVar]; int indexes = new int[ m_numberOfSolutions(m_numNodes-m_numHubs) + numThetaVar]; int *starts = new int[ numThetaVar + 1]; kount = 0;

starts[ 0] = 0;

int startsIdx; startsIdx = 0;

std::vector<IndexValuePair*> primalValPair;

try {

    if(m_initOSiLFile.size() == 0) throw ErrorClass("OSiL file to generate restricted master missing");
    osil = fileUtil->getFileAsString( m_initOSiLFile.c_str());

    osilreader = new OSiLReader();
    osinstance = osilreader->readOSiL(osil);



    int i;
    int j;
    int k;

fill in the cost vector first the x vector starts at 2*m_numHubs

            int idx1;
            int idx2;


            idx2 = 0;  //zRouteDemand have 0 coefficients in obj

fill in m_cost from the cost coefficient in osil for(k = 0; k < m_numHubs; k++){

    idx1 = 0;

    for(i = 0; i < m_numNodes; i++){

            for(j = 0; j < i; j++){

                    m_cost[k][idx1++ ] = osinstance->instanceData->objectives->obj[0]->coef[ idx2++ ]->value;
            }

            for(j = i + 1; j < m_numNodes; j++){

                    m_cost[k][idx1++ ] = osinstance->instanceData->objectives->obj[0]->coef[ idx2++ ]->value;

            }
    }

}

get variable names for checking purposes std::string* varNames; varNames = osinstance->getVariableNames();

start building the restricted master here

            m_osinstanceMaster = new OSInstance();
            m_osinstanceMaster->setInstanceDescription("The Initial Restricted Master");

first the variables m_osinstanceMaster->setVariableNumber( m_numberOfSolutions*m_numHubs);

now add the objective function m_osinstanceMaster->setObjectiveNumber( 1); SparseVector *objcoeff = new SparseVector( m_numberOfSolutions*m_numHubs);

now the constraints m_osinstanceMaster->setConstraintNumber( m_numNodes);

addVariable(int index, string name, double lowerBound, double upperBound, char type, double init, string initString); we could use setVariables() and add all the variable with one method call – below is easier

            int varNumber;
            varNumber = 0;
            std::string masterVarName;
            kountNonz = 0;

now get the primal solution solve the model for solution in the osoption object for ( mit = m_initSolMap.begin() ; mit != m_initSolMap.end(); mit++ ){

kipp change upper and lower bounds here on z variables loop over nodes and routes and set bound set kount to the start of the z variables go past the x variables kount = 2*m_numHubs + m_numHubs*(m_numNodes*m_numNodes - m_numNodes); osinstance->bVariablesModified = true; for ( mit2 = mit->second.begin() ; mit2 != mit->second.end(); mit2++ ){ //we are looping over routes in solution mit

                            startsIdx++;
                            starts[ startsIdx ] = kountNonz + mit2->second.size() + 1; //the +1 comes from the convexity row

make sure all lower bounds on z variables on this route back to 0.0 for(i = 0; i < m_numNodes; i++){ osinstance->instanceData->variables->var[ kount + mit2->first*m_numNodes + i]->lb = 0.0; }

                            for ( vit = mit2->second.begin() ; vit != mit2->second.end(); vit++ ){  


                                    osinstance->instanceData->variables->var[ kount + mit2->first*m_numNodes + *vit]->lb = 1.0;

std::cout << "FIXING LOWER BOUND ON VARIABLE " << osinstance->getVariableNames()[ kount + mit2->first*m_numNodes + *vit ] << std::endl;

                                    values[ kountNonz] = 1.0;
                                    indexes[ kountNonz ] = *vit - m_numHubs ;  //0 based counting
                                    kountNonz++;

                            }

now for the convexity row coefficient values[ kountNonz] = 1; indexes[ kountNonz ] = m_numNodes - m_numHubs + mit2->first ; kountNonz++;

                    }

                    solver = new CoinSolver();
                    solver->sSolverName ="cbc"; 
                    solver->osinstance = osinstance;        

                    solver->buildSolverInstance();
                    solver->solve();

get the solver solution status

                    std::cout << "Solution Status =  " << solver->osresult->getSolutionStatusType( 0 ) << std::endl;

get the optimal objective function value

                    primalValPair = solver->osresult->getOptimalPrimalVariableValues( 0);

loop over routes again to create master objective coefficients

                    for(k = 0; k < m_numHubs; k++){

lets get the x variables the variables for this route should be from 2*numHubs + k*(numNodes - 1*)*(numNodes - 1) idx1 = 2*m_numHubs + k*m_numNodes*(m_numNodes - 1); idx2 = idx1 + m_numNodes*(m_numNodes - 1); end of x variables

std::cout << "HUB " << k << " VARIABLES" << std::endl;

                            for(i = idx1; i < idx2; i++){
                                    if(  primalValPair[ i]->value > .1 ){

std::cout << osinstance->getVariableNames()[ primalValPair[ i]->idx ] << std::endl; std::cout << m_variableNames[ primalValPair[ i]->idx - k*(m_numNodes - 1)*m_numNodes - 2*m_numHubs ] << std::endl; m_thetaIndex[ m_numThetaNonz++ ] = primalValPair[ i]->idx - k*(m_numNodes - 1)*m_numNodes - 2*m_numHubs; }

} m_convexityRowIndex[ m_numThetaVar] = k; m_thetaCost[ m_numThetaVar++ ] = primalValPair[ k]->value*primalValPair[ k + m_numHubs]->value; m_thetaPnt[ m_numThetaVar ] = m_numThetaNonz;

masterVarName = makeStringFromInt("theta(", k); masterVarName += makeStringFromInt(",", mit->first); masterVarName += ")"; intVarSet.insert ( std::pair<int,double>(varNumber, 1.0) ); m_osinstanceMaster->addVariable(varNumber++, masterVarName, 0, 1, 'C');

std::cout << "Optimal Objective Value = " << primalValPair[ k]->value*primalValPair[ k + m_numHubs]->value << std::endl;

objcoeff->indexes[ k + (mit->first)*m_numHubs] = k + (mit->first)*m_numHubs; objcoeff->values[ k + (mit->first)*m_numHubs] = primalValPair[ k]->value*primalValPair[ k + m_numHubs]->value;

                            std::cout <<  osinstance->getVariableNames()[ k ] << std::endl;
                            std::cout <<  osinstance->getVariableNames()[ k + m_numHubs ] << std::endl;


                    }//end for on k -- hubs


                    primalValPair.clear();
                    delete solver;
                    solver = NULL;
            }//end for on number of solutions

add the constraints add the row saying we must visit each node for( i = 0; i < m_numNodes - m_numHubs ; i++){

    m_osinstanceMaster->addConstraint(i,  makeStringFromInt("visitNode_", i + m_numHubs) , 1.0, 1.0, 0); 

}

kount = 0;

add the convexity row for( i = m_numNodes - m_numHubs; i < m_numNodes ; i++){

    m_osinstanceMaster->addConstraint(i,  makeStringFromInt("convexityRowRoute_", kount++ ) , 1.0, 1.0, 0); 

}

m_osinstanceMaster->addObjective(-1, "objfunction", "min", 0.0, 1.0, objcoeff);

std::cout << "kountNonz = " << kountNonz << std::endl;

add the linear constraints coefficients m_osinstanceMaster->setLinearConstraintCoefficients(kountNonz , true, values, 0, kountNonz - 1, indexes, 0, kountNonz - 1, starts, 0, startsIdx);

            std::cout << m_osinstanceMaster->printModel() << std::endl;
            delete objcoeff;

delete[] values; delete[] starts; delete[] indexes; delete osilreader; osilreader = NULL;

    } catch (const ErrorClass& eclass) {
            std::cout << std::endl << std::endl << std::endl;
            if (osilreader != NULL)
                    delete osilreader;
            if (solver != NULL)
                    delete solver;

Problem with the parser throw ErrorClass(eclass.errormsg); }

delete fileUtil; fileUtil = NULL;

return m_osinstanceMaster; }//end generateInitialRestrictedMaster

Implements OSDecompSolver.

Definition at line 1632 of file OSBearcatSolverXij.cpp.

OSInstance * OSBearcatSolverXij::getSeparationInstance ( )

Definition at line 3776 of file OSBearcatSolverXij.cpp.

double OSBearcatSolverXij::qrouteCost ( const int k,
const int l,
const double *  c,
int kountVar 
)

kipp – document

Definition at line 727 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getOptL ( double **  c)

Definition at line 570 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getCutsTheta ( const double *  thetaVar,
const int  numThetaVar,
int numNewRows,
int *&  numNonz,
int **&  colIdx,
double **&  values,
double *&  rowLB,
double *&  rowUB 
)
virtual

RETURN VALUES: int numNewRows – number of new rows generated int* numNonz – number of nonzeros in each row int** colIdx – vectors column indexes of new rows double** values – vectors of matrix coefficient values of new rows double* rowLB – vector of row lower bounds double* rowUB – vector of row upper bounds.

INPUT: double* thetaVar – the vector of primal master values int numThetaVar – size of master primal vector

Implements OSDecompSolver.

Definition at line 2176 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getCutsX ( const double *  xVar,
const int  numXVar,
int numNewRows,
int *&  numNonz,
int **&  colIdx,
double **&  values,
double *&  rowLB,
double *&  rowUB 
)

RETURN VALUES: int numNewRows – number of new rows generated int* numNonz – number of nonzeros in each row int** colIdx – vectors column indexes of new rows double** values – vectors of matrix coefficient values of new rows double* rowLB – vector of row lower bounds double* rowUB – vector of row upper bounds.

INPUT: double* xVar – the vector of primal values int numXVar – size of master primal vector

Definition at line 3124 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getBranchingCut ( const double *  thetaVar,
const int  numThetaVar,
const std::map< int, int > &  varConMap,
int varIdx,
int numNonz,
int *&  indexes,
double *&  values 
)
virtual

RETURN VALUES: varIdx – the variable number x_{ij} for branching numNonz – number of theta indexes in the cut indexes – the indexes of the theta variables values – the number of times the theta indexed in indexes appears in the cut note – set numNonz to zero if the generated cut variable already appears in varConMap.

INPUT: double* thetaVar – the vector of primal master values int numThetaVar – size of master primal vector varConMap – the map of variables in x_{ij} space to a consraint number

Implements OSDecompSolver.

Definition at line 4306 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getBranchingCut ( const int thetaIdx,
const double *  theta,
const int  numThetaVar,
const std::map< int, int > &  varConMap,
int varIdx,
int numNonz,
int *&  indexes,
double *&  values 
)
virtual

Sparse Version.

RETURN VALUES: varIdx – the variable number x_{ij} for branching numNonz – number of theta indexes in the cut indexes – the indexes of the theta variables values – the number of times the theta indexed in indexes appears in the cut note – set numNonz to zero if the generated cut variable already appears in varConMap

INPUT: double* theta – the vector of primal master values int numThetaVar – size of master primal vector varConMap – the map of variables in x_{ij} space to a consraint number

Implements OSDecompSolver.

Definition at line 4388 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getCutsMultiCommod ( const double *  thetaVar,
const int  numThetaVar,
int numNewRows,
int *&  numNonz,
int **&  colIdx,
double **&  values,
double *&  rowLB,
double *&  rowUB 
)
virtual

This is the routine that generates the multi-item cuts.

RETURN VALUES: int numNewRows – number of new rows generated int* numNonz – number of nonzeros in each row int** colIdx – vectors column indexes of new rows double** values – vectors of matrix coefficient values of new rows double* rowLB – vector of row lower bounds double* rowUB – vector of row upper bounds

INPUT: double* thetaVar – the vector of primal master values int numThetaVar – size of master primal vector

    kount = 0;
    for(i = 0; i < m_numNodes; i++){

            for(j = 0; j < i; j++){  //j < i



                    indexPair.first = i;
                    indexPair.second = j;
                    xVarIndexMap[ indexPair] = kount;
                    kount++;
            }

            for(j = i+1; j < m_numNodes; j++){ // i < j

                    indexPair.first = i;
                    indexPair.second = j;
                    xVarIndexMap[ indexPair] = kount;
                    kount++;
            }
    }

end construct map

Implements OSDecompSolver.

Definition at line 2558 of file OSBearcatSolverXij.cpp.

int OSBearcatSolverXij::getBranchingVar ( const double *  theta,
const int  numThetaVar 
)

RETURN VALUES: return the integer index of a fractional x_{ij} variable.

INPUT: double* theta – the vector of primal master values int numThetaVar – size of master primal vector

Definition at line 4020 of file OSBearcatSolverXij.cpp.

int OSBearcatSolverXij::getBranchingVar ( const int thetaIdx,
const double *  theta,
const int  numThetaVar 
)

Sparse Version.

RETURN VALUES: return the integer index of a fractional x_{ij} variable

INPUT: int* thetaIdx – index vector of nonzero theta variables double* theta – the sparse vector of primal master values int numThetaVar – size of master primal vector

Definition at line 4161 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getColumns ( const double *  yA,
const int  numARows,
const double *  yB,
const int  numBRows,
int numNewColumns,
int *&  numNonz,
double *&  cost,
int **&  rowIdx,
double **&  values,
double &  lowerBound 
)
virtual

RETURN VALUES: int numNewColumns – number of new columns generated int* numNonz – number of nonzeros in each column double* cost – the objective function coefficient on each new column double** rowIdx – vectors row indexes of new columns double** values – vectors of matrix coefficient values of new columns double lowerBound – the lowerBound, this is a value on the LP relaxation.

INPUT: double* y – the vector of dual values int numRows – size of dual vector

                    int ivalue;
                    int jvalue;
                    for(j = 0; j < kountVar; j++){

                            startPntInc  =  k*m_upperBoundL*(m_numNodes*m_numNodes - m_numNodes) + (m_optL[ k] - 1)*(m_numNodes*m_numNodes - m_numNodes);


                            std::cout << "Variable Index = " <<  m_varIdx[ j] - startPntInc ;
                            std::cout << "  Variable = " << m_variableNames[  m_varIdx[ j] - startPntInc ]  << std::endl ;  

tmp – get the node

tmp = fmod(m_varIdx[ j] - startPntInc, m_numNodes) ;

                            ivalue = floor( (m_varIdx[ j] - startPntInc)/(m_numNodes - 1) );
                            jvalue = (m_varIdx[ j] - startPntInc) - ivalue*(m_numNodes - 1);
                            std::cout << " i NODE NUMBER = " << ivalue  ;

                            if(  jvalue  > ivalue ){

                                    std::cout << " j NODE NUMBER = " <<  jvalue + 1   << std::endl;
                            }else{

                                    std::cout << " j NODE NUMBER = " <<  jvalue   << std::endl;
                            }


                    }

                    std::cout << "Route True Cost = " << m_costVec[ k] << std::endl;

Implements OSDecompSolver.

Definition at line 1074 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getOptions ( OSOption osoption)

Definition at line 1849 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getVariableIndexMap ( )

this method will populate: std::map<std::pair<int, int>,int>m_xVarIndexMap this gives us

Definition at line 6105 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::permuteHubs ( )

this method will calculate a permuation of the hubs so that they are in ascending order, this will make the dynamic program in the v variables faster

Definition at line 6136 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::calcReducedCost ( const double *  yA,
const double *  yB 
)

calculate the reduced costs c – input of the objective function costs yA – dual values on node assignment – coupling constraints yB – dual values on tour breaking constraints d – reduced with convexity dual value

Definition at line 3342 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::createVariableNames ( )

Definition at line 3439 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::createAmatrix ( )

Definition at line 3480 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::initializeDataStructures ( )
virtual

allocate memory and initialize arrays

m_u[i, l] – this will be the minimum cost of reaching node i on a q-route with demand l, note that m_u[ i] has dimension m_upperBoundL + 1 so the possible values for l are l = 0, 1, , m_upperBoundL – l is the actual value of demand

Implements OSDecompSolver.

Definition at line 112 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getInitialSolution ( )

generate an intitial feasible solution in theta space for the initial master

Definition at line 4474 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::resetMaster ( std::map< int, int > &  inVars,
OsiSolverInterface *  si 
)
virtual

INPUT:

Parameters
dstd::map<int,int>&inVars – the mapping of variables, the first index is the variable number before resetting, the second index is the variable number after the reset
OsiSolverInterface*si – the solver interface that corresponds to the master this is what gets rebuilt

Implements OSDecompSolver.

Definition at line 4531 of file OSBearcatSolverXij.cpp.

double OSBearcatSolverXij::getRouteDistance ( int  numNodes,
int  hubIndex,
CoinSolver solver,
std::vector< int zk,
double *  xVar 
)

call this method to get a minimum TSP tour for a given assignment of nodes to routes INPUT: int numNodes – number of cities/nodes in tour int hubIndex – indexes the hub index CoinSolver* solver – the coin solver numNodes*numNodes - numNodes entries, we are assuming zk – indexes the non-hub nodes assigned this route asymmetric

OUTPUT: xVar the optimal solution

Definition at line 4910 of file OSBearcatSolverXij.cpp.

CoinSolver * OSBearcatSolverXij::getTSP ( int  numNodes,
double *  cost 
)

call this method to get a TSP instance

INPUT: int numNodes – number of cities/nodes in tour double* cost – the cost vector, this should have

RETURN: pointer to a CoinSolver with a TSP instance

Definition at line 5109 of file OSBearcatSolverXij.cpp.

CoinSolver * OSBearcatSolverXij::getMultiCommodInstance ( int  hubIndex)

call this method to get an instance that is used to generate a multicommodity cut

INPUT: hubIndex is the index associated with the hub for which we are looking for a cut RETURN: pointer to a CoinSolver with a cut generator instance

Definition at line 5611 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::getFeasibleSolution ( )

call this method to get generate an instance of the generalized assignment problem and find a feasible solution to the problem

INPUT:

RETURN: void

Definition at line 5892 of file OSBearcatSolverXij.cpp.

bool OSBearcatSolverXij::OneOPT ( )

try and find a feasible solution, return false if solution not feasible

Definition at line 5316 of file OSBearcatSolverXij.cpp.

void OSBearcatSolverXij::pauHana ( std::vector< int > &  m_zOptIndexes,
std::vector< double > &  m_zRootLPx_vals,
int  numNodes,
int  numColsGen,
std::string  message 
)
virtual

Implements OSDecompSolver.

Definition at line 3529 of file OSBearcatSolverXij.cpp.

double OSBearcatSolverXij::calcNonlinearRelax ( std::vector< double > &  m_zRootLPx_vals)

calculate the nonlinear relaxation value for an LP solution

Definition at line 3630 of file OSBearcatSolverXij.cpp.

Member Data Documentation

std::map<int, std::string> OSBearcatSolverXij::m_tmpVarMap

Definition at line 39 of file OSBearcatSolverXij.h.

std::map<std::pair<int, int>,int> OSBearcatSolverXij::m_xVarIndexMap

m_xVarIndexMap takes a variable indexed by (i,j) and returns the index of the variable in one dimension

Definition at line 44 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_hubPoint

m_hubPoint[ k] points to the the k'th hub that we use in getOptL

Definition at line 50 of file OSBearcatSolverXij.h.

std::string OSBearcatSolverXij::m_initOSiLFile

Definition at line 53 of file OSBearcatSolverXij.h.

std::map<int, std::map<int, std::vector<int> > > OSBearcatSolverXij::m_initSolMap

the index on the outer map is on the solution number, the index on the inner map indexes the route number, the vector is the list of nodes assigned to that route

Definition at line 59 of file OSBearcatSolverXij.h.

std::vector<CoinSolver*> OSBearcatSolverXij::m_multCommodCutSolvers

m_multCommodCutSolvers is a vector of solvers, one solver for each hub, used to find multicommodity flow cuts for the given hub

Definition at line 65 of file OSBearcatSolverXij.h.

bool OSBearcatSolverXij::m_use1OPTstart

if m_use1OPTstart is true we use the option file to fix the nodes to hubs found by SK's 1OPT heuristic

Definition at line 70 of file OSBearcatSolverXij.h.

int OSBearcatSolverXij::m_maxThetaNonz

m_maxMasterNonz is the maximumn number of nonzero elements we allow in the transformation matrix betwee the theta variables and the xij variables

Definition at line 76 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_routeCapacity

the route capacity – bus seating limit this can vary with the route/hub

Definition at line 84 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_routeMinPickup

the minimum number of students that we pickup on a route this can vary with the route/hub

Definition at line 90 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_upperBoundL

largest possible L-value on a route – this will be the minimum of m_routeCapacity and total demand

Definition at line 98 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_lowerBoundL

smallest possible L-value on a route for now this will equal

Definition at line 104 of file OSBearcatSolverXij.h.

int OSBearcatSolverXij::m_upperBoundLMax

largest possible L-value over all routes

Definition at line 107 of file OSBearcatSolverXij.h.

int OSBearcatSolverXij::m_minDemand

m_minDemand is the value of the minimum demand node – it is not the minimum demand that must be carried on a route

Definition at line 113 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_demand

m_demand is the vector of node demands

Definition at line 116 of file OSBearcatSolverXij.h.

std::string* OSBearcatSolverXij::m_nodeName

m_nodeName is the vector of node names

Definition at line 119 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::m_cost

the distance/cost vectors

Definition at line 122 of file OSBearcatSolverXij.h.

bool OSBearcatSolverXij::m_costSetInOption

m_costSetInOption is true if the costs are set using the OSOption file

Definition at line 127 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_rc

the reduced cost vector for each k, we asssume order is (l, i, j)

Definition at line 132 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::m_optValHub

Definition at line 136 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_u

Definition at line 140 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_v

Definition at line 141 of file OSBearcatSolverXij.h.

int** OSBearcatSolverXij::m_px

Definition at line 142 of file OSBearcatSolverXij.h.

int** OSBearcatSolverXij::m_tx

Definition at line 143 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_g

Definition at line 144 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_varIdx

Definition at line 145 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_optL

Definition at line 150 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_optD

Definition at line 151 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_vv

Definition at line 152 of file OSBearcatSolverXij.h.

int** OSBearcatSolverXij::m_vvpnt

Definition at line 153 of file OSBearcatSolverXij.h.

int OSBearcatSolverXij::m_totalDemand

Definition at line 157 of file OSBearcatSolverXij.h.

int OSBearcatSolverXij::m_numberOfSolutions

Definition at line 158 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_tmpScatterArray

Definition at line 163 of file OSBearcatSolverXij.h.

double OSBearcatSolverXij::m_lowerBnd

Definition at line 166 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_newColumnNonz

Definition at line 167 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::m_costVec

Definition at line 168 of file OSBearcatSolverXij.h.

int** OSBearcatSolverXij::m_newColumnRowIdx

Definition at line 169 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_newColumnRowValue

Definition at line 170 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_newRowNonz

Definition at line 173 of file OSBearcatSolverXij.h.

int** OSBearcatSolverXij::m_newRowColumnIdx

Definition at line 174 of file OSBearcatSolverXij.h.

double** OSBearcatSolverXij::m_newRowColumnValue

Definition at line 175 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::m_newRowUB

Definition at line 176 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::m_newRowLB

Definition at line 177 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::branchCutIndexes

Definition at line 180 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::branchCutValues

Definition at line 181 of file OSBearcatSolverXij.h.

double* OSBearcatSolverXij::m_thetaCost

Definition at line 190 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_convexityRowIndex

m_convexityRowIndex holds the index of the convexity row that the theta columns are in.

If the theta is an artificial variable this value is -1

Definition at line 196 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_BmatrixRowIndex

m_BmatrixRowIndex holds the index of the convexity row that the constraint corresponds to, this is for the multicommodity constraints – if the constraint applies to theta regardless of k, then the value is -1

Definition at line 204 of file OSBearcatSolverXij.h.

int* OSBearcatSolverXij::m_separationIndexMap

m_separationIndexMap maps the variable index into the appropriate row in the separation problem for the tour breaking constraints

Definition at line 211 of file OSBearcatSolverXij.h.

OSInstance* OSBearcatSolverXij::m_osinstanceSeparation

Definition at line 214 of file OSBearcatSolverXij.h.

ClpSimplex* OSBearcatSolverXij::m_separationClpModel

Definition at line 217 of file OSBearcatSolverXij.h.


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