MAiNGO
utilities.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 utilities.h
11  *
12  * @brief File containing a few auxiliary functions needed in different
13  * parts of MAiNGO
14  *
15  **********************************************************************************/
16 
17 #pragma once
18 
19 #include "settings.h"
20 
21 #include <cmath>
22 #include <string>
23 
24 
25 namespace maingo {
26 
27 
37 inline bool
38 larger_or_equal_within_tolerance(const double LBD, const double UBD, Settings* mySettings)
39 {
40 
41  bool absDone = (LBD >= (UBD - mySettings->epsilonA)); // Done means that absolute criterion is met
42  bool relDone = (LBD >= (UBD - std::fabs(UBD) * mySettings->epsilonR)); // Done means that relative criterion is met
43  return (absDone || relDone); // If either criterion is met we are done
44 }
45 
53 inline std::string
55 {
56  return "v0.2.1 ";
57 }
58 
59 
60 } // end namespace maingo
Struct for storing settings for MAiNGO.
Definition: settings.h:143
bool larger_or_equal_within_tolerance(const double LBD, const double UBD, Settings *mySettings)
Function for checking if LBD is larger than UBD, or smaller by not more than the specified tolerance ...
Definition: utilities.h:38
namespace holding all essentials of MAiNGO
Definition: aleModel.h:31
double epsilonA
Absolute optimality tolerance, i.e., termination when (UBD-LBD) < BAB_epsilon_a.
Definition: settings.h:164
std::string print_version()
Function printing the current version number.
Definition: utilities.h:54
double epsilonR
Relative optimality tolerance, i.e., termination when (UBD-LBD) < BAB_epsilon_r * UBD.
Definition: settings.h:165