/home/coin/SVN-release/OS-2.0.0/Bonmin/src/Interfaces/BonRegisteredOptions.hpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation 2007
00002 //
00003 // All Rights Reserved.
00004 // This code is published under the Common Public License.
00005 //
00006 // Authors :
00007 // Pierre Bonami, Carnegie Mellon University,
00008 //
00009 // Date : 27/08/2007
00010 
00011 #ifndef BonRegisteredOptions_H
00012 #define BonRegisteredOptions_H
00013 
00014 #include "IpRegOptions.hpp"
00015 #include "IpException.hpp"
00016 #include "CoinError.hpp"
00017 #include "IpTypes.hpp"
00018 #include <iostream>
00019 #ifdef COIN_HAS_ASL
00020    /* Forwar declaration, the function will be defined in BonAmplTMINLP.cpp*/
00021    namespace Ipopt{
00022    class AmplOptionsList;
00023    }
00024 #endif
00025 namespace Bonmin {
00030 class RegisteredOptions: public Ipopt::RegisteredOptions{
00031   public:
00032     enum ExtraOptInfosBits{
00033     validInHybrid=0,
00034     validInQG,
00035     validInOA,
00036     validInBBB
00037    };
00038    enum ExtraCategoriesInfo{
00039     BonminCategory = 0,
00040     IpoptCategory ,
00041     FilterCategory ,
00042     BqpdCategory ,
00043     CouenneCategory 
00044    };
00046     RegisteredOptions():
00047        Ipopt::RegisteredOptions(){
00048     }
00049 
00051     ~RegisteredOptions(){
00052     }
00053 
00054    //DECLARE_STD_EXCEPTION(OPTION_NOT_REGISTERED); 
00056    void SetRegisteringCategory (const std::string &registering_category,
00057                                 const ExtraCategoriesInfo extra){
00058       Ipopt::RegisteredOptions::SetRegisteringCategory(registering_category);
00059       categoriesInfos_[registering_category] = extra;}
00060  
00062    inline void optionExists(const std::string & option){
00063      if(!IsValid(GetOption(option))){
00064        std::string msg = "Try to access option: "+option;
00065        msg += "\n Option is not registered.\n";
00066        throw CoinError("Bonmin::RegisteredOption","optionExists",msg);
00067      }
00068    }
00069 
00071    inline void setOptionExtraInfo(const std::string & option, int code){
00072       optionExists(option);
00073       bonOptInfos_[option] = code;
00074    }
00075 
00077    inline void optionValidForHybrid(const std::string &option){
00078       optionExists(option);
00079      bonOptInfos_[option] |= 1 << validInHybrid;}
00080 
00082    inline void optionValidForBQG(const std::string &option){
00083      optionExists(option);
00084      bonOptInfos_[option] |= 1 << validInQG;}
00085    
00087    inline void optionValidForBOA(const std::string &option){
00088      optionExists(option);
00089      bonOptInfos_[option] |= 1 << validInOA;}
00090    
00092    inline void optionValidForBBB(const std::string &option){
00093      optionExists(option);
00094      bonOptInfos_[option] |= 1 << validInBBB;}
00095 
00096 
00098    inline bool isValidForHybrid(const std::string &option){
00099       optionExists(option);
00100      std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
00101      if(i != bonOptInfos_.end()) 
00102      return (i->second) & (1 << validInHybrid);
00103      else return true;}
00104 
00106    inline bool isValidForBQG(const std::string &option){
00107      optionExists(option);
00108      std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
00109      if(i != bonOptInfos_.end()) 
00110        return (i->second) & (1 << validInQG);
00111      else return true;}
00112    
00114    inline bool isValidForBOA(const std::string &option){
00115      optionExists(option);
00116      std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
00117      if(i != bonOptInfos_.end()) 
00118      return (i->second) & (1 << validInOA);
00119      return true;}
00120    
00122    inline bool isValidForBBB(const std::string &option){
00123      optionExists(option);
00124      std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
00125      if(i != bonOptInfos_.end()) 
00126      return (i->second) & (1 << validInBBB);
00127      return true;}
00129    void writeLatexOptionsTable(std::ostream &of, ExtraCategoriesInfo which);
00130 
00132    void writeHtmlOptionsTable(std::ostream &of, ExtraCategoriesInfo which);
00133 
00134 
00136    void writeLatexHtmlDoc(std::ostream &of, ExtraCategoriesInfo which);
00138   void writeBonminOpt(std::ostream &os, ExtraCategoriesInfo which);
00139 
00141    ExtraCategoriesInfo categoriesInfo(const std::string &s)
00142    {
00143       std::map<std::string, ExtraCategoriesInfo>::iterator i = categoriesInfos_.find(s);
00144       if(i == categoriesInfos_.end())
00145         return IpoptCategory;
00146       return i->second;
00147    }
00148   
00149 #ifdef COIN_HAS_ASL
00150    /* Forward declaration, the function will be defined in BonAmplTMINLP.cpp*/
00151    void fillAmplOptionList(ExtraCategoriesInfo which, Ipopt::AmplOptionsList * amplOptList);
00152 #endif
00153    private:
00155    void chooseOptions(ExtraCategoriesInfo which, std::list<Ipopt::RegisteredOption *> &options);
00157    void writeHtmlOptionsTable(std::ostream & os, std::list<Ipopt::RegisteredOption *> &options);
00159    std::map<std::string, int> bonOptInfos_;
00162    std::map<std::string, ExtraCategoriesInfo> categoriesInfos_;
00163 };
00164 
00165 }/*Ends namespace Bonmin.*/
00166 #endif
00167 

Generated on Mon Aug 3 03:02:18 2009 by  doxygen 1.4.7