25 #include "OSInstance.h"
31 #ifdef COIN_HAS_COUENNE
46 using std::ostringstream;
52 m_osinstanceMaster(NULL) {
53 std::cout <<
"INSIDE OSColGenApp CONSTRUCTOR" << std::endl;
59 std::cout <<
"INSIDE OSColGenApp CONSTRUCTOR" << std::endl;
86 std::cout <<
"CREATE THE FACTORY " << std::endl;
88 std::cout <<
"FINISH FACTORY CREATION " << std::endl;
89 std::cout <<
"SET FACTORY OPTION " << std::endl;
91 std::cout <<
"FINISH SET FACTORY OPTION " << std::endl;
113 std::cout <<
"INSIDE ~OSColGenApp DESTRUCTOR" << std::endl;
138 int &numNewRows,
int* &numNonz,
int** &colIdx,
139 double** &
values,
double* &rowLB,
double* &rowUB) {
142 numNewRows, numNonz, colIdx, values, rowLB, rowUB);
149 numNewRows, numNonz, colIdx, values, rowLB, rowUB);
176 const double* yB,
const int numBRows,
177 int &numNewColumns,
int* &numNonz,
double* &cost,
178 int** &rowIdx,
double** &
values,
double &lowerBound) {
181 yB, numBRows, numNewColumns, numNonz,
182 cost, rowIdx, values, lowerBound);
196 std::vector<SolverOption*> solverOptions;
197 std::vector<SolverOption*>::iterator vit;
200 if (solverOptions.size() == 0)
throw ErrorClass(
"options for OSDecompSolver not available");
203 for (vit = solverOptions.begin(); vit != solverOptions.end(); vit++) {
205 if((*vit)->name.find(
"columnLimit") != std::string::npos){
208 std::istringstream columnLimitBuffer( (*vit)->value);
214 if( (*vit)->name.find(
"artVarCoeff") != std::string::npos ){
216 std::istringstream artVarCoeffBuffer( (*vit)->value);
222 if( (*vit)->name.find(
"zeroTol") != std::string::npos){
224 std::istringstream zeroTolBuffer( (*vit)->value);
231 if( (*vit)->name.find(
"nodeLimit") != std::string::npos){
233 std::istringstream nodeLimitBuffer( (*vit)->value);
239 if( (*vit)->name.find(
"masterColumnResetValue") != std::string::npos){
241 std::istringstream masterColumnResetValueBuffer( (*vit)->value);
246 if( (*vit)->name.find(
"optTolPerCent") != std::string::npos){
248 std::istringstream optTolPerCentBuffer( (*vit)->value);
274 int *new_cbasis = NULL;
278 std::set<std::pair<int, double> >::iterator sit;
279 std::vector<int>::iterator vit;
280 std::map<int, int>::iterator mit;
293 std::cout <<
" m_zUB " <<
m_zUB << std::endl;
333 numCols =
m_si->getNumCols();
334 numRows =
m_si->getNumRows();
337 cbasis =
new int[ numCols];
338 rbasis =
new int[ numRows ];
339 m_si->getBasisStatus( cbasis, rbasis);
341 for(i = 0; i < numCols; i++){
352 std::cout <<
"x variables for column " << i << std::endl;
364 std::cout <<
"optimal LP value at root node = " <<
m_zLB << std::endl;
373 m_si->setInteger( sit->first);
377 CbcModel model( *
m_si);
378 OsiSolverInterface *ipSolver = model.solver();
379 std::cout <<
"start solving master as integer program " << std::endl;
380 ipSolver->branchAndBound();
381 std::cout <<
"done solving master as integer program " << std::endl;
385 if( ipSolver->getObjValue() <
m_zUB)
m_zUB = ipSolver->getObjValue() ;
388 numCols =
m_si->getNumCols();
390 for(i = 0; i < numCols; i++){
404 m_si->setContinuous( sit->first);
405 m_si->setColUpper( sit->first, sit->second);
409 std::cout <<
"OPTIMAL LP VALUE = " <<
m_zLB << std::endl;
410 std::cout <<
"CURRENT BEST IP VALUE = " <<
m_zUB << std::endl;
435 std::cout <<
"START BRANCH AND BOUND = " << std::endl;
441 std::cout <<
"FINISH BRANCH AND BOUND = " << std::endl;
464 if(new_cbasis != NULL)
delete[] new_cbasis;
487 if(new_cbasis != NULL)
delete[] new_cbasis;
528 int* numRowNonz = NULL;
530 double** rowValues = NULL ;
549 while(isCutAdded ==
true ){
553 std::cout <<
"CALL Solve " <<
" Number of columns = " <<
m_si->getNumCols() << std::endl;
562 std::cout <<
"m_si->getNumRows() = " <<
m_si->getNumRows() << std::endl;
563 std::cout <<
"numARows = " << numARows << std::endl;
565 throw ErrorClass(
"detect a row number inconsistency in solveRestrictedMasterRelaxation");
570 if(
m_si->getRowPrice() == NULL )
571 throw ErrorClass(
"problem getting dual values in solveRestrictedMasterRelaxation");
576 for(i = 0; i < numARows; i++){
578 *(
m_yA + i) =
m_si->getRowPrice()[ i];
582 for(i = numARows; i < numARows + numBRows; i++){
584 *(
m_yB + i - numARows) =
m_si->getRowPrice()[ i];
598 numNonz, cost, rowIdx, values, lowerBound);
600 std::cout <<
"Lower Bound = " << lowerBound << std::endl;
604 for(k = 0; k < numNewColumns; k++){
606 m_si->addCol( numNonz[ k], rowIdx[k], values[k],
607 collb, colub, cost[ k]) ;
614 std::cout <<
" OBJ VALUE = " <<
m_si->getObjValue() << std::endl;
616 std::cout <<
"m_zUB = " <<
m_zUB << std::endl;
620 std::cout << std::endl << std::endl << std::endl;
621 std::cout <<
"CALL Solve " <<
" Number of columns = " <<
m_si->getNumCols() << std::endl;
625 std::cout <<
"Number of solver interface columns = " <<
m_si->getNumCols() << std::endl;
628 numCols =
m_si->getNumCols();
633 m_message =
" ***** COLUMN LIMIT EXCEEDED -- INSIDE solveRestrictedMasterRelaxation ****";
642 for(i = 0; i < numARows; i++){
644 *(
m_yA + i) =
m_si->getRowPrice()[ i];
648 for(i = numARows; i < numARows + numBRows; i++){
650 *(
m_yB + i - numARows) =
m_si->getRowPrice()[ i];
660 numCols =
m_si->getNumCols();
661 for(i=0; i < numCols; i++){
671 colIdx,rowValues, rowLB, rowUB);
674 if( numNewRows >= 1 ){
678 for(i = 0; i < numNewRows; i++){
680 m_si->addRow(numRowNonz[ i], colIdx[ i], rowValues[ i], rowLB[ i], rowUB[ i] ) ;
688 rowArtIdx =
m_si->getNumRows() - 1;
694 m_si->addCol(1, &rowArtIdx, &rowArtVal, 0, 1, bigM);
699 std::cout << std::endl;
700 std::cout <<
"CUTS WERE ADDED CALL SOLVE" << std::endl;
732 for(i = 0; i < numThetaVar; i++){
734 if( (thetaVar[ i] > tol) && (thetaVar[ i] < 1 - tol) ){
759 std::set<std::pair<int, double> >::iterator sit;
762 numCols =
m_si->getNumCols();
765 for(i = 0; i < numCols; i++){
767 std::cout <<
"PROCESSING THETA COLUMN " << i <<
" value = " <<
m_si->getColSolution()[i] << std::endl;
776 numRows =
m_si->getNumRows();
780 std::cout <<
"PROCESSING ROW " << i << std::endl;
808 std::map<int, int> varConMap;
810 std::vector<OSNode*> nodeVec;
811 std::vector<OSNode*>::iterator vit;
814 std::map<int, OSNode*>::iterator mit;
816 double bestNodeBound;
820 OSNode *osnodeLeftChild = NULL;
821 OSNode *osnodeRightChild = NULL;
829 bool leftNodeCreated =
false;
830 bool rightNodeCreated =
false;
837 numCols =
m_si->getNumCols();
853 osnodeLeftChild =
createChild(osnode, varConMap, rowIdx, 1, 1);
854 if(osnodeLeftChild != NULL){
861 m_nodeMap.insert ( std::pair<int, OSNode*>(osnodeLeftChild->
nodeID, osnodeLeftChild) );
869 osnodeRightChild =
createChild(osnode, varConMap, rowIdx, 0, 0);
870 if(osnodeRightChild != NULL){
877 m_nodeMap.insert ( std::pair<int, OSNode*>(osnodeRightChild->
nodeID, osnodeRightChild) );
885 std::cout <<
"ENTERING THE WHILE IN BRANCH AND BOUND" << std::endl;
891 m_message =
"******* NODE LIMIT EXCEEDED *******";
897 m_message =
"******* COLUMN LIMIT EXCEEDED *******";
907 std::cout <<
"DOING A MASTER RESET IN BRANCH AND BOUND" << std::endl;
908 std::cout <<
"NUMBER OF COLUMNS BEFORE RESET = " <<
m_si->getNumCols() << std::endl;
910 std::cout <<
"NUMBER OF COLUMNS AFTER RESET = " <<
m_si->getNumCols() << std::endl;
917 leftNodeCreated =
false;
918 rightNodeCreated =
false;
935 if( mit->second->lpValue < bestNodeBound) {
937 bestNodeBound = mit->second->lpValue;
938 bestNodeID = mit->first;
948 if(mit ==
m_nodeMap.end() )
throw ErrorClass(
"a node selection problem in branch and bound");
949 osnode = mit->second;
955 std::cout <<
"CREATE A BRANCHING CUT " << std::endl;
973 std::cout <<
"BEST NODE ID " << bestNodeID << std::endl;
974 std::cout <<
"NODE LP VALUE = " << osnode->
lpValue << std::endl;
980 osnodeLeftChild =
createChild(osnode, varConMap, rowIdx, 1, 1);
981 if(osnodeLeftChild != NULL){
987 leftNodeCreated =
true;
991 osnodeRightChild =
createChild(osnode, varConMap, rowIdx, 0, 0);
992 if(osnodeRightChild != NULL){
998 rightNodeCreated =
true;
1009 if( leftNodeCreated ==
true)
1010 m_nodeMap.insert ( std::pair<int, OSNode*>(osnodeLeftChild->
nodeID, osnodeLeftChild) ) ;
1012 if( rightNodeCreated ==
true)
1013 m_nodeMap.insert ( std::pair<int, OSNode*>(osnodeRightChild->
nodeID, osnodeRightChild) ) ;
1019 std::cout <<
"FATHAM BY UPPER BOUND " << std::endl;
1055 const int rowIdx,
const double rowLB,
const double rowUB){
1067 std::map<int, int>::iterator mit;
1073 int childRowIdxNumNonz;
1074 childRowIdxNumNonz = 0;
1083 if(osnodeParent != NULL) childRowIdxNumNonz = osnodeParent->
rowIdxNumNonz + 1;
1084 else childRowIdxNumNonz = 1;
1088 if(osnodeParent != NULL){
1092 m_si->setRowLower( osnodeParent->
rowIdx[ i], osnodeParent->
rowLB[ i]);
1093 m_si->setRowUpper( osnodeParent->
rowIdx[ i], osnodeParent->
rowUB[ i]);
1099 m_si->setRowLower( rowIdx, rowLB);
1100 m_si->setRowUpper( rowIdx, rowUB);
1108 std::cout <<
"CALL SOLVE FROM CREATE CHILD " << std::endl;
1110 if(osnodeParent != NULL){
1112 tmpColNum =
m_si->getNumCols() ;
1113 tmpRowNum =
m_si->getNumRows() ;
1114 int *tmpColParent =
new int[ tmpColNum];
1115 int *tmpRowParent =
new int[ tmpRowNum ];
1117 for(k = 0; k < tmpColNum; k++){
1119 if(
m_si->getObjCoefficients()[
k] >=
1121 tmpColParent[ k ] = 3;
1124 else tmpColParent[
k] = 0;
1128 for(k = 0; k < tmpRowNum; k++){
1130 tmpRowParent[
k] = 0;
1147 m_si->setBasisStatus(tmpColParent, tmpRowParent);
1176 delete[] tmpColParent;
1177 tmpColParent = NULL;
1178 delete[] tmpRowParent;
1179 tmpRowParent = NULL;
1189 std::cout << std::endl << std::endl;
1190 std::cout <<
"FINISH SOLVING THE MASTER " << std::endl;
1196 if( osnodeParent != NULL){
1200 m_si->setRowLower( osnodeParent->
rowIdx[ i], 0);
1201 m_si->setRowUpper( osnodeParent->
rowIdx[ i], 1);
1207 m_si->setRowLower( rowIdx, 0);
1208 m_si->setRowUpper( rowIdx, 1);
1213 std::cout << std::endl << std::endl;
1214 std::cout <<
"MESSAGE: START CREATION OF A CHILD NODE" << std::endl;
1215 std::cout <<
"LB " << rowLB <<
" UB = " << rowUB << std::endl;
1216 std::cout <<
"MESSAGE: LP RELAXATION VALUE OF POTENTIAL CHILD NODE " <<
m_si->getObjValue() << std::endl;
1217 std::cout <<
"MESSAGE: OPTIMALITY STATUS OF NODE IS " <<
m_si->isProvenOptimal() << std::endl;
1221 std::cout <<
"MESSAGE: WE CANNOT FATHOM THE CHILD BASED ON UPPER BOUND " << std::endl;
1222 numCols =
m_si->getNumCols();
1223 numRows =
m_si->getNumRows();
1226 for(i = 0; i < numCols; i++){
1234 std::cout <<
"MESSAGE: WE HAVE AN INTEGRALITY FATHOM " <<
m_zUB << std::endl;
1241 for(i = 0; i < numCols; i++){
1250 std::cout <<
"MESSAGE: WE ARE CREATING A CHILD NODE WITH NUMBER COLUMNS = "<< numCols << std::endl;
1251 osnodeChild =
new OSNode(childRowIdxNumNonz, thetaNumNonz );
1283 if(osnodeParent == NULL){
1284 osnodeChild->
rowIdx[ 0] = rowIdx;
1286 else osnodeChild->
rowLB[ 0] = 1;
1289 else osnodeChild->
rowUB[ 0] = 1;
1297 osnodeChild->
rowLB[ i] = osnodeParent->
rowLB[ i];
1298 osnodeChild->
rowUB[ i] = osnodeParent->
rowUB[ i];
1303 osnodeChild->
rowIdx[ childRowIdxNumNonz - 1] = rowIdx;
1308 else osnodeChild->
rowLB[ childRowIdxNumNonz - 1 ] = 1;
1311 else osnodeChild->
rowUB[ childRowIdxNumNonz - 1 ] = 1;
1320 for(i = 0; i < numCols; i++){
1324 osnodeChild->
thetaIdx[ thetaNumNonz] = i;
1342 std::cout << std::endl << std::endl;
1356 const int numThetaVar, std::map<int, int> &varConMap,
int &rowIdx){
1376 std::map<int, int>::iterator mit;
1385 varConMap, varIdx, numNonz, indexes, values);
1407 m_si->addRow(numNonz, indexes, values, 0, 1) ;
1412 rowIdx =
m_si->getNumRows() - 1;
1418 m_si->addCol(1, &rowIdx, &rowArtVal, 0, 1.0, bigM);
1423 varConMap.insert( std::pair<int, int>(varIdx , rowIdx) );
1434 mit = varConMap.find( varIdx);
1435 if( mit == varConMap.end() )
throw ErrorClass(
"in branchAndBound getBranchingCut() returned inconsistent value for varIdx");
1436 else rowIdx = mit->second;
1448 const int numThetaVar, std::map<int, int> &varConMap,
int &rowIdx){
1460 std::map<int, int>::iterator mit;
1464 varConMap, varIdx, numNonz, indexes, values);
1467 std::cout <<
"varIDX2 = " << varIdx << std::endl;
1468 std::cout <<
"numNonz2 = " << numNonz << std::endl;
1487 m_si->addRow(numNonz, indexes, values, 0, 1) ;
1492 rowIdx =
m_si->getNumRows() - 1;
1499 m_si->addCol(1, &rowIdx, &rowArtVal, 0, 1.0, bigM);
1504 varConMap.insert ( std::pair<int,int>(varIdx , rowIdx) );
1514 mit = varConMap.find( varIdx);
1515 if( mit == varConMap.end() )
throw ErrorClass(
"in branchAndBound getBranchingCut() returned inconsistent value for varIdx");
1516 else rowIdx = mit->second;
1532 std::map<int, int>::iterator mit;
1533 std::set<int>::iterator sit;
1534 std::vector<int>::iterator vit;
1535 std::vector<std::pair<int, int> >::iterator vit2;
1536 std::map<int, OSNode*>::iterator mit2;
1555 inVars.insert( std::pair<int, int>(*vit, kount++) );
1564 if(
inVars.find( *vit ) ==
inVars.end() )
inVars.insert( std::pair<int, int>(*vit, kount++) );
1580 std::cout <<
"NUMBER OF REDUCED COSTS = " << mit2->second->reducedCostIdx.size() << std::endl;
1581 for(sit = mit2->second->reducedCostIdx.begin();
1582 sit != mit2->second->reducedCostIdx.end(); sit++){
1586 && (
m_si->getReducedCost()[*sit] < tmpEps )
1588 inVars.insert( std::pair<int, int>(*sit, kount++) );
1594 for(i = 0; i < mit2->second->thetaNumNonz; i++){
1596 if(
inVars.find( mit2->second->thetaIdx[ i] ) ==
inVars.end() )
1598 inVars.insert( std::pair<int, int>(mit2->second->thetaIdx[ i], kount++) );
1607 std::cout <<
"NUMBER OF COLUMNS = " <<
inVars.size() << std::endl;
1608 std::cout <<
"CALLING osroute solver reset " << std::endl;
1614 int numVars =
m_si->getNumCols();
1615 double *tmpVals = NULL;
1616 tmpVals =
new double[ numVars];
1618 for(i = 0; i < numVars; i++) tmpVals[ i ] = 0;
1622 tmpVals[ mit->second] =
m_theta[ mit->first] ;
1626 for(i = 0; i < numVars; i++)
m_theta[ i] = tmpVals[ i] ;
1633 for(i = 0; i < mit2->second->thetaNumNonz; i++){
1636 if(
inVars.find( mit2->second->thetaIdx[ i] ) ==
inVars.end() )
throw ErrorClass(
"index problem in resetMaster");
1639 mit2->second->thetaIdx[ i] =
inVars[ mit2->second->thetaIdx[ i] ] ;
1646 for(vit2 = mit2->second->colBasisStatus.begin();
1647 vit2 != mit2->second->colBasisStatus.end(); vit2++){
1649 (*vit2).first =
inVars[ (*vit2).first ] ;
1655 std::set<int> tmpSet;
1656 for(sit = mit2->second->reducedCostIdx.begin();
1657 sit != mit2->second->reducedCostIdx.end(); sit++){
1659 tmpSet.insert(
inVars[ *sit ] );
1662 mit2->second->reducedCostIdx.clear();
1664 for(sit = tmpSet.begin(); sit != tmpSet.end(); sit++){
1669 mit2->second->reducedCostIdx.insert( *sit );
1702 throw ErrorClass(
"there is an inconsistency in the the model rebuid in resetMaster");
1706 std::cout <<
"SOLVER INTERFACE NUMBER OF COLUMNS = " <<
m_si->getNumCols() << std::endl;
1707 std::cout <<
"SOLVER INTERFACE NUMBER OF ROWS = " <<
m_si->getNumRows() << std::endl;
1720 for(i = 0; i < mit2->second->thetaNumNonz; i++){
1722 lpVal +=
m_si->getObjCoefficients()[ mit2->second->thetaIdx[ i] ]*mit2->second->theta[ i];
1752 std::map<int, OSNode*>::iterator mit;
1755 std::cout << std::endl << std::endl;
1757 std::cout <<
"NUMBER OF REMAINING DANGLING NODES = " <<
m_nodeMap.size() << std::endl;
1764 std::cout <<
"NODE ID VALUE = " << mit->second->nodeID <<
" " ;
1765 std::cout <<
" NODE LP VALUE = " << mit->second->lpValue << std::endl;
1767 for(i = 0; i < mit->second->rowIdxNumNonz; i++){
1769 std::cout <<
"CONSTRAINT = " << mit->second->rowIdx[ i] ;
1770 std::cout <<
" CONSTRAINT LB = " << mit->second->rowLB[ i] ;
1771 std::cout <<
" CONSTRAINT UB = " << mit->second->rowUB[ i] << std::endl;
1774 if( mit->second->lpValue <
m_zLB)
m_zLB = mit->second->lpValue;
1786 if( osnode == NULL)
return;
1788 std::set<int> indexSet;
1791 int rowIdxNumNonz = 0;
1792 int thetaNumNonz = 0;
1795 std::map<int, double> varSumMap;
1797 std::cout <<
"MESSAGE: CHECKING FOR NODE CONSISTENCY CONSTRAINT" << std::endl;
1799 for(i = 0; i < thetaNumNonz; i++){
1803 std::cout <<
"theta idx " << osnode->
thetaIdx[ i] <<
" theta value " << osnode->
theta[ i] << std::endl;
1825 for(i = 0; i < rowIdxNumNonz; i++){
1827 std::cout <<
" row number " << osnode->
rowIdx[ i] <<
" LB = " << osnode->
rowLB[ i] <<
" UB = "
1828 << osnode->
rowUB[ i] ;
1834 std::cout <<
" variable sum = " << varSumMap[
m_rowIdxVarMap[ osnode->
rowIdx[ i] ]] << std::endl ;
1836 if(indexSet.find( osnode->
rowIdx[ i] ) == indexSet.end() ){
1838 indexSet.insert( osnode->
rowIdx[ i] );
1843 throw ErrorClass(
"We are trying to add an existing constraint to a node" );
double * m_yB
m_yB is the dual for the cuts that get added
virtual void getCutsTheta(const double *thetaVar, const int numThetaVar, int &numNewRows, int *&numNonz, int **&colIdx, double **&values, double *&rowLB, double *&rowUB)=0
RETURN VALUES:
void getOptions(OSOption *osoption)
std::string m_message
m_message is the message to the pauHana routine
void solveRestrictedMasterRelaxation()
kipp – document
int m_maxMasterRows
m_maxMasterColumns is the maximumn number of rows we allow in the master, in this application it is e...
std::vector< int > m_zOptIndexes
m_zOptIndexes is the vector theta indexes corresponding to the current m_zUB
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 eac...
std::string getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index...
std::vector< int > m_zOptRootLP
m_zOptRootLP is the vector theta indexes corresponding to optimal LP solution at the roor tnode ...
OSColGenApp()
Default Constructor.
int getVariableNumber()
Get number of variables.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
bool m_calledBranchAndBound
this variable is true if we have called the branchAndBound() method
double * rowUB
rowUB is a vector of row upper bounds
OSDecompFactoryInitializer * m_factoryInit
OsiSolverInterface * osiSolver
osiSolver is the osi solver object – in this case clp, glpk, cbc, cplex, symphony or dylp ...
std::vector< SolverOption * > getSolverOptions(std::string solver_name)
Get the options associated with a given solver.
int m_numColumnsGenerated
kount the columns generated
double m_zUB
m_zUB is the upper bound
OSInstance * m_osinstanceMaster
int masterColumnResetValue
when the number of columns in the master hits masterColumnResetValue do a column purge ...
double * m_yA
m_yA is the dual values for the initial restricted constraints
~OSColGenApp()
Default destructor.
OSDecompParam m_osDecompParam
Application specific parameters.
OSResult * osresult
osresult holds the solution or result of the model in-memory as an OSResult object ...
int m_numBmatrixCon
m_numBmatrixCon is the number of constraints in B - 1, we have the -1 because: m_pntBmatrix[ k] point...
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 ...
double optTolPerCent
we fathom a node if UB*(1 - optTolPerCent) <= LB
virtual void buildSolverInstance()
The implementation of the corresponding virtual function.
OsiSolverInterface * m_si
int thetaNumNonz
thetaNumNonz is the number of non-zero elements in the theta variable solution at this node ...
int m_numNodesGenerated
kount the nodes generated
double m_zRootLP
m_zRootLP is the value of the root LP relaxation
int m_maxCols
m_maxCols is the maximum number of columns we can have
int * thetaIdx
theta is an array of primal solution variable indexes
std::set< int > reducedCostIdx
reducedCostVec will hold variables within a tolerance on their reduced costs.
OSDecompSolver * m_osrouteSolver
virtual void getCutsMultiCommod(const double *thetaVar, const int numThetaVar, int &numNewRows, int *&numNonz, int **&colIdx, double **&values, double *&rowLB, double *&rowUB)=0
This is the routine that generates the multi-item cuts.
void getInitialRestrictedMaster()
OSInstance * m_osinstanceMaster
int rowIdxNumNonz
rowIdxNumNonz is the number of non-zero elements in rowIndex
int nodeID
nodeID is the node ID
int m_numColumnsOld
when m_numColumnsGenerated - m_numColumnsOld hits masterColumnResetValue we do a reset ...
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 sec...
int parentID
parentID is the node ID of the parent
OSOption * osoption
osoption holds the solver options in-memory as an OSOption object
std::map< int, int > m_rowIdxVarMap
map the variable generated at a node with a variable
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)=0
RETURN VALUES:
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
virtual void initializeDataStructures()=0
allocate memory and initialize arrays
double m_zLB
m_zLB is the lower bound
int m_multiCommodCutLimit
int columnLimit
columnLimit is the limit on the number of columns that can be generated in a single call to solveRest...
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 s...
int getConstraintNumber()
Get number of constraints.
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
virtual void pauHana(std::vector< int > &m_zOptIndexes, std::vector< double > &m_zRootLPx_vals, int numNodes, int numColsGen, std::string message)=0
static std::map< std::string, OSDecompSolverFactory * > factories
std::vector< double > m_zRootLPx_vals
m_zRootLPx_vals holds root node optimal LP solution nonzero values
double * theta
theta is an array of primal positive values this is used for branching and creating new children node...
Implements a solve method for the Coin solvers.
int m_numNodes
m_numNodes is the number of nodes (both pickup and hub) in the model
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 – th...
void checkNodeConsistency(const int rowIdx, const OSNode *osnode)
std::map< int, int > inVars
double * m_theta
m_theta is the primal values in the master
double * rowLB
rowLB is a vector of row lower bounds
virtual void getBranchingCut(const double *thetaVar, const int numThetaVar, const std::map< int, int > &varConMap, int &varIdx, int &numNonz, int *&indexes, double *&values)=0
Dense Version.
bool branchAndBound()
the method that invokes and controls branch and bound
std::string * m_variableNames
virtual void resetMaster(std::map< int, int > &inVars, OsiSolverInterface *si)=0
INPUT:
double lpValue
lpValue is the LP relaxation for the node
virtual void solve()
The implementation of the corresponding virtual function.
double zeroTol
we terminate column generation when the reduced costs are not smaller than zeroTol ...
std::map< int, OSNode * > m_nodeMap
nodeMap is the map of nodes in the branch and bound tree
OSDecompParam m_osDecompParam
share the parameters with the decomposition solver
used for throwing exceptions.
int m_maxRows
m_maxRows is the maximum number of rows we can have
int m_numHubs
m_numHubs is the number of hubs/routes
int m_maxMasterColumns
m_maxMasterColumns is the maximumn number of columns we allow in the master
int m_maxBmatrixCon
m_maxBmatrixCon is the maximum number of B matrix constraints it is the number of tour breaking const...
virtual OSInstance * getInitialRestrictedMaster()=0
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 ...
int nodeLimit
nodeLimit is the limit on the number of nodes that are allowed in the branch and bound tree ...
int * rowIdx
rowIdx is a vector of row indexes for which we are setting the upper and lower bounds ...
double artVarCoeff
artVarCoeff is the coefficient of the artificial variable in the objective function ...