NOMAD Source  Version 4.0.0 Beta
defines.hpp
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------------*/
2 /* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct Search - */
3 /* */
4 /* NOMAD - Version 4.0.0 has been created by */
5 /* Viviane Rochon Montplaisir - Polytechnique Montreal */
6 /* Christophe Tribes - Polytechnique Montreal */
7 /* */
8 /* The copyright of NOMAD - version 4.0.0 is owned by */
9 /* Charles Audet - Polytechnique Montreal */
10 /* Sebastien Le Digabel - Polytechnique Montreal */
11 /* Viviane Rochon Montplaisir - Polytechnique Montreal */
12 /* Christophe Tribes - Polytechnique Montreal */
13 /* */
14 /* NOMAD v4 has been funded by Rio Tinto, Hydro-Québec, NSERC (Natural */
15 /* Sciences and Engineering Research Council of Canada), InnovÉÉ (Innovation */
16 /* en Énergie Électrique) and IVADO (The Institute for Data Valorization) */
17 /* */
18 /* NOMAD v3 was created and developed by Charles Audet, Sebastien Le Digabel, */
19 /* Christophe Tribes and Viviane Rochon Montplaisir and was funded by AFOSR */
20 /* and Exxon Mobil. */
21 /* */
22 /* NOMAD v1 and v2 were created and developed by Mark Abramson, Charles Audet, */
23 /* Gilles Couture, and John E. Dennis Jr., and were funded by AFOSR and */
24 /* Exxon Mobil. */
25 /* */
26 /* Contact information: */
27 /* Polytechnique Montreal - GERAD */
28 /* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */
29 /* e-mail: nomad@gerad.ca */
30 /* */
31 /* This program is free software: you can redistribute it and/or modify it */
32 /* under the terms of the GNU Lesser General Public License as published by */
33 /* the Free Software Foundation, either version 3 of the License, or (at your */
34 /* option) any later version. */
35 /* */
36 /* This program is distributed in the hope that it will be useful, but WITHOUT */
37 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
38 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License */
39 /* for more details. */
40 /* */
41 /* You should have received a copy of the GNU Lesser General Public License */
42 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
43 /* */
44 /* You can find information on the NOMAD software at www.gerad.ca/nomad */
45 /*---------------------------------------------------------------------------------*/
46 /**
47  \file defines.hpp
48  \brief Definitions
49  \author Sebastien Le Digabel, modified by Viviane Rochon Montplaisir
50  \date March 2017
51  */
52 #ifndef __NOMAD400_DEFINES__
53 #define __NOMAD400_DEFINES__
54 
55 #include <string>
56 #include <iostream>
57 #include <sstream>
58 #include <limits.h> // For INT_MAX
59 #include <limits> // For numeric_limits
60 #include <cstdlib>
61 #include <memory> // For shared_ptr, unique_ptr
62 
63 
64 // Define in order to display debug information
65 //#define DEBUG
66 
67 
68 // CASE Linux using gnu compiler
69 #ifdef __gnu_linux__
70 #define GCC_X
71 #endif
72 
73 // CASE OSX using gnu compiler
74 #ifdef __APPLE__
75 #ifdef __GNUC__
76 #define GCC_X
77 #endif
78 #endif
79 
80 // CASE Visual Studio C++ compiler
81 #ifdef _MSC_VER
82 #define WINDOWS
83 #pragma warning(disable:4996)
84 #endif
85 
86 // For NOMAD random number generator
87 #if !defined(UINT32_MAX)
88 typedef unsigned int uint32_t;
89 #define UINT32_MAX 0xffffffff
90 #endif
91 
92 #include "../nomad_nsbegin.hpp"
93 
94 // Directory separator
95 #ifdef WINDOWS
96 const char DIR_SEP = '\\'; ///< Directory separator
97 #else
98 const char DIR_SEP = '/'; ///< Directory separator
99 #endif
100 
101 /// Maximum number of variables.
102 const int MAX_DIMENSION = 1000;
103 
104 /// Default epsilon used by Double
105 /** Use Parameters::set_EPSILON(), or parameter EPSILON,
106  or Double::setEpsilon() to change it
107  */
108 const double DEFAULT_EPSILON = 1e-13;
109 
110 /// Default infinity string used by Double
111 /** Use Parameters::set_INF_STR(), or parameter INF_STR,
112  or Double::setInfStr() to change it
113  */
114 const std::string DEFAULT_INF_STR = "inf";
115 
116 /// Default undefined value string used by Double
117 /** Use Parameters::set_UNDEF_STR(), or parameter UNDEF_STR,
118  or Double::set_undefStr() to change it
119  */
120 const std::string DEFAULT_UNDEF_STR = "NaN";
121 // Other strings recognized as NaN
122 const std::string DEFAULT_UNDEF_STR_HYPHEN = "-";
123 const std::string DEFAULT_UNDEF_STR_1 = "nan";
124 
125 const double INF = std::numeric_limits<double>::max(); ///< Infinity
126 const double NaN = std::numeric_limits<double>::quiet_NaN(); ///< Quiet Not-A-Number
127 const int P_INF_INT = std::numeric_limits<int>::max(); ///< plus infinity for int
128 const int M_INF_INT = std::numeric_limits<int>::min(); ///< minus infinity for int
129 const size_t INF_SIZE_T = std::numeric_limits<size_t>::max();///< The infinity for \c size_t
130 const size_t INF_SHORT = std::numeric_limits<short>::max();///< The infinity for \c short
131 
132 const double D_INT_MAX = UINT32_MAX; ///< The UINT32_MAX constant as a \c double
133 
134 
135 // Display precisions.
136 const int DISPLAY_PRECISION_STD = 6; ///< Precision after decimal point (number of digits)
137 const int DISPLAY_PRECISION_FULL = 20; ///< Display all decimals
138 const int NB_DIGITS_BEFORE_POINT = 3; // "Precision" before decimal point
139 const int INT_DISPLAY_WIDTH = 3; // Width for integers
140 
141 
142 // -------------------------
143 // Related to MADS algorithm
144 // -------------------------
145 
146 /// Success type of an iteration.
147 // Order is important.
148 enum class SuccessType
149 {
150  NOT_EVALUATED, ///< Not evaluated yet
151  UNSUCCESSFUL, ///< Failure
152  PARTIAL_SUCCESS, ///< Partial success (improving). Found an infeasible
153  ///< solution with a better h. f is worse.
154  FULL_SUCCESS ///< Full success (dominating)
155 };
156 
157 
158 #include "../nomad_nsend.hpp"
159 
160 #endif // __NOMAD400_DEFINES__
M_INF_INT
const int M_INF_INT
minus infinity for int
Definition: defines.hpp:128
MAX_DIMENSION
const int MAX_DIMENSION
Maximum number of variables.
Definition: defines.hpp:102
max
Double max(const Double d1, const Double d2)
Largest of two values >=.
Definition: Double.hpp:600
INF
const double INF
Infinity.
Definition: defines.hpp:125
uint32_t
unsigned int uint32_t
Definition: defines.hpp:88
DEFAULT_UNDEF_STR_HYPHEN
const std::string DEFAULT_UNDEF_STR_HYPHEN
Definition: defines.hpp:122
DEFAULT_UNDEF_STR
const std::string DEFAULT_UNDEF_STR
Default undefined value string used by Double.
Definition: defines.hpp:120
D_INT_MAX
const double D_INT_MAX
The UINT32_MAX constant as a double.
Definition: defines.hpp:132
SuccessType
SuccessType
Success type of an iteration.
Definition: defines.hpp:148
NaN
const double NaN
Quiet Not-A-Number.
Definition: defines.hpp:126
INT_DISPLAY_WIDTH
const int INT_DISPLAY_WIDTH
Definition: defines.hpp:139
DEFAULT_INF_STR
const std::string DEFAULT_INF_STR
Default infinity string used by Double.
Definition: defines.hpp:114
min
Double min(const Double d1, const Double d2)
Smallest of two values >=.
Definition: Double.hpp:610
DEFAULT_EPSILON
const double DEFAULT_EPSILON
Default epsilon used by Double.
Definition: defines.hpp:108
DEFAULT_UNDEF_STR_1
const std::string DEFAULT_UNDEF_STR_1
Definition: defines.hpp:123
DISPLAY_PRECISION_STD
const int DISPLAY_PRECISION_STD
Precision after decimal point (number of digits)
Definition: defines.hpp:136
SuccessType::UNSUCCESSFUL
@ UNSUCCESSFUL
Failure.
SuccessType::PARTIAL_SUCCESS
@ PARTIAL_SUCCESS
solution with a better h. f is worse.
DISPLAY_PRECISION_FULL
const int DISPLAY_PRECISION_FULL
Display all decimals.
Definition: defines.hpp:137
SuccessType::FULL_SUCCESS
@ FULL_SUCCESS
Full success (dominating)
INF_SHORT
const size_t INF_SHORT
The infinity for short.
Definition: defines.hpp:130
SuccessType::NOT_EVALUATED
@ NOT_EVALUATED
Not evaluated yet.
INF_SIZE_T
const size_t INF_SIZE_T
The infinity for size_t.
Definition: defines.hpp:129
NB_DIGITS_BEFORE_POINT
const int NB_DIGITS_BEFORE_POINT
Definition: defines.hpp:138
P_INF_INT
const int P_INF_INT
plus infinity for int
Definition: defines.hpp:127
UINT32_MAX
#define UINT32_MAX
Definition: defines.hpp:89
DIR_SEP
const char DIR_SEP
Directory separator.
Definition: defines.hpp:98