#include <OSColGenApp.h>
Collaboration diagram for OSColGenApp:
Public Member Functions | |
void | solveRestrictedMasterRelaxation () |
kipp -- document | |
void | getOptions (OSOption *osoption) |
bool | branchAndBound () |
return true if nothing goes wrong | |
void | solve () |
void | printTreeInfo () |
void | getInitialRestrictedMaster () |
bool | isInteger (const double *thetaVar, const int numThetaVar, const double tol) |
INPUT: double* thetaVar -- the vector of primal master values int numThetaVar -- size of master primal vector tol -- is the tolerance on 0/1. | |
void | printDebugInfo () |
void | checkNodeConsistency (const int rowIdx, const OSNode *osnode) |
void | getCuts (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 double** 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 | 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. | |
OSNode * | createChild (const OSNode *osnode, std::map< int, int > &varConMap, const int rowIdx, const double rowLB, const double rowUB) |
INPUT: OSNode* osnode -- the parent node for which we create a child std::map<int, int> varConMap -- the variable constraint map rowIdx is the index of the branching row rowLB is the lower bound of the new branching row rowUB is the upper bound of the new branching row. | |
void | createBranchingCut (const int *thetaIdx, const double *theta, const int numThetaVar, std::map< int, int > &varConMap, int &rowIdx) |
INPUT: -- sparse version int* thetaIdx -- index vector of nonzero theta variables double* theta -- the sparse vector of primal master values int numThetaVar -- size of master primal vector std::map<int, int> varConMap -- the variable constraint map. | |
void | createBranchingCut (const double *theta, const int numThetaVar, std::map< int, int > &varConMap, int &rowIdx) |
INPUT: -- dense version double* theta -- the dense vector of primal master values int numThetaVar -- size of master primal vector std::map<int, int> varConMap -- the variable constraint map. | |
void | resetMaster () |
OSColGenApp () | |
Default Constructor. | |
OSColGenApp (OSOption *osption) | |
Second Constructor. | |
~OSColGenApp () | |
Default destructor. | |
Public Attributes | |
OSDecompFactoryInitializer * | m_factoryInit |
OSDecompSolver * | m_osrouteSolver |
std::ostringstream | outStr |
OSInstance * | m_osinstanceMaster |
OSOption * | m_osoption |
OSResult * | m_osresult |
std::vector< double > | m_zRootLPx_vals |
m_zRootLPx_vals holds root node optimal LP solution nonzero values | |
std::vector< int > | m_zRootLPx_idx |
m_zRootLPx_idxs holds root node optimal LP solution nonzero indexes | |
bool | m_calledBranchAndBound |
this variable is true if we have called the branchAndBound() method | |
std::map< int, int > | m_rowIdxVarMap |
map the variable generated at a node with a variable | |
CoinSolver * | m_solver |
OsiSolverInterface * | m_si |
OSDecompParam | m_osDecompParam |
Application specific parameters. | |
int | m_numNodesGenerated |
kount the nodes generated | |
int | m_numColumnsGenerated |
kount the columns generated | |
int | m_numColumnsOld |
when m_numColumnsGenerated - m_numColumnsOld hits masterColumnResetValue we do a reset | |
std::string | m_message |
m_message is the message to the pauHana routine | |
double | m_zUB |
m_zUB is the upper bound | |
double | m_zLB |
m_zLB is the lower bound | |
double | m_zRootLP |
m_zRootLP is the value of the root LP relaxation | |
std::map< int, OSNode * > | m_nodeMap |
nodeMap is the map of nodes in the branch and bound tree | |
std::vector< int > | m_zOptIndexes |
m_zOptIndexes is the vector theta indexes corresponding to the current m_zUB | |
std::vector< int > | m_zOptRootLP |
m_zOptRootLP is the vector theta indexes corresponding to optimal LP solution at the roor tnode | |
std::map< int, int > | inVars |
double * | m_yA |
m_yA is the dual values for the initial restricted constraints | |
double * | m_yB |
m_yB is the dual for the cuts that get added | |
double * | m_theta |
m_theta is the primal values in the master | |
int | m_maxCols |
m_maxCols is the maximum number of columns we can have | |
int | m_maxRows |
m_maxRows is the maximum number of rows we can have |
Definition at line 40 of file OSColGenApp.h.
OSColGenApp::OSColGenApp | ( | ) |
OSColGenApp::OSColGenApp | ( | OSOption * | osption | ) |
Second Constructor.
Definition at line 59 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, OSDecompParam::columnLimit, OSDecompSolverFactory::factories, getOptions(), OSDecompSolver::initializeDataStructures(), m_calledBranchAndBound, m_factoryInit, m_numColumnsOld, OSDecompSolver::m_osDecompParam, m_osDecompParam, m_osinstanceMaster, OSDecompSolver::m_osoption, m_osoption, m_osrouteSolver, m_zLB, m_zUB, OSDecompParam::masterColumnResetValue, OSDecompParam::nodeLimit, OSDecompParam::optTolPerCent, OSDBL_MAX, osoption, and OSDecompParam::zeroTol.
OSColGenApp::~OSColGenApp | ( | ) |
Default destructor.
Definition at line 112 of file OSColGenApp.cpp.
References m_factoryInit, m_osinstanceMaster, and m_osrouteSolver.
void OSColGenApp::solveRestrictedMasterRelaxation | ( | ) |
kipp -- document
Definition at line 500 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, OSDecompParam::columnLimit, ErrorClass::errormsg, getColumns(), getCuts(), OSResult::getSolutionStatusType(), k, OSDecompSolver::m_bestIPValue, OSDecompSolver::m_bestLPValue, m_maxCols, m_message, OSDecompSolver::m_numBmatrixCon, m_numColumnsGenerated, OSDecompSolver::m_numHubs, OSDecompSolver::m_numNodes, m_numNodesGenerated, OSDecompSolver::m_numThetaVar, m_osDecompParam, m_osrouteSolver, m_si, m_solver, m_theta, m_yA, m_yB, m_zLB, m_zOptIndexes, m_zRootLPx_vals, m_zUB, OSDecompParam::optTolPerCent, DefaultSolver::osresult, OSDecompSolver::pauHana(), printTreeInfo(), CoinSolver::solve(), and OSDecompParam::zeroTol.
Referenced by createChild(), and solve().
void OSColGenApp::getOptions | ( | OSOption * | osoption | ) |
Definition at line 190 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, OSDecompParam::columnLimit, ErrorClass::errormsg, OSOption::getSolverOptions(), m_osDecompParam, OSDecompParam::masterColumnResetValue, OSDecompParam::nodeLimit, OSDecompParam::optTolPerCent, osoption, and OSDecompParam::zeroTol.
Referenced by OSColGenApp().
bool OSColGenApp::branchAndBound | ( | ) |
return true if nothing goes wrong
varConMap is a map that maps the index of an x_{ij} variable to the corresponding branching constraint number in the master
end temp error checking
Definition at line 801 of file OSColGenApp.cpp.
References checkNodeConsistency(), createBranchingCut(), createChild(), ErrorClass::errormsg, OSNode::lpValue, m_calledBranchAndBound, m_maxCols, m_message, m_nodeMap, m_numColumnsGenerated, m_numColumnsOld, m_numNodesGenerated, m_osDecompParam, m_si, m_theta, m_zLB, m_zUB, OSDecompParam::masterColumnResetValue, OSNode::nodeID, OSDecompParam::nodeLimit, OSDecompParam::optTolPerCent, OSDBL_MAX, OSNode::parentID, resetMaster(), OSNode::theta, OSNode::thetaIdx, OSNode::thetaNumNonz, and OSDecompParam::zeroTol.
Referenced by solve().
void OSColGenApp::solve | ( | ) |
Definition at line 269 of file OSColGenApp.cpp.
References branchAndBound(), CoinSolver::buildSolverInstance(), ErrorClass::errormsg, OSInstance::getConstraintNumber(), OSDecompSolver::intVarSet, OSDecompSolver::m_bestIPValue, OSDecompSolver::m_bestLPValue, OSDecompSolver::m_maxBmatrixCon, m_maxCols, OSDecompSolver::m_maxMasterColumns, OSDecompSolver::m_maxMasterRows, m_maxRows, m_message, m_numColumnsGenerated, m_numNodesGenerated, m_osDecompParam, m_osinstanceMaster, m_osoption, m_osrouteSolver, OSDecompSolver::m_rootLPValue, m_si, m_solver, m_theta, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, OSDecompSolver::m_variableNames, m_yA, m_yB, m_zLB, m_zOptIndexes, m_zOptRootLP, m_zRootLP, m_zRootLPx_vals, m_zUB, DefaultSolver::osinstance, CoinSolver::osiSolver, DefaultSolver::osoption, OSDecompSolver::pauHana(), printTreeInfo(), solveRestrictedMasterRelaxation(), DefaultSolver::sSolverName, and OSDecompParam::zeroTol.
Referenced by main().
void OSColGenApp::printTreeInfo | ( | ) |
Definition at line 1751 of file OSColGenApp.cpp.
References m_nodeMap, m_zLB, and OSDBL_MAX.
Referenced by solve(), and solveRestrictedMasterRelaxation().
void OSColGenApp::getInitialRestrictedMaster | ( | ) |
Definition at line 130 of file OSColGenApp.cpp.
References OSDecompSolver::getInitialRestrictedMaster(), m_osinstanceMaster, and m_osrouteSolver.
Referenced by main().
bool OSColGenApp::isInteger | ( | const double * | thetaVar, | |
const int | numThetaVar, | |||
const double | tol | |||
) |
INPUT: double* thetaVar -- the vector of primal master values int numThetaVar -- size of master primal vector tol -- is the tolerance on 0/1.
return true if the solution is integer
Definition at line 723 of file OSColGenApp.cpp.
References ErrorClass::errormsg.
Referenced by createChild().
void OSColGenApp::printDebugInfo | ( | ) |
Definition at line 756 of file OSColGenApp.cpp.
References OSDecompSolver::intVarSet, OSDecompSolver::m_numNodes, m_osrouteSolver, OSDecompSolver::m_pntBmatrix, m_si, and OSDecompSolver::m_thetaPnt.
void OSColGenApp::checkNodeConsistency | ( | const int | rowIdx, | |
const OSNode * | osnode | |||
) |
Definition at line 1785 of file OSColGenApp.cpp.
References m_osrouteSolver, m_rowIdxVarMap, OSDecompSolver::m_thetaIndex, OSDecompSolver::m_thetaPnt, OSDecompSolver::m_variableNames, OSNode::rowIdx, OSNode::rowIdxNumNonz, OSNode::rowLB, OSNode::rowUB, OSNode::theta, OSNode::thetaIdx, and OSNode::thetaNumNonz.
Referenced by branchAndBound().
void OSColGenApp::getCuts | ( | 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 double** 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
Definition at line 138 of file OSColGenApp.cpp.
References OSDecompSolver::getCutsMultiCommod(), OSDecompSolver::getCutsTheta(), m_calledBranchAndBound, OSDecompSolver::m_multiCommodCutLimit, OSDecompSolver::m_numMultCuts, and m_osrouteSolver.
Referenced by solveRestrictedMasterRelaxation().
void OSColGenApp::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.
INPUT: double* yA -- the vector of dual values on the coupling constraints int numARows -- size of the yA dual vector double* yB -- the vector of dual values on the tour breaking constaints int numBRows -- size of the yA dual vector
Definition at line 176 of file OSColGenApp.cpp.
References OSDecompSolver::getColumns(), and m_osrouteSolver.
Referenced by solveRestrictedMasterRelaxation().
OSNode * OSColGenApp::createChild | ( | const OSNode * | osnode, | |
std::map< int, int > & | varConMap, | |||
const int | rowIdx, | |||
const double | rowLB, | |||
const double | rowUB | |||
) |
INPUT: OSNode* osnode -- the parent node for which we create a child std::map<int, int> varConMap -- the variable constraint map rowIdx is the index of the branching row rowLB is the lower bound of the new branching row rowUB is the upper bound of the new branching row.
method returns a pointer to a child node if a new branching variable is found we may add that to the map so varConMap can gen
Definition at line 1055 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, isInteger(), k, OSNode::lpValue, m_numNodesGenerated, m_osDecompParam, m_si, m_theta, m_zOptIndexes, m_zUB, OSDecompParam::optTolPerCent, OSNode::reducedCostIdx, OSNode::rowIdx, OSNode::rowIdxNumNonz, OSNode::rowLB, OSNode::rowUB, solveRestrictedMasterRelaxation(), OSNode::theta, OSNode::thetaIdx, and OSDecompParam::zeroTol.
Referenced by branchAndBound().
void OSColGenApp::createBranchingCut | ( | const int * | thetaIdx, | |
const double * | theta, | |||
const int | numThetaVar, | |||
std::map< int, int > & | varConMap, | |||
int & | rowIdx | |||
) |
INPUT: -- sparse version int* thetaIdx -- index vector of nonzero theta variables double* theta -- the sparse vector of primal master values int numThetaVar -- size of master primal vector std::map<int, int> varConMap -- the variable constraint map.
RETURN:
rowIdx is the row index of the row used for branching
Definition at line 1356 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, OSDecompSolver::getBranchingCut(), m_numColumnsGenerated, m_osDecompParam, m_osrouteSolver, m_rowIdxVarMap, and m_si.
Referenced by branchAndBound().
void OSColGenApp::createBranchingCut | ( | const double * | theta, | |
const int | numThetaVar, | |||
std::map< int, int > & | varConMap, | |||
int & | rowIdx | |||
) |
INPUT: -- dense version double* theta -- the dense vector of primal master values int numThetaVar -- size of master primal vector std::map<int, int> varConMap -- the variable constraint map.
RETURN:
rowIdx is the row index of the row used for branching
std::cout << m_osrouteSolver->m_variableNames[ m_osrouteSolver->m_thetaIndex[ j] ] << " = " << theta[ thetaNumNonz] << std::endl;
Definition at line 1448 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, OSDecompSolver::getBranchingCut(), m_numColumnsGenerated, m_osDecompParam, m_osrouteSolver, m_rowIdxVarMap, and m_si.
void OSColGenApp::resetMaster | ( | ) |
Definition at line 1527 of file OSColGenApp.cpp.
References OSDecompParam::artVarCoeff, CoinSolver::buildSolverInstance(), ErrorClass::errormsg, OSInstance::getConstraintNumber(), OSInstance::getVariableNumber(), inVars, m_nodeMap, m_osDecompParam, OSDecompSolver::m_osinstanceMaster, m_osinstanceMaster, m_osoption, m_osrouteSolver, m_si, m_solver, m_theta, m_zOptIndexes, m_zOptRootLP, OSDBL_MAX, DefaultSolver::osinstance, CoinSolver::osiSolver, DefaultSolver::osoption, OSDecompSolver::resetMaster(), DefaultSolver::sSolverName, and OSDecompParam::zeroTol.
Referenced by branchAndBound().
Definition at line 46 of file OSColGenApp.h.
Referenced by checkNodeConsistency(), createBranchingCut(), getColumns(), getCuts(), getInitialRestrictedMaster(), OSColGenApp(), printDebugInfo(), resetMaster(), solve(), solveRestrictedMasterRelaxation(), and ~OSColGenApp().
std::ostringstream OSColGenApp::outStr |
Definition at line 51 of file OSColGenApp.h.
Definition at line 53 of file OSColGenApp.h.
Referenced by getInitialRestrictedMaster(), OSColGenApp(), resetMaster(), solve(), and ~OSColGenApp().
Definition at line 54 of file OSColGenApp.h.
Referenced by OSColGenApp(), resetMaster(), and solve().
Definition at line 55 of file OSColGenApp.h.
std::vector<double> OSColGenApp::m_zRootLPx_vals |
m_zRootLPx_vals holds root node optimal LP solution nonzero values
Definition at line 60 of file OSColGenApp.h.
Referenced by solve(), and solveRestrictedMasterRelaxation().
std::vector<int> OSColGenApp::m_zRootLPx_idx |
m_zRootLPx_idxs holds root node optimal LP solution nonzero indexes
Definition at line 66 of file OSColGenApp.h.
this variable is true if we have called the branchAndBound() method
Definition at line 73 of file OSColGenApp.h.
Referenced by branchAndBound(), getCuts(), and OSColGenApp().
std::map<int, int> OSColGenApp::m_rowIdxVarMap |
map the variable generated at a node with a variable
Definition at line 78 of file OSColGenApp.h.
Referenced by checkNodeConsistency(), and createBranchingCut().
Definition at line 82 of file OSColGenApp.h.
Referenced by resetMaster(), solve(), and solveRestrictedMasterRelaxation().
OsiSolverInterface* OSColGenApp::m_si |
Definition at line 84 of file OSColGenApp.h.
Referenced by branchAndBound(), createBranchingCut(), createChild(), printDebugInfo(), resetMaster(), solve(), and solveRestrictedMasterRelaxation().
Application specific parameters.
Definition at line 88 of file OSColGenApp.h.
Referenced by branchAndBound(), createBranchingCut(), createChild(), getOptions(), OSColGenApp(), resetMaster(), solve(), and solveRestrictedMasterRelaxation().
kount the nodes generated
Definition at line 91 of file OSColGenApp.h.
Referenced by branchAndBound(), createChild(), solve(), and solveRestrictedMasterRelaxation().
kount the columns generated
Definition at line 94 of file OSColGenApp.h.
Referenced by branchAndBound(), createBranchingCut(), solve(), and solveRestrictedMasterRelaxation().
when m_numColumnsGenerated - m_numColumnsOld hits masterColumnResetValue we do a reset
Definition at line 102 of file OSColGenApp.h.
Referenced by branchAndBound(), and OSColGenApp().
std::string OSColGenApp::m_message |
m_message is the message to the pauHana routine
Definition at line 105 of file OSColGenApp.h.
Referenced by branchAndBound(), solve(), and solveRestrictedMasterRelaxation().
double OSColGenApp::m_zUB |
m_zUB is the upper bound
Definition at line 108 of file OSColGenApp.h.
Referenced by branchAndBound(), createChild(), OSColGenApp(), solve(), and solveRestrictedMasterRelaxation().
double OSColGenApp::m_zLB |
m_zLB is the lower bound
Definition at line 111 of file OSColGenApp.h.
Referenced by branchAndBound(), OSColGenApp(), printTreeInfo(), solve(), and solveRestrictedMasterRelaxation().
double OSColGenApp::m_zRootLP |
m_zRootLP is the value of the root LP relaxation
Definition at line 114 of file OSColGenApp.h.
Referenced by solve().
std::map<int, OSNode*> OSColGenApp::m_nodeMap |
nodeMap is the map of nodes in the branch and bound tree
Definition at line 119 of file OSColGenApp.h.
Referenced by branchAndBound(), printTreeInfo(), and resetMaster().
std::vector<int> OSColGenApp::m_zOptIndexes |
m_zOptIndexes is the vector theta indexes corresponding to the current m_zUB
Definition at line 125 of file OSColGenApp.h.
Referenced by createChild(), resetMaster(), solve(), and solveRestrictedMasterRelaxation().
std::vector<int> OSColGenApp::m_zOptRootLP |
m_zOptRootLP is the vector theta indexes corresponding to optimal LP solution at the roor tnode
Definition at line 132 of file OSColGenApp.h.
Referenced by resetMaster(), and solve().
std::map<int, int> OSColGenApp::inVars |
double* OSColGenApp::m_yA |
m_yA is the dual values for the initial restricted constraints
Definition at line 141 of file OSColGenApp.h.
Referenced by solve(), and solveRestrictedMasterRelaxation().
double* OSColGenApp::m_yB |
m_yB is the dual for the cuts that get added
Definition at line 144 of file OSColGenApp.h.
Referenced by solve(), and solveRestrictedMasterRelaxation().
double* OSColGenApp::m_theta |
m_theta is the primal values in the master
Definition at line 147 of file OSColGenApp.h.
Referenced by branchAndBound(), createChild(), resetMaster(), solve(), and solveRestrictedMasterRelaxation().
m_maxCols is the maximum number of columns we can have
Definition at line 150 of file OSColGenApp.h.
Referenced by branchAndBound(), solve(), and solveRestrictedMasterRelaxation().
m_maxRows is the maximum number of rows we can have
Definition at line 153 of file OSColGenApp.h.
Referenced by solve().