OSBearcatSolverXkij Class Reference

#include <OSBearcatSolverXkij.h>

Inheritance diagram for OSBearcatSolverXkij:

Inheritance graph
[legend]
Collaboration diagram for OSBearcatSolverXkij:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual OSInstancegetInitialRestrictedMaster ()
 OSInstance* OSBearcatSolverXkij::getInitialRestrictedMaster( ){.
OSInstancegetSeparationInstance ()
double qrouteCost (const int &k, const int &l, const double *c, int *kountVar)
 kipp -- document
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.
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.
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.
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.
int getBranchingVar (const double *theta, const int numThetaVar)
 RETURN VALUES: return the integer index of a fractional x_{ij} variable.
int getBranchingVar (const int *thetaIdx, const double *theta, const int numThetaVar)
 Sparse Version.
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.
void getOptions (OSOption *osoption)
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
void createVariableNames ()
void createAmatrix ()
virtual void initializeDataStructures ()
 allocate memory and initialize arrays
void getInitialSolution ()
 generate an intitial feasible solution in theta space for the initial master
virtual void resetMaster (std::map< int, int > &inVars, OsiSolverInterface *si)
 INPUT:.
virtual void pauHana (std::vector< int > &m_zOptIndexes, int numNodes, int numColsGen)
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.
 OSBearcatSolverXkij ()
 Default Constructor.
 OSBearcatSolverXkij (OSOption *osoption)
 Second Constructor.
 ~OSBearcatSolverXkij ()
 Default Destructor.

Public Attributes

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
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
int m_maxThetaNonz
 m_maxMasterNonz is the maximumn number of nonzero elements we allow in the transformation matrix betwee the theta variables and the xkij variables
int * m_routeCapacity
 the route capacity -- bus seating limit this can vary with the route/hub
int * m_routeMinPickup
 the minimum number of students that we pickup on a route this can vary with the route/hub
int * m_upperBoundL
 largest possible L-value on a route -- this will be the minimum of m_routeCapacity and total demand
int * m_lowerBoundL
 smallest possible L-value on a route for now this will equal
int m_upperBoundLMax
 largest possible L-value over all routes
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
int * m_demand
 m_demand is the vector of node demands
double ** m_cost
 the distance/cost vectors
double ** m_rc
 the reduced cost vector for each k, we asssume order is (l, i, j)
double * m_optValHub
double ** m_u
double ** m_v
int ** m_px
int ** m_tx
double ** m_g
int * m_varIdx
int * m_optL
int * m_optD
double ** m_vv
int ** m_vvpnt
int m_totalDemand
int m_numberOfSolutions
int * m_tmpScatterArray
double m_lowerBnd
int * m_newColumnNonz
double * m_costVec
int ** m_newColumnRowIdx
double ** m_newColumnRowValue
int * m_newRowNonz
int ** m_newRowColumnIdx
double ** m_newRowColumnValue
double * m_newRowUB
double * m_newRowLB
int * branchCutIndexes
double * branchCutValues
double * m_thetaCost
int * convexityRowIndex
 conconvexityRowIndex holds the index of the convexity row that the theta columns are in.
int * m_separationIndexMap
 m_separationIndexMap maps the variable index into the appropriate row in the separation problem for the tour breaking constraints
OSInstancem_osinstanceSeparation
ClpSimplex * m_separationClpModel

Classes

class  Factory

Detailed Description

Definition at line 31 of file OSBearcatSolverXkij.h.


Constructor & Destructor Documentation

OSBearcatSolverXkij::OSBearcatSolverXkij (  ) 

Default Constructor.

Definition at line 65 of file OSBearcatSolverXkij.cpp.

Referenced by OSBearcatSolverXkij::Factory::create().

OSBearcatSolverXkij::OSBearcatSolverXkij ( OSOption osoption  ) 

Second Constructor.

Definition at line 69 of file OSBearcatSolverXkij.cpp.

References OSDecompSolver::m_bestIPValue, OSDecompSolver::m_bestLPValue, m_cost, m_demand, m_g, m_minDemand, m_optD, m_optL, OSDecompSolver::m_osoption, m_px, m_rc, m_routeCapacity, m_routeMinPickup, m_tx, m_u, m_upperBoundL, m_upperBoundLMax, m_v, m_varIdx, m_vv, m_vvpnt, OSDBL_MAX, OSINT_MAX, and osoption.

OSBearcatSolverXkij::~OSBearcatSolverXkij (  ) 

Default Destructor.

Definition at line 313 of file OSBearcatSolverXkij.cpp.

References branchCutIndexes, branchCutValues, convexityRowIndex, OSDecompSolver::m_Amatrix, m_cost, m_costVec, m_demand, m_g, m_lowerBoundL, m_newColumnNonz, m_newColumnRowIdx, m_newColumnRowValue, m_newRowColumnIdx, m_newRowColumnValue, m_newRowLB, m_newRowNonz, m_newRowUB, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, m_optD, m_optL, m_optValHub, m_osinstanceSeparation, OSDecompSolver::m_pntAmatrix, OSDecompSolver::m_pntBmatrix, m_px, m_rc, m_routeCapacity, m_routeMinPickup, m_separationClpModel, m_separationIndexMap, m_thetaCost, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, m_tmpScatterArray, m_tx, m_u, m_upperBoundL, m_v, OSDecompSolver::m_variableNames, m_varIdx, m_vv, and m_vvpnt.


Member Function Documentation

OSInstance * OSBearcatSolverXkij::getInitialRestrictedMaster (  )  [virtual]

OSInstance* OSBearcatSolverXkij::getInitialRestrictedMaster( ){.

std::cout << "Executing OSBearcatSolverXkij::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; }

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

masterVarName = makeStringFromInt2("theta(", k); masterVarName += makeStringFromInt2(",", 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, makeStringFromInt2("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, makeStringFromInt2("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 1529 of file OSBearcatSolverXkij.cpp.

References OSInstance::addConstraint(), OSInstance::addObjective(), OSInstance::addVariable(), OSDecompParam::artVarCoeff, CoinSolver::buildSolverInstance(), OSInstance::bVariablesModified, Objective::coef, convexityRowIndex, ErrorClass::errormsg, getCutsX(), FileUtil::getFileAsString(), OSResult::getObjValue(), OSResult::getOptimalPrimalVariableValues(), OSResult::getSolutionStatusType(), OSInstance::getVariableNames(), SparseVector::indexes, OSInstance::instanceData, OSDecompSolver::intVarSet, k, OSDecompSolver::m_bestIPValue, m_cost, m_initOSiLFile, m_initSolMap, m_numberOfSolutions, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, OSDecompSolver::m_numThetaNonz, OSDecompSolver::m_numThetaVar, OSDecompSolver::m_osDecompParam, OSDecompSolver::m_osinstanceMaster, OSDecompSolver::m_osoption, m_thetaCost, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, m_use1OPTstart, OSDecompSolver::m_variableNames, makeStringFromInt2(), Objectives::obj, InstanceData::objectives, DefaultSolver::osinstance, osinstance, CoinSolver::osiSolver, DefaultSolver::osoption, DefaultSolver::osresult, OSInstance::printModel(), OSiLReader::readOSiL(), OSInstance::setConstraintNumber(), OSInstance::setInstanceDescription(), OSInstance::setLinearConstraintCoefficients(), OSInstance::setObjectiveNumber(), OSInstance::setVariableNumber(), CoinSolver::solve(), DefaultSolver::sSolverName, ObjCoef::value, SparseVector::values, Variables::var, and InstanceData::variables.

OSInstance * OSBearcatSolverXkij::getSeparationInstance (  ) 

Definition at line 3215 of file OSBearcatSolverXkij.cpp.

References OSInstance::addConstraint(), OSInstance::addObjective(), OSInstance::addVariable(), ErrorClass::errormsg, OSInstance::getConstraintLowerBounds(), OSInstance::getConstraintNumber(), OSInstance::getConstraintUpperBounds(), OSInstance::getDenseObjectiveCoefficients(), OSInstance::getLinearConstraintCoefficientNumber(), OSInstance::getLinearConstraintCoefficientsInColumnMajor(), OSInstance::getLinearConstraintCoefficientsInRowMajor(), OSInstance::getVariableLowerBounds(), OSInstance::getVariableNumber(), OSInstance::getVariableUpperBounds(), SparseMatrix::indexes, SparseVector::indexes, OSDecompSolver::m_numNodes, m_osinstanceSeparation, m_separationClpModel, m_separationIndexMap, makeStringFromInt2(), OSInstance::setConstraintNumber(), OSInstance::setInstanceDescription(), OSInstance::setLinearConstraintCoefficients(), OSInstance::setObjectiveNumber(), OSInstance::setVariableNumber(), SparseMatrix::starts, SparseMatrix::values, and SparseVector::values.

Referenced by initializeDataStructures().

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

kipp -- document

Definition at line 659 of file OSBearcatSolverXkij.cpp.

References m_demand, m_g, m_minDemand, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, m_px, m_tx, m_u, m_upperBoundL, m_v, m_varIdx, OSDBL_MAX, and OSINT_MAX.

Referenced by getColumns(), and getOptL().

void OSBearcatSolverXkij::getOptL ( double **  c  ) 

Definition at line 504 of file OSBearcatSolverXkij.cpp.

References d1, k, m_lowerBoundL, OSDecompSolver::m_numHubs, m_optD, m_optL, m_totalDemand, m_upperBoundL, m_vv, m_vvpnt, OSDBL_MAX, and qrouteCost().

Referenced by getColumns().

void OSBearcatSolverXkij::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 2361 of file OSBearcatSolverXkij.cpp.

References OSInstance::bConstraintsModified, OSInstance::getConstraintNumber(), k, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, OSDecompSolver::m_numThetaVar, OSDecompSolver::m_osDecompParam, m_osinstanceSeparation, m_separationIndexMap, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, OSINT_MAX, and OSDecompParam::zeroTol.

void OSBearcatSolverXkij::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 2743 of file OSBearcatSolverXkij.cpp.

References OSInstance::bConstraintsModified, OSInstance::getConstraintNumber(), k, OSDecompSolver::m_numNodes, OSDecompSolver::m_osDecompParam, m_osinstanceSeparation, m_separationIndexMap, OSINT_MAX, and OSDecompParam::zeroTol.

Referenced by getInitialRestrictedMaster().

void OSBearcatSolverXkij::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 3747 of file OSBearcatSolverXkij.cpp.

References branchCutIndexes, branchCutValues, convexityRowIndex, ErrorClass::errormsg, getBranchingVar(), OSDecompSolver::m_numBmatrixCon, OSDecompSolver::m_numBmatrixNonz, OSDecompSolver::m_numThetaNonz, OSDecompSolver::m_thetaIndex, and OSDecompSolver::m_variableNames.

void OSBearcatSolverXkij::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 3828 of file OSBearcatSolverXkij.cpp.

References branchCutIndexes, branchCutValues, convexityRowIndex, ErrorClass::errormsg, getBranchingVar(), OSDecompSolver::m_numBmatrixCon, OSDecompSolver::m_numBmatrixNonz, OSDecompSolver::m_numThetaNonz, OSDecompSolver::m_thetaIndex, and OSDecompSolver::m_variableNames.

int OSBearcatSolverXkij::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 3459 of file OSBearcatSolverXkij.cpp.

References OSDecompSolver::m_numNodes, OSDecompSolver::m_osDecompParam, OSDecompSolver::m_thetaIndex, and OSDecompParam::zeroTol.

Referenced by getBranchingCut().

int OSBearcatSolverXkij::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 3602 of file OSBearcatSolverXkij.cpp.

References OSDecompSolver::m_osDecompParam, OSDecompSolver::m_thetaIndex, and OSDecompParam::zeroTol.

void OSBearcatSolverXkij::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 986 of file OSBearcatSolverXkij.cpp.

References calcReducedCost(), convexityRowIndex, ErrorClass::errormsg, getOptL(), OSDecompSolver::intVarSet, k, OSDecompSolver::m_Amatrix, m_cost, m_costVec, m_lowerBnd, m_newColumnNonz, m_newColumnRowIdx, m_newColumnRowValue, OSDecompSolver::m_numBmatrixCon, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, OSDecompSolver::m_numThetaNonz, OSDecompSolver::m_numThetaVar, m_optL, m_optValHub, OSDecompSolver::m_pntAmatrix, OSDecompSolver::m_pntBmatrix, m_rc, m_thetaCost, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, m_tmpScatterArray, m_totalDemand, m_varIdx, and qrouteCost().

void OSBearcatSolverXkij::getOptions ( OSOption osoption  ) 

Definition at line 2087 of file OSBearcatSolverXkij.cpp.

References ErrorClass::errormsg, OSOption::getSolverOptions(), m_demand, m_initOSiLFile, m_initSolMap, OSDecompSolver::m_maxBmatrixCon, OSDecompSolver::m_maxBmatrixNonz, OSDecompSolver::m_maxMasterColumns, m_maxThetaNonz, m_minDemand, m_numberOfSolutions, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, m_routeCapacity, m_routeMinPickup, m_totalDemand, m_use1OPTstart, and osoption.

Referenced by getInitialSolution(), and initializeDataStructures().

void OSBearcatSolverXkij::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 2961 of file OSBearcatSolverXkij.cpp.

References m_cost, OSDecompSolver::m_numBmatrixCon, OSDecompSolver::m_numNodes, m_rc, and m_upperBoundL.

Referenced by getColumns().

void OSBearcatSolverXkij::createVariableNames (  ) 

Definition at line 3058 of file OSBearcatSolverXkij.cpp.

References OSDecompSolver::m_numNodes, OSDecompSolver::m_variableNames, and makeStringFromInt2().

Referenced by initializeDataStructures().

void OSBearcatSolverXkij::createAmatrix (  ) 

Definition at line 3095 of file OSBearcatSolverXkij.cpp.

References OSDecompSolver::m_Amatrix, OSDecompSolver::m_numNodes, and OSDecompSolver::m_pntAmatrix.

Referenced by initializeDataStructures().

void OSBearcatSolverXkij::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 104 of file OSBearcatSolverXkij.cpp.

References branchCutIndexes, branchCutValues, convexityRowIndex, createAmatrix(), createVariableNames(), ErrorClass::errormsg, getOptions(), getSeparationInstance(), k, OSDecompSolver::m_Amatrix, m_cost, m_costVec, m_g, m_lowerBoundL, OSDecompSolver::m_maxBmatrixCon, OSDecompSolver::m_maxBmatrixNonz, OSDecompSolver::m_maxMasterColumns, OSDecompSolver::m_maxMasterRows, m_maxThetaNonz, m_newColumnNonz, m_newColumnRowIdx, m_newColumnRowValue, m_newRowColumnIdx, m_newRowColumnValue, m_newRowLB, m_newRowNonz, m_newRowUB, OSDecompSolver::m_numBmatrixCon, OSDecompSolver::m_numBmatrixNonz, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, OSDecompSolver::m_numThetaNonz, OSDecompSolver::m_numThetaVar, m_optD, m_optL, m_optValHub, OSDecompSolver::m_osoption, OSDecompSolver::m_pntAmatrix, OSDecompSolver::m_pntBmatrix, m_px, m_rc, m_routeCapacity, m_routeMinPickup, m_separationIndexMap, m_thetaCost, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, m_tmpScatterArray, m_totalDemand, m_tx, m_u, m_upperBoundL, m_upperBoundLMax, m_v, OSDecompSolver::m_variableNames, m_varIdx, m_vv, m_vvpnt, OSDBL_MAX, and OSINT_MAX.

void OSBearcatSolverXkij::getInitialSolution (  ) 

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

Definition at line 3913 of file OSBearcatSolverXkij.cpp.

References ErrorClass::errormsg, getOptions(), m_initSolMap, and OSDecompSolver::m_osoption.

void OSBearcatSolverXkij::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 3939 of file OSBearcatSolverXkij.cpp.

References OSInstance::addConstraint(), OSInstance::addObjective(), OSInstance::addVariable(), OSDecompParam::artVarCoeff, convexityRowIndex, SparseVector::indexes, OSDecompSolver::intVarSet, OSDecompSolver::m_Amatrix, OSDecompSolver::m_numBmatrixCon, OSDecompSolver::m_numThetaNonz, OSDecompSolver::m_osDecompParam, OSDecompSolver::m_osinstanceMaster, OSDecompSolver::m_pntAmatrix, m_thetaCost, OSDecompSolver::m_thetaIndex, m_tmpScatterArray, makeStringFromInt2(), OSInstance::setConstraintNumber(), OSInstance::setInstanceDescription(), OSInstance::setLinearConstraintCoefficients(), OSInstance::setObjectiveNumber(), OSInstance::setVariableNumber(), and SparseVector::values.

void OSBearcatSolverXkij::pauHana ( std::vector< int > &  m_zOptIndexes,
int  numNodes,
int  numColsGen 
) [virtual]

Definition at line 3144 of file OSBearcatSolverXkij.cpp.

References ErrorClass::errormsg, OSDecompSolver::m_bestIPValue, OSDecompSolver::m_bestLPValue, OSDecompSolver::m_numBmatrixCon, m_thetaCost, OSDecompSolver::m_thetaIndex, and OSDecompSolver::m_variableNames.

void OSBearcatSolverXkij::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

Implements OSDecompSolver.


Member Data Documentation

std::string OSBearcatSolverXkij::m_initOSiLFile

Definition at line 43 of file OSBearcatSolverXkij.h.

Referenced by getInitialRestrictedMaster(), and getOptions().

std::map<int, std::map<int, std::vector<int> > > OSBearcatSolverXkij::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 49 of file OSBearcatSolverXkij.h.

Referenced by getInitialRestrictedMaster(), getInitialSolution(), and getOptions().

bool OSBearcatSolverXkij::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 58 of file OSBearcatSolverXkij.h.

Referenced by getInitialRestrictedMaster(), and getOptions().

int OSBearcatSolverXkij::m_maxThetaNonz

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

Definition at line 64 of file OSBearcatSolverXkij.h.

Referenced by getOptions(), and initializeDataStructures().

int* OSBearcatSolverXkij::m_routeCapacity

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

Definition at line 72 of file OSBearcatSolverXkij.h.

Referenced by getOptions(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_routeMinPickup

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

Definition at line 78 of file OSBearcatSolverXkij.h.

Referenced by getOptions(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_upperBoundL

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

Definition at line 86 of file OSBearcatSolverXkij.h.

Referenced by calcReducedCost(), getOptL(), initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_lowerBoundL

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

Definition at line 92 of file OSBearcatSolverXkij.h.

Referenced by getOptL(), initializeDataStructures(), and ~OSBearcatSolverXkij().

int OSBearcatSolverXkij::m_upperBoundLMax

largest possible L-value over all routes

Definition at line 95 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), and OSBearcatSolverXkij().

int OSBearcatSolverXkij::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 101 of file OSBearcatSolverXkij.h.

Referenced by getOptions(), OSBearcatSolverXkij(), and qrouteCost().

int* OSBearcatSolverXkij::m_demand

m_demand is the vector of node demands

Definition at line 104 of file OSBearcatSolverXkij.h.

Referenced by getOptions(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_cost

the distance/cost vectors

Definition at line 107 of file OSBearcatSolverXkij.h.

Referenced by calcReducedCost(), getColumns(), getInitialRestrictedMaster(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_rc

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

Definition at line 112 of file OSBearcatSolverXkij.h.

Referenced by calcReducedCost(), getColumns(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

double* OSBearcatSolverXkij::m_optValHub

Definition at line 116 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_u

Definition at line 120 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_v

Definition at line 121 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

int** OSBearcatSolverXkij::m_px

Definition at line 122 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

int** OSBearcatSolverXkij::m_tx

Definition at line 123 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_g

Definition at line 124 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_varIdx

Definition at line 125 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), OSBearcatSolverXkij(), qrouteCost(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_optL

Definition at line 130 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), getOptL(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_optD

Definition at line 131 of file OSBearcatSolverXkij.h.

Referenced by getOptL(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_vv

Definition at line 132 of file OSBearcatSolverXkij.h.

Referenced by getOptL(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

int** OSBearcatSolverXkij::m_vvpnt

Definition at line 133 of file OSBearcatSolverXkij.h.

Referenced by getOptL(), initializeDataStructures(), OSBearcatSolverXkij(), and ~OSBearcatSolverXkij().

int OSBearcatSolverXkij::m_totalDemand

Definition at line 137 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), getOptions(), getOptL(), and initializeDataStructures().

int OSBearcatSolverXkij::m_numberOfSolutions

Definition at line 138 of file OSBearcatSolverXkij.h.

Referenced by getInitialRestrictedMaster(), and getOptions().

int* OSBearcatSolverXkij::m_tmpScatterArray

Definition at line 143 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), resetMaster(), and ~OSBearcatSolverXkij().

double OSBearcatSolverXkij::m_lowerBnd

Definition at line 146 of file OSBearcatSolverXkij.h.

Referenced by getColumns().

int* OSBearcatSolverXkij::m_newColumnNonz

Definition at line 147 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), and ~OSBearcatSolverXkij().

double* OSBearcatSolverXkij::m_costVec

Definition at line 148 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), and ~OSBearcatSolverXkij().

int** OSBearcatSolverXkij::m_newColumnRowIdx

Definition at line 149 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_newColumnRowValue

Definition at line 150 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), initializeDataStructures(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_newRowNonz

Definition at line 153 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), and ~OSBearcatSolverXkij().

int** OSBearcatSolverXkij::m_newRowColumnIdx

Definition at line 154 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), and ~OSBearcatSolverXkij().

double** OSBearcatSolverXkij::m_newRowColumnValue

Definition at line 155 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), and ~OSBearcatSolverXkij().

double* OSBearcatSolverXkij::m_newRowUB

Definition at line 156 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), and ~OSBearcatSolverXkij().

double* OSBearcatSolverXkij::m_newRowLB

Definition at line 157 of file OSBearcatSolverXkij.h.

Referenced by initializeDataStructures(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::branchCutIndexes

Definition at line 160 of file OSBearcatSolverXkij.h.

Referenced by getBranchingCut(), initializeDataStructures(), and ~OSBearcatSolverXkij().

double* OSBearcatSolverXkij::branchCutValues

Definition at line 161 of file OSBearcatSolverXkij.h.

Referenced by getBranchingCut(), initializeDataStructures(), and ~OSBearcatSolverXkij().

double* OSBearcatSolverXkij::m_thetaCost

Definition at line 170 of file OSBearcatSolverXkij.h.

Referenced by getColumns(), getInitialRestrictedMaster(), initializeDataStructures(), pauHana(), resetMaster(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::convexityRowIndex

conconvexityRowIndex 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 176 of file OSBearcatSolverXkij.h.

Referenced by getBranchingCut(), getColumns(), getInitialRestrictedMaster(), initializeDataStructures(), resetMaster(), and ~OSBearcatSolverXkij().

int* OSBearcatSolverXkij::m_separationIndexMap

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

Definition at line 183 of file OSBearcatSolverXkij.h.

Referenced by getCutsTheta(), getCutsX(), getSeparationInstance(), initializeDataStructures(), and ~OSBearcatSolverXkij().

OSInstance* OSBearcatSolverXkij::m_osinstanceSeparation

Definition at line 186 of file OSBearcatSolverXkij.h.

Referenced by getCutsTheta(), getCutsX(), getSeparationInstance(), and ~OSBearcatSolverXkij().

ClpSimplex* OSBearcatSolverXkij::m_separationClpModel

Definition at line 189 of file OSBearcatSolverXkij.h.

Referenced by getSeparationInstance(), and ~OSBearcatSolverXkij().


The documentation for this class was generated from the following files:
Generated on Thu Nov 10 03:12:51 2011 by  doxygen 1.4.7