/home/coin/SVN-release/CoinAll-1.1.0/Smi/src/SmiSmpsIO.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2003, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #ifndef SmiSmpsIO_HPP
00005 #define SmiSmpsIO_HPP
00006 
00007 #if defined(_MSC_VER)
00008 // Turn off compiler warning about long names
00009 #  pragma warning(disable:4786)
00010 #endif
00011 
00012 #include "CoinMpsIO.hpp"
00013 #include "CoinFileIO.hpp"
00014 #include "SmiScnModel.hpp"
00015 #include "SmiScnData.hpp"
00016 #include "SmiScenarioTree.hpp"
00017 
00018 #include <vector>
00019 #include <map>
00020 #include <string>
00021 
00022 using namespace std;
00023 
00024 
00025 // sections
00026 enum SmiSectionType { SMI_NO_SECTION, SMI_NAME_SECTION,
00027                                           SMI_ENDATA_SECTION, 
00028                                         SMI_EOF_SECTION, 
00029                                           SMI_TIME_SECTION, 
00030                                         SMI_SCENARIOS_SECTION, 
00031                                         SMI_INDEPENDENT_SECTION,
00032                                           SMI_UNKNOWN_SECTION
00033 };
00034 
00035 enum SmiSmpsType { SMI_SC_CARD, SMI_BL_CARD, SMI_COLUMN_CARD, SMI_DISCRETE_DIST, SMI_SMPS_COMBINE_ADD, 
00036         SMI_SMPS_COMBINE_REPLACE, SMI_SMPS_COMBINE_UNKNOWN, SMI_UNKNOWN_MPS_TYPE,
00037         SMI_TIME_UNORDERED_CORE_TYPE, SMI_TIME_ORDERED_CORE_TYPE
00038 };
00039 
00040 class SmiSmpsCardReader:
00041 public CoinMpsCardReader
00042 {
00043 public:
00044           SmiSectionType nextSmpsField (  );
00045           SmiSectionType whichSmpsSection(){return smiSection_;}
00046             
00047           SmiSmpsType whichSmpsType() {return smiSmpsType_;}
00048         
00049           inline const char *periodName (  ) const {return periodName_;}
00050           inline const char *scenarioNew (  ) const {return columnName_;}
00051           inline const char *scenarioAnc (  ) const {return rowName_;}
00052 
00053           inline double getProb(){ return prob_;}
00054 
00055           inline void setCoreCombineRule(SmiCoreCombineRule *r){combineRule_=r;combineRuleSet=true;}
00056           inline SmiCoreCombineRule *getCoreCombineRule() { return combineRule_;}
00057 
00060           SmiSmpsCardReader( CoinFileInput *input, CoinMpsIO * reader ):CoinMpsCardReader (input,reader ),
00061                 combineRuleSet(false),prob_(0.0){}
00062 
00063           ~SmiSmpsCardReader(){}
00064 private:
00066         char periodName_[COIN_MAX_FIELD_LENGTH];
00067         float fvalue_;
00068         SmiSectionType smiSection_;
00069         SmiSmpsType smiSmpsType_;
00070         SmiCoreCombineRule *combineRule_;
00071         bool combineRuleSet;
00072         double prob_;
00073 };
00074 
00075 class SmiSmpsIO: 
00076 public CoinMpsIO
00077 {
00078 public:
00079         SmiCoreData * readTimeFile(SmiScnModel *smi,const char *c,const char *ext="time");
00080         int readStochFile(SmiScnModel *smi,SmiCoreData *core, const char *c,const char *ext="stoch");
00081     
00082         inline void setCoreCombineRule(SmiCoreCombineRule *r){combineRule_=r; combineRuleSet=true;}
00083         inline SmiCoreCombineRule *getCoreCombineRule() { return combineRule_;}
00084         inline int getNumStages(){ return nstag_;}
00085         inline int *getColumnStages(){ return cstag_;}
00086         inline int *getRowStages(){ return rstag_;}     
00087 public:
00088         SmiSmpsIO():CoinMpsIO(),nstag_(0),cstag_(NULL),rstag_(NULL),iftime(false),combineRuleSet(false){}
00089         ~SmiSmpsIO(){delete [] cstag_;delete[] rstag_;delete smpsCardReader_;}
00090 private:
00091         int nstag_;
00092         int *cstag_;
00093         int *rstag_;
00094         typedef         std::map<string,int> StringIntMap;
00095         StringIntMap periodMap_;
00096         StringIntMap scenarioMap_;
00097         bool iftime,ifstoch;
00098         SmiSmpsCardReader *smpsCardReader_;
00099         SmiCoreCombineRule *combineRule_;
00100         bool combineRuleSet;
00101         
00102 };
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 #endif //#define SmiSmpsIO_HPP

Generated on Sun Nov 14 14:06:40 2010 for Coin-All by  doxygen 1.4.7