MAiNGO
babBounds.h
Go to the documentation of this file.
1 /**********************************************************************************
2  * Copyright (c) 2019 Process Systems Engineering (AVT.SVT), RWTH Aachen University
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License 2.0 which is available at
6  * http://www.eclipse.org/legal/epl-2.0.
7  *
8  * SPDX-License-Identifier: EPL-2.0
9  *
10  * @file babBounds.h
11  *
12  * @brief File containing definition of Bounds struct for storing bounds on optimization variables.
13  *
14  **********************************************************************************/
15 
16 #pragma once
17 
18 #include <iostream>
19 
20 
25 namespace babBase {
26 
27 
32 struct Bounds {
33 
34  public:
41  Bounds(const double lowerIn, const double upperIn):
42  lower(lowerIn), upper(upperIn) {}
43 
47  bool are_consistent() const
48  {
49  return (lower <= upper);
50  }
51 
52  double lower;
53  double upper;
54 };
55 
56 
63 inline std::ostream &operator<<(std::ostream &os, const Bounds &b)
64 {
65  os << "Lower:" << b.lower << " , Upper:" << b.upper;
66  return os;
67 };
68 
69 
76 inline bool operator==(const Bounds &b1, const Bounds &b2)
77 {
78  return ( (b1.lower == b2.lower) && (b1.upper == b2.upper) );
79 };
80 
81 
88 inline bool operator!=(const Bounds &b1, const Bounds &b2)
89 {
90  return ( (b1.lower != b2.lower) || (b1.upper != b2.upper) );
91 };
92 
93 
94 } // namespace babBase
std::ostream & operator<<(std::ostream &os, const Bounds &b)
Overloaded outstream operator for nicer output.
Definition: babBounds.h:63
Auxiliary struct for representing bounds on an optimization variable.
Definition: babBounds.h:32
namespace holding all essentials of the babBase submodule
bool operator==(const Bounds &b1, const Bounds &b2)
Equality operator for checking if two bound objects are equal.
Definition: babBounds.h:76
double lower
Definition: babBounds.h:52
Bounds(const double lowerIn, const double upperIn)
Constructor.
Definition: babBounds.h:41
double upper
Definition: babBounds.h:53
bool are_consistent() const
Function for querying whether the lower bound is less than or equal to the upper bound.
Definition: babBounds.h:47
bool operator!=(const Bounds &b1, const Bounds &b2)
Inequality operator for checking if two bound objects differ from each other.
Definition: babBounds.h:88