CYCLUS
cyc_limits.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_CYC_LIMITS_H_
2 #define CYCLUS_SRC_CYC_LIMITS_H_
3 
4 #include <cmath>
5 #include <limits>
6 
7 namespace cyclus {
8 
9 /// generic epsilon values
10 extern double cy_eps;
11 /// a generic epsilon value
12 inline double eps() {
13  return cy_eps;
14 }
15 
16 /// epsilon values to be used by resources
17 extern double cy_eps_rsrc;
18 /// an epsilon value to be used by resources
19 inline double eps_rsrc() {
20  return cy_eps_rsrc;
21 }
22 
23 /// returns true if a double is less than 0 - eps()
24 inline bool IsNegative(double d) {
25  return (d < (-1 * eps()));
26 }
27 
28 /// returns true if two doubles are within eps() of one another
29 inline bool AlmostEq(double d1, double d2) {
30  return std::fabs(d1 - d2) < eps();
31 }
32 
33 /// distance in ULP within which floating point numbers should be considered
34 /// equal.
35 static const double float_ulp_eq = 2;
36 
37 /// maximum value for a function modifier (i.e., a_i for variable x_i)
38 static const double kModifierLimit = pow(10, 10);
39 
40 /// maximum (+ or -) value for an integer variable
41 static const int kIntBoundLimit = std::numeric_limits<int>::max();
42 
43 /// maximum (+ or -) value for a linear variable
44 static const double kLinBoundLimit = std::numeric_limits<double>::max();
45 
46 /// epsilon value to turn determine difference between constraint values
47 static const double kConstraintEps = 1e-08;
48 
49 } // namespace cyclus
50 
51 #endif // CYCLUS_SRC_CYC_LIMITS_H_
bool AlmostEq(double d1, double d2)
returns true if two doubles are within eps() of one another
Definition: cyc_limits.h:29
double cy_eps
generic epsilon values
Definition: context.cc:16
static const double kModifierLimit
maximum value for a function modifier (i.e., a_i for variable x_i)
Definition: cyc_limits.h:38
static const double float_ulp_eq
distance in ULP within which floating point numbers should be considered equal.
Definition: cyc_limits.h:35
double eps_rsrc()
an epsilon value to be used by resources
Definition: cyc_limits.h:19
static const double kConstraintEps
epsilon value to turn determine difference between constraint values
Definition: cyc_limits.h:47
bool IsNegative(double d)
returns true if a double is less than 0 - eps()
Definition: cyc_limits.h:24
static const double kLinBoundLimit
maximum (+ or -) value for a linear variable
Definition: cyc_limits.h:44
double cy_eps_rsrc
epsilon values to be used by resources
Definition: context.cc:17
static const int kIntBoundLimit
maximum (+ or -) value for an integer variable
Definition: cyc_limits.h:41
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
double eps()
a generic epsilon value
Definition: cyc_limits.h:12