00001
00002
00003
00004
00005
00006
00007 #ifndef LP_OLD
00008 #ifndef OSIOSLSOLVERMIPHANDLERINTERFACE_H_
00009 #define OSIOSLSOLVERMIPHANDLERINTERFACE_H_
00010
00011
00012 #ifdef TIMER
00013 #ifdef AIX
00014
00015 #include <ctime>
00016 time_t t_0;
00017 time_t t_1;
00018 #else
00019 #include <bcd.h>
00020 #include <conio.h>
00021 struct time t_0;
00022 struct time t_1;
00023 #endif
00024 #endif
00025
00026 #include "OsiOslSolverInterface.hpp"
00027 #include "tableau.h"
00028
00030
00037 class OsiOslSolverMipHandlerInterface : public OsiOslSolverInterface{
00038 friend void OsiOslSolverMipHandlerInterfaceUnitTest();
00039 public:
00041
00042
00043
00047 virtual int solve1();
00049
00053 virtual int solve2();
00055
00061 virtual int solve3();
00063
00064
00065
00066
00067
00068
00069 virtual const double * getRowUpper() ;
00070 virtual const double * getObjCoefficients() ;
00072
00073
00074
00075
00076
00077 virtual const double * getColSolution() ;
00078 virtual const double * getRowPrice() ;
00079 virtual const double * getRowActivity() ;
00081
00082
00083 int getNumberOfNodes();
00085
00086
00087 int getMaximumNumberOfNodes();
00088 bool getTestFlag()const;
00089 bool getTransponeFlag()const;
00091
00092
00093 CoinPackedMatrix getInfoBlock()const;
00095
00096
00097 void setTestFlag(bool test_);
00098 void setTransponeFlag(bool istransposed_);
00100
00101
00102 void setInfoBlock(CoinPackedMatrix infoBlock_);
00104
00106
00107 void deleteCols(const int num, const int * columnIndices);
00108 void deleteRows(const int num, const int * rowIndices);
00110
00111
00112 virtual void createNames();
00114
00115
00122 virtual void loadProblem(const int numcols, const int numrows,
00123 const CoinBigIndex * start, const int* index,
00124 const double* value,
00125 const double* collb, const double* colub,
00126 const double* obj,
00127 const double* rowlb, const double* rowub);
00128
00131 virtual void loadProblem(const int numcols, const int numrows,
00132 const CoinBigIndex * start, const int* index,
00133 const double* value,
00134 const double* collb, const double* colub,
00135 const double* obj,
00136 const char* rowsen, const double* rowrhs,
00137 const double* rowrng);
00139
00144 virtual int addSpeciallyOrderedSet(const SpeciallyOrderedSet* sos);
00146
00149
00150 virtual void writeProblemExcel(char* filename, const CoinPackedMatrix& activityType);
00152
00153
00155 int testModel();
00160 int checkSolutionPrimal();
00162
00164
00165 OsiOslSolverMipHandlerInterface();
00166
00168 virtual ~OsiOslSolverMipHandlerInterface();
00170
00171 private:
00172
00173 int numrows;
00174
00175 int numcols;
00177 int numberofrowstodrop;
00179 int numberofcolstodrop;
00181 bool test;
00183 int istransposed;
00185 CoinPackedMatrix infoBlock;
00186
00187 template <class Type> int allocateVector(Type*& pointertovector, long int sizeofvector);
00189 void retrieveOriginalColumnNames(int*& colIndex);
00191 void retrieveOriginalRowNames(int*& rowIndex);
00193 int checkColumns();
00194 int fixDiverseParameters();
00195 void gutsOfDestructor();
00196 };
00197
00198
00199 template <class Type>
00200 int OsiOslSolverMipHandlerInterface::allocateVector(Type*& pointertovector, long int sizeofvector){
00201 if (sizeofvector > 0)
00202 if(pointertovector== NULL){
00203 try{
00204 pointertovector = new Type[sizeofvector];
00205 for (int i = 0; i<sizeofvector;i++) pointertovector[i] = NULL;
00206 }
00207 catch(exception& exceptionObject){
00208 cerr << "Exception: "<< exceptionObject.what()<<endl;
00209 cerr << "Error in "<< typeid(*this).name()<<"::allocateVector(): cannot allocate memory for Type"<< typeid(*pointertovector).name()<<"["<<sizeofvector<<"]" << endl;
00210 exit(0);
00211 }
00212 }
00213 else {
00214 delete[] pointertovector;
00215 pointertovector = NULL;
00216 try{
00217 pointertovector = new Type[sizeofvector];
00218 for (int i = 0; i<sizeofvector;i++) pointertovector[i] = NULL;
00219 }
00220 catch(exception& exceptionObject){
00221 cerr << "Exception: "<< exceptionObject.what()<<endl;
00222 cerr << "Error in "<< typeid(*this).name()<<"::allocateVector(): cannot allocate memory for Type"<< typeid(*pointertovector).name()<<"["<<sizeofvector<<"]" << endl;
00223 exit(0);
00224 }
00225 }
00226 else {
00227 if (test) cerr << "Warning in "<< typeid(*this).name()<<"::allocateVector(): nothing to allocate:"
00228 << "length of array of "<<typeid(*pointertovector).name()<<" is: "<<sizeofvector<<"!" << endl;
00229 return 0;
00230 }
00231 return 1;
00232 }
00233 #endif
00234 #endif