NOMAD Source  Version 4.0.0 Beta
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BBOutputType.hpp
Go to the documentation of this file.
1 /**
2  \file BBOutputType.hpp
3  \brief types for BBOutput
4  \author Viviane Rochon Montplaisir
5  \date September 2018
6  \see BBOutput.hpp
7  */
8 #ifndef __NOMAD400_BB_OUTPUT_TYPE__
9 #define __NOMAD400_BB_OUTPUT_TYPE__
10 
11 #include <string>
12 #include <sstream>
13 #include <vector>
14 
15 #include "../nomad_nsbegin.hpp"
16 
17 
18 /// Blackbox output types
19 enum class BBOutputType
20 {
21  OBJ, ///< Objective value
22  EB, ///< Extreme barrier constraint
23  PB, ///< Progressive barrier constraint
24  // CNT_EVAL, ///< Output set to 0 or 1 to count the blackbox evaluation or not
25  //STAT_AVG, ///< Stat (average)
26  //STAT_SUM, ///< Stat (sum)
27  BBO_UNDEFINED ///< Output ignored
28 };
29 
30 /// Definition for the list of blackbox output types
31 typedef std::vector<BBOutputType> BBOutputTypeList;
32 typedef BBOutputTypeList::const_iterator BBOutputTypeListIt;
33 
34 
35 /// Utility for BBOutputType
36 /**
37  Convert a string (ex "OBJ", "EB", "PB"...)
38  to a BBOutputType.
39  */
40 BBOutputType stringToBBOutputType(const std::string &s);
41 
42 /// Utility for BBOutputType
43 /**
44  Convert a string containing multiple BBOutputTypes (ex "OBJ EB PB PB")
45  to a BBOutputTypeList.
46  */
47 BBOutputTypeList stringToBBOutputTypeList(const std::string &s);
48 
49 /// Utility for BBOutputType
50 /**
51  Convert a BBOutputTypeList into a string
52  */
53 std::string BBOutputTypeListToString ( const BBOutputTypeList & bbotList );
54 
55 /// Helper to test if a BBOutputType is a constraint (PB, EB, ....)
56 bool BBOutputTypeIsConstraint(const BBOutputType & bbotType);
57 
58 /// Read and interpret BBOutputType
59 inline std::ostream& operator<<(std::ostream& os, const BBOutputType &bbot)
60 {
61  switch (bbot)
62  {
63  case BBOutputType::OBJ:
64  os << "OBJ";
65  break;
66  case BBOutputType::PB:
67  os << "PB";
68  break;
69  case BBOutputType::EB:
70  os << "EB";
71  break;
72 // case BBOutputType::CNT_EVAL:
73 // os << "CNT_EVAL";
74 // break;
76  default:
77  return os << "BBO_UNDEFINED";
78  break;
79  }
80 
81  return os;
82 }
83 
84 /// Display BBOutputType
85 inline std::ostream& operator<<(std::ostream& out, const BBOutputTypeList &bboutputtypelist)
86 {
88  bool first = true;
89  for (it = bboutputtypelist.begin(); it != bboutputtypelist.end(); ++it)
90  {
91  if (!first)
92  {
93  out << " ";
94  }
95  out << *it;
96  first = false;
97  }
98  return out;
99 }
100 
101 
102 
103 #include "../nomad_nsend.hpp"
104 
105 #endif // __NOMAD400_BB_OUTPUT_TYPE__
std::vector< BBOutputType > BBOutputTypeList
Definition for the list of blackbox output types.
Extreme barrier constraint.
BBOutputType stringToBBOutputType(const std::string &s)
Utility for BBOutputType.
BBOutputTypeList stringToBBOutputTypeList(const std::string &s)
Utility for BBOutputType.
bool BBOutputTypeIsConstraint(const BBOutputType &bbotType)
Helper to test if a BBOutputType is a constraint (PB, EB, ....)
Progressive barrier constraint.
BBOutputType
Blackbox output types.
std::ostream & operator<<(std::ostream &os, const Algorithm &algo)
Operator to write parameters used for hot restart.
std::string BBOutputTypeListToString(const BBOutputTypeList &bbotList)
Utility for BBOutputType.
Objective value.
BBOutputTypeList::const_iterator BBOutputTypeListIt