Bonmin 1.8.9
Loading...
Searching...
No Matches
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 */
21namespace Ipopt {
22 class AmplOptionsList;
23}
24
25namespace Bonmin {
31 public:
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
64
68
69 //DECLARE_STD_EXCEPTION(OPTION_NOT_REGISTERED);
71 void SetRegisteringCategory (const std::string &registering_category,
72 const ExtraCategoriesInfo extra){
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
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*/
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 writeHtmlOptionsTable(std::ostream &of, ExtraCategoriesInfo which)
Output html table of options.
RegisteredOptions()
Standard constructor.
void writeLatexHtmlDoc(std::ostream &of, ExtraCategoriesInfo which)
Output Latex/Html ooptions documentation.
void optionValidForBiFP(const std::string &option)
Set that option is valid for B-iFP.
void optionValidForBQG(const std::string &option)
Set that option is valid for QuesadaGrossmann.
void optionValidForBBB(const std::string &option)
Set that option is valid for pure branch-and-bound.
void optionValidForCbc(const std::string &option)
Set that option is valid for Cbc.
void optionExists(const std::string &option)
throw if option does not exists.
void writeBonminOpt(std::ostream &os, ExtraCategoriesInfo which)
Ouptut a bonmin.opt file with options default values and short descriptions.
ExtraCategoriesInfo categoriesInfo(const std::string &s)
Get info about what a category is taking care of (e.g., Ipopt, Bonmin, FilterSQP,....
void SetRegisteringCategory(const std::string &registering_category, const ExtraCategoriesInfo extra)
Set registering category with extra information.
bool isValidForBiFP(const std::string &option)
Say if option is valid for B-iFP.
void optionValidForBOA(const std::string &option)
Set that option is valid for Outer approximation.
bool isValidForHybrid(const std::string &option)
Say if option is valid for hybrid.
void fillAmplOptionList(ExtraCategoriesInfo which, Ipopt::AmplOptionsList *amplOptList)
void optionValidForHybrid(const std::string &option)
Set that option is valid for hybrid.
bool isValidForBEcp(const std::string &option)
Say if option is valid for B-Ecp.
bool isValidForBBB(const std::string &option)
Say if option is valid for pure branch-and-bound.
bool isValidForBQG(const std::string &option)
Say if option is valid for QuesadaGrossmann.
@ BqpdCategory
Option category for Bqpd.
@ IpoptCategory
Option category for Ipopt.
@ UndocumentedCategory
For undocumented options.
@ CouenneCategory
Option category for Couenne.
@ FilterCategory
Option category for FilterSqp.
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.
@ validInEcp
Say that option is valid in the Ecp (16).
@ validInCbc
Say that option is valid when using Cbc_Par (64).
@ validInQG
Say that option is valid in Quesada Grossmann method (2).
@ validInOA
Say that option is valid in outer approximation dec (4).
@ validIniFP
Say that option is valid in the iFP (32).
@ validInBBB
Say that option is valid in the pure branch-and-bound (8).
bool isValidForBOA(const std::string &option)
Say if option is valid for Outer approximation.
~RegisteredOptions()
Standard destructor.
bool isValidForCbc(const std::string &option)
Say if option is valid for Cbc.
void setOptionExtraInfo(const std::string &option, int code)
Set extra information for option.
virtual void SetRegisteringCategory(const std::string &registering_category, int priority=0)
virtual SmartPtr< const RegisteredOption > GetOption(const std::string &name)
(C) Copyright International Business Machines Corporation 2007
bool IsValid(const SmartPtr< U > &smart_ptr)