20 using std::ostringstream;
27 std::cout <<
"INSIDE OSDipBlockBearcatSolver CONSTRUCTOR" << std::endl;
32 std::cout <<
"INSIDE OSDipBlockBearcatSolver CONSTRUCTOR" << std::endl;
33 std::cout <<
"whichBlock = " <<
m_whichBlock<< std::endl;
49 std::vector<SolverOption*> solverOptions;
50 std::vector<SolverOption*>::iterator vit;
51 std::vector<int >demand;
59 for (vit = solverOptions.begin(); vit != solverOptions.end(); vit++) {
67 if( (*vit)->name.find(
"numHubs") != std::string::npos){
69 std::istringstream buffer( (*vit)->value);
71 std::cout <<
"numHubs = " << m_numHubs << std::endl;
75 if((*vit)->name.find(
"numNodes") != std::string::npos){
77 std::istringstream buffer( (*vit)->value);
79 std::cout <<
"numNodes = " << m_numNodes << std::endl;
82 if((*vit)->name.find(
"totalDemand") != std::string::npos){
84 std::istringstream buffer( (*vit)->value);
86 std::cout <<
"m_totalDemand = " << m_totalDemand << std::endl;
89 if((*vit)->name.find(
"minDemand") != std::string::npos){
91 std::istringstream buffer( (*vit)->value);
93 std::cout <<
"m_minDemand = " << m_minDemand << std::endl;
96 if( (*vit)->name.find(
"demand") != std::string::npos ){
98 std::istringstream buffer( (*vit)->value);
100 demand.push_back( tmpVal);
149 std::cout <<
"INSIDE ~OSDipBlockBearcatSolver()" << std::endl;
152 std::vector<IndexValuePair*>::iterator vit;
213 std::vector<IndexValuePair*>::iterator vit;
237 if( testVal < *optVal){
247 std::cout <<
"best reduced cost = " << *optVal << std::endl;
249 std::map<int, int> indexCount;
251 std::map<int, int>::iterator mit;
254 for(i = 0; i < kountVar; i++){
256 if( indexCount.find(
m_varIdx[ i]) == indexCount.end() ){
269 for (mit = indexCount.begin(); mit != indexCount.end(); mit++){
278 primalValPair->
value = mit->second;
279 primalValPair->
idx = mit->first;
348 int bestLastNode = 0;
379 m_u[i][l1] = *(c + k*(m_numNodes - 1) + i - 1);
394 if(
m_u[i][l] + *(c + i*(m_numNodes-1) +
k ) < rcost){
396 rcost =
m_u[i][l] + *(c + i*(m_numNodes-1) + k );
409 *(
m_varIdx + (*kountVar)++) = startPnt + bestLastNode*(m_numNodes - 1) +
k ;
410 *(
m_varIdx + (*kountVar)++) = startPnt + k*(m_numNodes - 1) + bestLastNode - 1;
422 for(l2 = lowerVal; l2 <= l; l2++){
436 if(
m_px[j][ l1 ] != i ){
439 m_g[
j][i] =
m_u[
j][ l1 ] + *(c + j*(m_numNodes-1) + i - 1) ;
446 m_g[
j][i] =
m_v[
j][ l1] + *(c + j*(m_numNodes-1) + i - 1) ;
454 if(
m_g[j][i] <
m_u[i][l2] ){
472 if(
m_px[j][ l1 ] != i ){
475 m_g[
j][i] =
m_u[
j][ l1 ] + *(c + j*(m_numNodes-1) + i ) ;
480 m_g[
j][i] =
m_v[
j][ l1] + *(c + j*(m_numNodes-1) + i ) ;
486 if(
m_g[j][i] <
m_u[i][l2] ){
504 if( (
m_g[j][i] <
m_v[i][l2] ) && (
m_px[i][l2] != j) ){
522 if(
m_u[i][l2] + *(c + i*(m_numNodes-1) + k ) < rcost){
524 rcost =
m_u[i][l2] + *(c + i*(m_numNodes-1) + k );
555 *(
m_varIdx + (*kountVar)++) = startPnt + bestLastNode*(m_numNodes - 1) +
k ;
562 currentNode = bestLastNode;
567 while(currentNode != k){
570 if(
m_px[ currentNode][ lvalue ] != successorNode){
575 successorNode = currentNode;
576 currentNode =
m_px[ currentNode][ lvalue ];
579 if(currentNode - successorNode > 0){
581 *(
m_varIdx + (*kountVar)++) = startPnt + currentNode*(m_numNodes - 1) + successorNode;
585 *(
m_varIdx + (*kountVar)++) = startPnt + currentNode*(m_numNodes - 1) + successorNode - 1 ;
594 successorNode = currentNode;
595 currentNode =
m_tx[ currentNode][ lvalue ];
597 if(currentNode - successorNode > 0){
599 *(
m_varIdx + (*kountVar)++) = startPnt + currentNode*(m_numNodes - 1) + successorNode;
603 *(
m_varIdx + (*kountVar)++) = startPnt + currentNode*(m_numNodes - 1) + successorNode - 1 ;
610 lvalue = lvalue - *(
m_demand + successorNode);
virtual void solve(double *cost, std::vector< IndexValuePair * > *solIndexValPair, double *optVal)
int m_whichBlock
m_whichBlock is the index of the subproblem we are working with
double value
value is a double that holds the value of the entity
int getVariableNumber()
Get number of variables.
OSInstance * m_osinstance
A commonly used structure holding an index-value pair.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
std::vector< SolverOption * > getSolverOptions(std::string solver_name)
Get the options associated with a given solver.
std::vector< IndexValuePair * > m_primalVals
OSDipBlockBearcatSolver()
Default Constructor.
int idx
idx holds the index of an entity (such as a variable, constraint, objective) that is part of a sparse...
The in-memory representation of an OSiL instance..
double qrouteCost(const int &k, const int &l, double *c, int *kountVar)
~OSDipBlockBearcatSolver()
Default destructor.
used for throwing exceptions.