00001
00002
00003
00004
00005
00006
00007 #ifndef LP_OLD
00008
00009 #ifndef __TABLEAU__
00010 #define __TABLEAU__
00011
00012 #include <exception>
00013 #include "MatrixDouble.h"
00014 #include "CoinPackedMatrix.hpp"
00015
00016
00017 class SpeciallyOrderedSet
00018 {
00019 public:
00020 int getType()const;
00021 int getPriority()const;
00022 int getNumberOfMembers()const;
00023 int* getColumnIndices()const;
00024 double* getDownPseudoCosts()const;
00025 double* getReferenceRow()const;
00026
00027 virtual void print()const;
00028 virtual void readFile(FILE*);
00029 virtual void writeFile(FILE*)const;
00031 SpeciallyOrderedSet();
00033 SpeciallyOrderedSet(const SpeciallyOrderedSet&);
00035 SpeciallyOrderedSet& operator=(const SpeciallyOrderedSet&);
00037 virtual ~SpeciallyOrderedSet() {gutsOfDestructor(); }
00038
00039 private:
00040 int numberofmembers;
00041 int type;
00042 int priority;
00043 int* columnindices;
00044 double* downpseudocosts;
00045 double* referencerow;
00046
00047 void gutsOfDestructor(){
00048 if(columnindices){
00049 delete [] columnindices;
00050 columnindices = NULL;
00051 }
00052 if(downpseudocosts) {
00053 delete [] downpseudocosts;
00054 downpseudocosts = NULL;
00055 }
00056 if(referencerow){
00057 delete [] referencerow;
00058 referencerow = NULL;
00059 }
00060 }
00062 template <class Type> void allocateVector(Type*& pointertovector, long int sizeofvector);
00063 };
00064
00065 template <class Type>
00066 void SpeciallyOrderedSet::allocateVector(Type*& pointertovector, long int sizeofvector){
00067 if (sizeofvector > 0)
00068 if(pointertovector== NULL){
00069 try{
00070 pointertovector= new Type[sizeofvector];
00071 }
00072 catch(exception& exceptionObject){
00073 cerr << "Exception: "<< exceptionObject.what()<<endl;
00074 cerr << "Error in "<< typeid(*this).name()<<"::allocateVector(): cannot allocate memory for Type"<< typeid(*pointertovector).name()<<"["<<sizeofvector<<"]" << endl;
00075 exit(0);
00076 }
00077 }
00078 else {
00079 delete[] pointertovector;
00080 pointertovector = NULL;
00081 try{
00082 pointertovector = new Type[sizeofvector];
00083 }
00084 catch(exception& exceptionObject){
00085 cerr << "Exception: "<< exceptionObject.what()<<endl;
00086 cerr << "Error in "<< typeid(*this).name()<<"::allocateVector(): cannot allocate memory for Type "<< typeid(*pointertovector).name()<<"["<<sizeofvector<<"]" << endl;
00087 exit(0);
00088 }
00089 }
00090 else cerr << "Warning in "<< typeid(*this).name()<<"::allocateVector(): nothing to allocate:"
00091 << "length of array of "<<typeid(*pointertovector).name()<<" is: "<<sizeofvector<<"!" << endl;
00092 }
00093
00094
00095 typedef struct
00096 { int numA;
00097 int col0;
00098 } infoPerf;
00099
00100
00101
00102 typedef struct
00103 { int rowLP;
00104 int colLP;
00105 double origV;
00106 double consV;
00107 } infoFine;
00108
00109
00110
00111 typedef struct
00112 {
00113 int colLP;
00114 int colOp;
00115 int typCr;
00116 int roYLD;
00117 int roYSM;
00118
00119 } infoTSPC;
00120
00121
00122 typedef struct
00123 { int colStv;
00124 } infoResi;
00125
00126
00127
00128 typedef struct
00129 { int brows;
00130 int bcols;
00131 MatrixDouble bctyp;
00132 MatrixDouble bzrow;
00133 MatrixDouble bmat;
00134 } matblock;
00135
00136
00137 class tableau
00138 { protected:
00139 int numblx;
00140 int trans;
00141 matblock** matblx;
00142 MatrixDouble infoblx;
00143
00144 public:
00145 tableau();
00146 virtual ~tableau()
00147 { deallocateTableau();
00148 }
00149
00150 virtual void printToScreen();
00151 virtual void allocateTableau(int, int);
00152 virtual CoinPackedMatrix getInfoBlock();
00153 virtual void setInfoBlock(CoinPackedMatrix infoblock,int nrows, int ncols);
00154 virtual void readTableauFromFile(FILE* strm,
00155 MatrixDouble& ctx, MatrixDouble& zrx, MatrixDouble& mtx, int nrows, int ncols);
00156 virtual void writeTableauIntoFile(FILE* strm,
00157 const MatrixDouble& ctx, const MatrixDouble& zrx, const MatrixDouble& mtx);
00158
00159 virtual void allocateBlock(int, int, int);
00160 virtual void readBlockFromFile(int, FILE*);
00161 virtual void writeBlockIntoFile(int, FILE*);
00162
00163 virtual int getNumBlocks();
00164 virtual int getIfTrans();
00165 virtual void writeInfoblxInFile(FILE* strm);
00166
00167 virtual void copyBlockIntoZRow(int bn, MatrixDouble& zrx, int zrxc);
00168 virtual void copyBlockIntoMatrix(int bn, MatrixDouble& mtx, int mtxr, int mtxc);
00169
00170 virtual void copyZRowIntoBlock(int bn, const MatrixDouble& zrx, int zrxc);
00171 virtual void copyMatrixIntoBlock(int bn, const MatrixDouble& mtx, int mtxr, int mtxc);
00172
00173 virtual void deallocateTableau();
00174 virtual void deallocateBlock(int);
00175
00176 };
00177
00178 #endif
00179
00180 #endif