Bonmin  1.8.8
BonRegisteredOptions.hpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines Corporation 2007
2 //
3 // All Rights Reserved.
4 // This code is published under the Eclipse Public License.
5 //
6 // Authors :
7 // Pierre Bonami, Carnegie Mellon University,
8 //
9 // Date : 27/08/2007
10 
11 #ifndef BonRegisteredOptions_H
12 #define BonRegisteredOptions_H
13 
14 #include "IpRegOptions.hpp"
15 #include "IpException.hpp"
16 #include "CoinError.hpp"
17 #include "IpTypes.hpp"
18 #include <iostream>
19 
20 /* Forward declaration, the function will be defined in BonAmplTMINLP.cpp, if ASL is available */
21 namespace Ipopt {
22  class AmplOptionsList;
23 }
24 
25 namespace Bonmin {
30 class RegisteredOptions: public Ipopt::RegisteredOptions{
31  public:
40  };
41 
42 
43 /* Table of values
44  * only B-Hyb 1
45  * B-Hyb & B-QG 3
46  * B-Hyb & B-OA 5
47  * B-Hyb & B-QG & B-OA & B-ECP 23
48  */
49 
50 
51 
59  };
62  Ipopt::RegisteredOptions(){
63  }
64 
67  }
68 
69  //DECLARE_STD_EXCEPTION(OPTION_NOT_REGISTERED);
71  void SetRegisteringCategory (const std::string &registering_category,
72  const ExtraCategoriesInfo extra){
73  Ipopt::RegisteredOptions::SetRegisteringCategory(registering_category);
74  categoriesInfos_[registering_category] = extra;}
75 
77  inline void optionExists(const std::string & option){
78  if(!IsValid(GetOption(option))){
79  std::string msg = "Try to access option: "+option;
80  msg += "\n Option is not registered.\n";
81  throw CoinError("Bonmin::RegisteredOption","optionExists",msg);
82  }
83  }
84 
86  inline void setOptionExtraInfo(const std::string & option, int code){
87  optionExists(option);
88  bonOptInfos_[option] = code;
89  }
90 
92  inline void optionValidForHybrid(const std::string &option){
93  optionExists(option);
94  bonOptInfos_[option] |= 1 << validInHybrid;}
95 
97  inline void optionValidForBQG(const std::string &option){
98  optionExists(option);
99  bonOptInfos_[option] |= 1 << validInQG;}
100 
102  inline void optionValidForBOA(const std::string &option){
103  optionExists(option);
104  bonOptInfos_[option] |= 1 << validInOA;}
105 
107  inline void optionValidForBBB(const std::string &option){
108  optionExists(option);
109  bonOptInfos_[option] |= 1 << validInBBB;}
110 
112  inline void optionValidForBEcp(const std::string &option){
113  optionExists(option);
114  bonOptInfos_[option] |= 1 << validInEcp;}
115 
117  inline void optionValidForBiFP(const std::string &option){
118  optionExists(option);
119  bonOptInfos_[option] |= 1 << validIniFP;}
120 
122  inline void optionValidForCbc(const std::string &option){
123  optionExists(option);
124  bonOptInfos_[option] |= 1 << validInCbc;}
125 
126 
128  inline bool isValidForHybrid(const std::string &option){
129  optionExists(option);
130  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
131  if(i != bonOptInfos_.end())
132  return (i->second) & (1 << validInHybrid);
133  else return true;}
134 
136  inline bool isValidForBQG(const std::string &option){
137  optionExists(option);
138  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
139  if(i != bonOptInfos_.end())
140  return (i->second) & (1 << validInQG);
141  else return true;}
142 
144  inline bool isValidForBOA(const std::string &option){
145  optionExists(option);
146  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
147  if(i != bonOptInfos_.end())
148  return (i->second) & (1 << validInOA);
149  return true;}
150 
152  inline bool isValidForBBB(const std::string &option){
153  optionExists(option);
154  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
155  if(i != bonOptInfos_.end())
156  return (i->second) & (1 << validInBBB);
157  return true;}
158 
159 
161  inline bool isValidForBEcp(const std::string &option){
162  optionExists(option);
163  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
164  if(i != bonOptInfos_.end())
165  return (i->second) & (1 << validInEcp);
166  return true;}
167 
168 
170  inline bool isValidForBiFP(const std::string &option){
171  optionExists(option);
172  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
173  if(i != bonOptInfos_.end())
174  return (i->second) & (1 << validIniFP);
175  return true;}
176 
177 
179  inline bool isValidForCbc(const std::string &option){
180  optionExists(option);
181  std::map<std::string, int>::iterator i = bonOptInfos_.find(option);
182  if(i != bonOptInfos_.end())
183  return (i->second) & (1 << validInCbc);
184  return true;}
185 
186 
188  void writeLatexOptionsTable(std::ostream &of, ExtraCategoriesInfo which);
189 
191  void writeHtmlOptionsTable(std::ostream &of, ExtraCategoriesInfo which);
192 
193 
195  void writeLatexHtmlDoc(std::ostream &of, ExtraCategoriesInfo which);
197  void writeBonminOpt(std::ostream &os, ExtraCategoriesInfo which);
198 
200  ExtraCategoriesInfo categoriesInfo(const std::string &s)
201  {
202  std::map<std::string, ExtraCategoriesInfo>::iterator i = categoriesInfos_.find(s);
203  if(i == categoriesInfos_.end())
204  return IpoptCategory;
205  return i->second;
206  }
207 
208  /* Forward declaration, the function will be defined in BonAmplTMINLP.cpp*/
209  void fillAmplOptionList(ExtraCategoriesInfo which, Ipopt::AmplOptionsList * amplOptList);
210 
211  private:
213  void chooseOptions(ExtraCategoriesInfo which, std::list<Ipopt::RegisteredOption *> &options);
215  void writeHtmlOptionsTable(std::ostream & os, std::list<Ipopt::RegisteredOption *> &options);
217  std::map<std::string, int> bonOptInfos_;
220  std::map<std::string, ExtraCategoriesInfo> categoriesInfos_;
221 };
222 
223 }/*Ends namespace Bonmin.*/
224 #endif
225 
void optionValidForBiFP(const std::string &option)
Set that option is valid for B-iFP.
Say that option is valid in outer approximation dec (4).
void optionValidForCbc(const std::string &option)
Set that option is valid for Cbc.
void setOptionExtraInfo(const std::string &option, int code)
Set extra information for option.
void SetRegisteringCategory(const std::string &registering_category, const ExtraCategoriesInfo extra)
Set registering category with extra information.
void optionValidForBOA(const std::string &option)
Set that option is valid for Outer approximation.
void optionExists(const std::string &option)
throw if option does not exists.
void writeHtmlOptionsTable(std::ostream &of, ExtraCategoriesInfo which)
Output html table of options.
~RegisteredOptions()
Standard destructor.
Say that option is valid in the pure branch-and-bound (8).
bool isValidForBBB(const std::string &option)
Say if option is valid for pure branch-and-bound.
Say that option is valid in the Ecp (16).
bool isValidForHybrid(const std::string &option)
Say if option is valid for hybrid.
bool isValidForCbc(const std::string &option)
Say if option is valid for Cbc.
bool isValidForBiFP(const std::string &option)
Say if option is valid for B-iFP.
Say that option is valid when using Cbc_Par (64).
void chooseOptions(ExtraCategoriesInfo which, std::list< Ipopt::RegisteredOption * > &options)
Output Latex table of options.
bool isValidForBEcp(const std::string &option)
Say if option is valid for B-Ecp.
void fillAmplOptionList(ExtraCategoriesInfo which, Ipopt::AmplOptionsList *amplOptList)
bool isValidForBQG(const std::string &option)
Say if option is valid for QuesadaGrossmann.
RegisteredOptions()
Standard constructor.
Say that option is valid in the iFP (32).
std::map< std::string, ExtraCategoriesInfo > categoriesInfos_
Store extra Informations on Registering categories (is bonmin, filterSqp...).
void optionValidForHybrid(const std::string &option)
Set that option is valid for hybrid.
void optionValidForBQG(const std::string &option)
Set that option is valid for QuesadaGrossmann.
std::map< std::string, int > bonOptInfos_
Store extra Informations on Bonmin options.
bool isValidForBOA(const std::string &option)
Say if option is valid for Outer approximation.
void optionValidForBBB(const std::string &option)
Set that option is valid for pure branch-and-bound.
void writeLatexHtmlDoc(std::ostream &of, ExtraCategoriesInfo which)
Output Latex/Html ooptions documentation.
ExtraCategoriesInfo categoriesInfo(const std::string &s)
Get info about what a category is taking care of (e.g., Ipopt, Bonmin, FilterSQP,...) .
void writeBonminOpt(std::ostream &os, ExtraCategoriesInfo which)
Ouptut a bonmin.opt file with options default values and short descriptions.
void writeLatexOptionsTable(std::ostream &of, ExtraCategoriesInfo which)
Output Latex table of options.
void optionValidForBEcp(const std::string &option)
Set that option is valid for B-Ecp.
Say that option is valid in Quesada Grossmann method (2).
Class to add a few more information to Ipopt::RegisteredOptions.