1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
OptimisationMethod.cpp
Go to the documentation of this file.
1
// //////////////////////////////////////////////////////////////////////
2
// Import section
3
// //////////////////////////////////////////////////////////////////////
4
// STL
5
#include <cassert>
6
#include <sstream>
7
// StdAir
8
#include <
stdair/stdair_exceptions.hpp
>
9
#include <
stdair/basic/OptimisationMethod.hpp
>
10
11
namespace
stdair
{
12
13
// //////////////////////////////////////////////////////////////////////
14
const
std::string OptimisationMethod::_labels[
LAST_VALUE
] =
15
{
"Leg based Monte Carlo"
,
"Leg based EMSRb"
};
16
17
// //////////////////////////////////////////////////////////////////////
18
const
char
OptimisationMethod::
19
_methodLabels[
LAST_VALUE
] = {
'M'
,
'E'
};
20
21
22
// //////////////////////////////////////////////////////////////////////
23
OptimisationMethod::OptimisationMethod
()
24
: _method (
LAST_VALUE
) {
25
assert (
false
);
26
}
27
28
// //////////////////////////////////////////////////////////////////////
29
OptimisationMethod::
30
OptimisationMethod (
const
OptimisationMethod
& iOptimisationMethod)
31
: _method (iOptimisationMethod._method) {
32
}
33
34
// //////////////////////////////////////////////////////////////////////
35
OptimisationMethod::
36
OptimisationMethod
(
const
EN_OptimisationMethod
& iOptimisationMethod)
37
: _method (iOptimisationMethod) {
38
}
39
40
// //////////////////////////////////////////////////////////////////////
41
OptimisationMethod::OptimisationMethod
(
const
char
iMethod) {
42
switch
(iMethod) {
43
case
'M'
: _method =
LEG_BASED_MC
;
break
;
44
case
'E'
: _method =
LEG_BASED_EMSR_B
;
break
;
45
default
: _method =
LAST_VALUE
;
break
;
46
}
47
48
if
(_method ==
LAST_VALUE
) {
49
const
std::string& lLabels =
describeLabels
();
50
std::ostringstream oMessage;
51
oMessage <<
"The optimisation method '"
<< iMethod
52
<<
"' is not known. Known optimisation methods: "
<< lLabels;
53
throw
CodeConversionException
(oMessage.str());
54
}
55
}
56
57
// //////////////////////////////////////////////////////////////////////
58
const
std::string&
OptimisationMethod::
59
getLabel
(
const
EN_OptimisationMethod
& iMethod) {
60
return
_labels[iMethod];
61
}
62
63
// //////////////////////////////////////////////////////////////////////
64
char
OptimisationMethod::getMethodLabel
(
const
EN_OptimisationMethod
& iMethod) {
65
return
_methodLabels[iMethod];
66
}
67
68
// //////////////////////////////////////////////////////////////////////
69
std::string
OptimisationMethod::
70
getMethodLabelAsString
(
const
EN_OptimisationMethod
& iMethod) {
71
std::ostringstream oStr;
72
oStr << _methodLabels[iMethod];
73
return
oStr.str();
74
}
75
76
// //////////////////////////////////////////////////////////////////////
77
std::string
OptimisationMethod::describeLabels
() {
78
std::ostringstream ostr;
79
for
(
unsigned
short
idx = 0; idx !=
LAST_VALUE
; ++idx) {
80
if
(idx != 0) {
81
ostr <<
", "
;
82
}
83
ostr << _labels[idx] <<
" ("
<< _methodLabels[idx] <<
")"
;
84
}
85
return
ostr.str();
86
}
87
88
// //////////////////////////////////////////////////////////////////////
89
OptimisationMethod::EN_OptimisationMethod
OptimisationMethod::getMethod
()
const
{
90
return
_method;
91
}
92
93
// //////////////////////////////////////////////////////////////////////
94
std::string
OptimisationMethod::getMethodAsString
()
const
{
95
std::ostringstream oStr;
96
oStr << _methodLabels[_method];
97
return
oStr.str();
98
}
99
100
// //////////////////////////////////////////////////////////////////////
101
const
std::string
OptimisationMethod::describe
()
const
{
102
std::ostringstream ostr;
103
ostr << _labels[_method];
104
return
ostr.str();
105
}
106
107
// //////////////////////////////////////////////////////////////////////
108
bool
OptimisationMethod::
109
operator==
(
const
EN_OptimisationMethod
& iMethod)
const
{
110
return
(_method == iMethod);
111
}
112
113
}
OptimisationMethod.hpp
stdair_exceptions.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::LOG::LAST_VALUE
@ LAST_VALUE
Definition
stdair_log.hpp:25
stdair::OptimisationMethod::EN_OptimisationMethod
EN_OptimisationMethod
Definition
OptimisationMethod.hpp:17
stdair::OptimisationMethod::LAST_VALUE
@ LAST_VALUE
Definition
OptimisationMethod.hpp:20
stdair::OptimisationMethod::LEG_BASED_EMSR_B
@ LEG_BASED_EMSR_B
Definition
OptimisationMethod.hpp:19
stdair::OptimisationMethod::LEG_BASED_MC
@ LEG_BASED_MC
Definition
OptimisationMethod.hpp:18
stdair::OptimisationMethod::getMethod
EN_OptimisationMethod getMethod() const
Definition
OptimisationMethod.cpp:89
stdair::OptimisationMethod::getMethodAsString
std::string getMethodAsString() const
Definition
OptimisationMethod.cpp:94
stdair::OptimisationMethod::operator==
bool operator==(const EN_OptimisationMethod &) const
Definition
OptimisationMethod.cpp:109
stdair::OptimisationMethod::getMethodLabel
static char getMethodLabel(const EN_OptimisationMethod &)
Definition
OptimisationMethod.cpp:64
stdair::OptimisationMethod::getMethodLabelAsString
static std::string getMethodLabelAsString(const EN_OptimisationMethod &)
Definition
OptimisationMethod.cpp:70
stdair::OptimisationMethod::describe
const std::string describe() const
Definition
OptimisationMethod.cpp:101
stdair::OptimisationMethod::getLabel
static const std::string & getLabel(const EN_OptimisationMethod &)
Definition
OptimisationMethod.cpp:59
stdair::OptimisationMethod::describeLabels
static std::string describeLabels()
Definition
OptimisationMethod.cpp:77
stdair::OptimisationMethod::OptimisationMethod
OptimisationMethod(const EN_OptimisationMethod &)
Definition
OptimisationMethod.cpp:36
stdair::CodeConversionException
Definition
stdair_exceptions.hpp:133
Generated for StdAir by
1.17.0