/home/coin/SVN-release/OS-2.4.2/OS/applications/columnGen/code/OSBearcatSolverXij.h

Go to the documentation of this file.
00001 /* $Id: OSBearcatSolverXij.h 3038 2009-11-07 11:43:44Z kmartin $ */
00013 #ifndef OSBEARCATSOLVERXIJ_H
00014 #define OSBEARCATSOLVERXIJ_H
00015 
00016 #include "OSDecompSolver.h"
00017 #include "OSDecompSolverFactory.h"
00018 #include "OSInstance.h"
00019 #include "OSOption.h"
00020 #include "ClpSimplex.hpp"
00021 #include "OSCoinSolver.h"
00022 #include<map>
00023 // --------------------------------------------------------------------- //
00030 // --------------------------------------------------------------------- //
00031 class OSBearcatSolverXij : public OSDecompSolver {
00032 public:
00033         
00034         
00035 
00036 
00037 /***************** Bearcat Specific Solver Parameters ***********************/
00038         //kipp move to the method
00039         std::map<int, std::string> m_tmpVarMap;
00040         
00044         std::map<std::pair<int, int>,int>m_xVarIndexMap;
00045         
00050         int *m_hubPoint;
00051         
00052         
00053         std::string m_initOSiLFile;
00054         
00059         std::map<int, std::map<int, std::vector<int> > > m_initSolMap;
00060         
00065         std::vector<CoinSolver*> m_multCommodCutSolvers;
00066         
00070         bool m_use1OPTstart;
00071         
00076         int m_maxThetaNonz;
00077         
00078 
00079 
00080         
00084         int* m_routeCapacity;
00085         
00090         int* m_routeMinPickup;
00091         
00092         
00093         
00098         int* m_upperBoundL;
00099         
00100         
00104         int* m_lowerBoundL;
00105         
00107         int m_upperBoundLMax;
00108         
00113         int m_minDemand;
00114         
00116         int* m_demand;
00117         
00119         std::string* m_nodeName;
00120         
00122         double* m_cost;
00123 
00127         bool m_costSetInOption;
00128         
00132         double** m_rc;
00133         
00134 
00135         //will be the optimal reduced cost for each hub
00136         double* m_optValHub;
00137         
00138         
00139         //start variables for the q-route dynamic program
00140         double** m_u; 
00141         double** m_v;
00142         int** m_px;
00143         int** m_tx;
00144         double** m_g;
00145         int* m_varIdx;
00146         //end variables for the q-route  dynamic programming solution
00147         
00148         //variables for the outer dynamic program 
00149         //get the optimal l value for each route
00150         int* m_optL; //size is number of routes
00151         int* m_optD; //size is number of routes
00152         double** m_vv;
00153         int** m_vvpnt;
00154         //end of variable on the outer dynamic program
00155         
00156         
00157         int m_totalDemand;
00158         int m_numberOfSolutions;
00159         
00160         
00161         //below  is a scatter array we scatter into in order
00162         //to multiply the transformation matrix times the A matrix
00163         int* m_tmpScatterArray;
00164         
00165         //arguments for getColumns
00166         double m_lowerBnd;
00167         int* m_newColumnNonz;
00168         double* m_costVec;
00169         int** m_newColumnRowIdx;
00170         double** m_newColumnRowValue;
00171                 
00172         //arguments for getRows
00173         int* m_newRowNonz;
00174         int** m_newRowColumnIdx;
00175         double** m_newRowColumnValue;
00176         double* m_newRowUB;
00177         double* m_newRowLB;
00178         
00179         //arguments for the getBranchingCut
00180         int* branchCutIndexes;
00181         double* branchCutValues;
00182         //end arguments for the getBranchingCut
00183                 
00184 
00185         
00186 
00187         
00188         //kipp -- be carefull does m_thetaCost have
00189         // artificial variables -- it is 
00190         double* m_thetaCost;
00191         
00196         int* m_convexityRowIndex;
00197         
00198         
00204         int* m_BmatrixRowIndex;
00205         
00206 
00211         int* m_separationIndexMap;
00212         
00213         //
00214         OSInstance *m_osinstanceSeparation;
00215         
00216         //the Clp model 
00217         ClpSimplex*  m_separationClpModel;
00218 
00219         //create the initial restricted master
00220         virtual OSInstance* getInitialRestrictedMaster( );
00221 
00222         
00223         //this method generates the instance for 
00224         //separating the tour breaking constraints
00225         OSInstance* getSeparationInstance();
00226 
00228         // note -- this c vector is only for hub k
00229         double qrouteCost(const int& k, const int& l, const double* c, int* kountVar) ;
00230         
00231         //this c vector is for the entire cost vector
00232         void getOptL( double** c) ;
00233         
00234         
00248         void getCutsTheta(const  double* thetaVar, const int numThetaVar,
00249                         int &numNewRows, int*  &numNonz, int** &colIdx,
00250                         double** &values, double* &rowLB, double* &rowUB) ;     
00251         
00252         
00266         void getCutsX(const  double* xVar, const int numXVar,
00267                         int &numNewRows, int*  &numNonz, int** &colIdx,
00268                         double** &values, double* &rowLB, double* &rowUB) ;     
00269         
00270         
00289         virtual void getBranchingCut(const double* thetaVar, const int numThetaVar,
00290                         const std::map<int, int> &varConMap, int &varIdx,  int &numNonz, 
00291                         int* &indexes,  double* &values) ;      
00292         
00293         
00294         
00316         virtual void getBranchingCut(const int* thetaIdx, const double* theta, 
00317                         const int numThetaVar, const std::map<int, int> &varConMap, 
00318                         int &varIdx,  int &numNonz, int* &indexes, double* &values) ;
00319         
00320         
00321         
00337         void getCutsMultiCommod(const  double* thetaVar, const int numThetaVar,
00338                         int &numNewRows, int*  &numNonz, int** &colIdx,
00339                         double** &values, double* &rowLB, double* &rowUB) ;     
00340         
00341         
00342         
00352         int getBranchingVar(const  double* theta, const int numThetaVar ) ;     
00353         
00354         
00367         int getBranchingVar(const int* thetaIdx, const double* theta, const int numThetaVar ) ; 
00368         
00369         
00383         virtual void getColumns(const  double* yA, const int numARows,
00384                         const  double* yB, const int numBRows,
00385                         int &numNewColumns, int*  &numNonz, double* &cost, 
00386                         int** &rowIdx, double** &values, double &lowerBound) ;
00387         
00388         
00389 
00390         void getOptions( OSOption *osoption);
00391         
00397         void getVariableIndexMap();
00398         
00399         
00405         void permuteHubs();
00406         
00407         
00408         //some utility methods are below
00409         
00416         void calcReducedCost(const double* yA,  const double* yB );
00417         
00418         //these are the variable in x(i, j) space
00419         void createVariableNames( );
00420         
00421         //this is the matrix that says we must visit each node
00422         //this A matrix defines the "coupling constraints"
00423         void createAmatrix();
00424                 
00428         virtual void initializeDataStructures();
00429         
00433         void getInitialSolution();
00434                 
00435         virtual void resetMaster( std::map<int, int> &inVars, 
00436                         OsiSolverInterface *si );
00437         
00438         
00453         double getRouteDistance(int numNodes, int hubIndex, 
00454                         CoinSolver* solver, std::vector<int> zk, 
00455                         double* xVar);
00456         
00457         
00468         CoinSolver* getTSP(int numNodes, double* cost); 
00469         
00470         
00471         
00482         CoinSolver* getMultiCommodInstance(int hubIndex);
00483         
00484         
00495         void getFeasibleSolution();
00496         
00497         
00503         bool OneOPT();  
00504         
00505                 
00506         //this method gets called when we are done
00507         virtual void pauHana(std::vector<int> &m_zOptIndexes, 
00508                         std::vector<double> &m_zRootLPx_vals,
00509                         int numNodes, int numColsGen, std::string message);
00510         
00514         double calcNonlinearRelax( std::vector<double> &m_zRootLPx_vals);
00515         
00516         
00521         OSBearcatSolverXij();
00522         
00527         OSBearcatSolverXij(OSOption* osoption);
00528         
00529         
00534         ~OSBearcatSolverXij();
00535         
00536         
00537         class Factory;
00538         class Factory : public OSDecompSolverFactory{
00539                 
00540         public:
00541                 
00542                 Factory(){
00543                         
00544                 }
00545                 
00546                 ~Factory(){
00547                         
00548                 }
00549                 
00550                 OSDecompSolver* create() {  return new OSBearcatSolverXij(  osoption); };
00551                 
00552         };// end class OSDecompSolverFactory
00553         
00554 
00555 };//end class OSBearcatSolverXij
00556 
00557 #endif
00558 

Generated on Wed Nov 30 03:04:13 2011 by  doxygen 1.4.7