Global data and functions. More...
#include <ogdf/lib/abacus/global.h>
Public Member Functions | |
AbacusGlobal (double eps=1.0e-4, double machineEps=1.0e-7, double infinity=1.0e32) | |
The constructor. More... | |
virtual | ~AbacusGlobal () |
The destructor. More... | |
void | assignParameter (bool ¶m, const char *name) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (bool ¶m, const char *name, bool defVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (char ¶m, const char *name, const char *feasible, char defVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (char ¶m, const char *name, const char *feasible=nullptr) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (double ¶m, const char *name, double minVal, double maxVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (double ¶m, const char *name, double minVal, double maxVal, double defVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (int ¶m, const char *name, int minVal, int maxVal) const |
Searches for parameter name in the parameter table and returns its value in param. More... | |
void | assignParameter (int ¶m, const char *name, int minVal, int maxVal, int defVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (string ¶m, const char *name, unsigned nFeasible, const char *feasible[], const char *defVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (string ¶m, const char *name, unsigned nFeasible=0, const char *feasible[]=nullptr) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (unsigned ¶m, const char *name, unsigned minVal, unsigned maxVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
void | assignParameter (unsigned ¶m, const char *name, unsigned minVal, unsigned maxVal, unsigned defVal) const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description. More... | |
double | eps () const |
Returns the zero tolerance. More... | |
void | eps (double e) |
Sets the zero tolerance to e. More... | |
bool | equal (double x, double y) const |
Returns whether the absolute difference between x and y is less than the machine dependent zero tolerance. More... | |
int | findParameter (const char *name, const char *feasible) const |
See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description. More... | |
int | findParameter (const char *name, unsigned nFeasible, const char *feasible[]) const |
See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description. More... | |
int | findParameter (const char *name, unsigned nFeasible, const int *feasible) const |
Searches for parameter name in the parameter table. More... | |
int | getParameter (const char *name, bool ¶m) const |
int | getParameter (const char *name, char ¶m) const |
int | getParameter (const char *name, double ¶m) const |
int | getParameter (const char *name, int ¶m) const |
Searches for parameter name in the parameter table and returns its value in param. More... | |
int | getParameter (const char *name, string ¶m) const |
int | getParameter (const char *name, unsigned int ¶m) const |
double | infinity () const |
Provides a floating point value of "infinite" size. More... | |
void | infinity (double x) |
Sets the "infinite value" to x. More... | |
void | insertParameter (const char *name, const char *value) |
Inserts parameter name with value value into the parameter table. More... | |
bool | isInfinity (double x) const |
Returns true if x is regarded as "infinite" large, false otherwise. More... | |
bool | isInteger (double x) const |
Returns whether the value x differs at most by the machine dependent zero tolerance from an integer value. More... | |
bool | isInteger (double x, double eps) const |
Returns whether the value x differs at most by eps from an integer value. More... | |
bool | isMinusInfinity (double x) const |
Returns true if x is regarded as infinite small, false otherwise. More... | |
double | machineEps () const |
Provides a machine dependent zero tolerance. More... | |
void | machineEps (double e) |
Sets the machine dependent zero tolerance to e. More... | |
void | readParameters (const string &fileName) |
Opens the parameter file fileName, reads all parameters, and inserts them in the parameter table. More... | |
Public Member Functions inherited from abacus::AbacusRoot | |
virtual | ~AbacusRoot () |
The destructor. More... | |
Private Member Functions | |
AbacusGlobal (const AbacusGlobal &rhs) | |
const AbacusGlobal & | operator= (const AbacusGlobal &rhs) |
Private Attributes | |
double | eps_ |
A zero tolerance. More... | |
double | infinity_ |
An "infinite" big number. More... | |
double | machineEps_ |
The machine dependent zero tolerance, which is used to , e.g., to test if a floating point value is 0. More... | |
AbaHash< string, string > | paramTable_ |
Friends | |
std::ostream & | operator<< (std::ostream &out, const AbacusGlobal &rhs) |
The output operator writes some of the data members to an ouput stream out. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from abacus::AbacusRoot | |
static bool | ascii2bool (const string &str) |
Converts the string str to a boolean value. More... | |
static bool | endsWith (const string &str, const string &end) |
Returns true if str ends with end, false otherwise. More... | |
static double | fracPart (double x) |
Returns the absolute value of the fractional part of x. More... | |
static const char * | onOff (bool value) |
Converts a boolean variable to the strings "on" and "off". More... | |
Global data and functions.
This class stores global data (e.g., a zero tolerance, an output stream, a table with system parameters) und functions operating with this data. For each application there is usually one global object and almost every object in this system has a pointer to an associated global object or a pointer to an object of a class derived from AbacusGlobal (e.g., Master).
Like the class AbacusRoot, the class AbacusGlobal helps us to avoid names with global scope.
We assume that a set of parameters is associated with every application. These parameters can either be given by ABACUS system classes or can be user defined. The class AbacusGlobal contains a table for the storage of the literal values of the parameters. Moreover, functions are provided for assigning the literal valued parameters to specific types.
|
inline |
The constructor.
Initializes our filtered output and error stream with the standard output stream std::cout and the standard error stream std::cerr.
eps | The zero-tolerance used within all member functions of objects which have a pointer to this global object (default value 1.0e-4). |
machineEps | The machine dependent zero tolerance (default value 1.0e-7). |
infinity | All values greater than infinity are regarded as "infinite big", all values less than -infinity are regarded as "infinite small" (default value 1.0e32). Please note that this value might be different from the value the LP-solver uses internally. You should make sure that the value used here is always greater than or equal to the value used by the solver. |
|
inlinevirtual |
|
private |
void abacus::AbacusGlobal::assignParameter | ( | bool & | param, |
const char * | name | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void abacus::AbacusGlobal::assignParameter | ( | bool & | param, |
const char * | name, | ||
bool | defVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void abacus::AbacusGlobal::assignParameter | ( | char & | param, |
const char * | name, | ||
const char * | feasible, | ||
char | defVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
param | The variable param receives the value of the parameter. |
name | The name of the parameter. |
feasible | A string containing all feasible settings. If feasible is zero, then all settings are allowed. |
defVal | The default value that is used when the paramter is not found in the parameter table. |
void abacus::AbacusGlobal::assignParameter | ( | char & | param, |
const char * | name, | ||
const char * | feasible = nullptr |
||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
param | The variable param receives the value of the parameter. |
name | The name of the parameter. |
feasible | A string consisting of all feasible characters. If feasible is zero, then all characters are allowed. |
void abacus::AbacusGlobal::assignParameter | ( | double & | param, |
const char * | name, | ||
double | minVal, | ||
double | maxVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void abacus::AbacusGlobal::assignParameter | ( | double & | param, |
const char * | name, | ||
double | minVal, | ||
double | maxVal, | ||
double | defVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void abacus::AbacusGlobal::assignParameter | ( | int & | param, |
const char * | name, | ||
int | minVal, | ||
int | maxVal | ||
) | const |
Searches for parameter name in the parameter table and returns its value in param.
If no parameter name is found and no default value of the parameter is given, the program terminates with an error messages. The program terminates also with an error message if the value of a parameter is not within a specified feasible region. Depending on the type of the parameter, a feasible region can be an interval (specified by minVal and maxVal) or can be given by a set of feasible settings (given by a number nFeasible and a pointer feasible to the feasible values.
This function is overloaded in two ways. First, this function is defined for different types of the argument parameter, second, for each such type we have both versions, with and without a default value of the parameter.
param | The variable parameter receives the value of the parameter. |
name | The name of the parameter. |
minVal | The value of the parameter is considered as infeasible if it is less than minVal. |
maxVal | The value of the parameter is considered as infeasible if it is larger than maxVal. |
void abacus::AbacusGlobal::assignParameter | ( | int & | param, |
const char * | name, | ||
int | minVal, | ||
int | maxVal, | ||
int | defVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
param | The variable parameter receives the value of the parameter. |
name | The name of the parameter. |
minVal | The value of the parameter is considered as infeasible if it is less than minVal. |
maxVal | The value of the parameter is considered as infeasible if it is larger than maxVal. |
defVal | The default value that is used when the paramter is not found in the parameter table. |
void abacus::AbacusGlobal::assignParameter | ( | string & | param, |
const char * | name, | ||
unsigned | nFeasible, | ||
const char * | feasible[], | ||
const char * | defVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
param | The variable parameter receives the value of the parameter. |
name | The name of the parameter. |
nFeasible | The number of feasible settings. If nFeasible is equal to zero, then all settings are allowed. |
feasible | The settings for the parameter to be considered as feasible. Must be an array of nFeasible strings. |
defVal | The default value that is used when the paramter is not found in the parameter table. |
void abacus::AbacusGlobal::assignParameter | ( | string & | param, |
const char * | name, | ||
unsigned | nFeasible = 0 , |
||
const char * | feasible[] = nullptr |
||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
param | The variable parameter receives the value of the parameter. |
name | The name of the parameter. |
nFeasible | The number of feasible settings. If nFeasible is equal to zero, then all values are allowed. 0 is the default value. |
feasible | If nFeasible is greater zero, the this are the settings for the parameter to be considered as feasible. Must be an array of nFeasible strings. |
void abacus::AbacusGlobal::assignParameter | ( | unsigned & | param, |
const char * | name, | ||
unsigned | minVal, | ||
unsigned | maxVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void abacus::AbacusGlobal::assignParameter | ( | unsigned & | param, |
const char * | name, | ||
unsigned | minVal, | ||
unsigned | maxVal, | ||
unsigned | defVal | ||
) | const |
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
|
inline |
|
inline |
|
inline |
int abacus::AbacusGlobal::findParameter | ( | const char * | name, |
const char * | feasible | ||
) | const |
See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description.
int abacus::AbacusGlobal::findParameter | ( | const char * | name, |
unsigned | nFeasible, | ||
const char * | feasible[] | ||
) | const |
See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description.
int abacus::AbacusGlobal::findParameter | ( | const char * | name, |
unsigned | nFeasible, | ||
const int * | feasible | ||
) | const |
Searches for parameter name in the parameter table.
If no parameter name is found the function throws an exception. The function also throws an exception if the value of a parameter is not within a given list of feasible settings. This function is overloaded and can be used for different types of parameters such as integer valued, char valued and string parameters.
name | The name of the parameter. |
nFeasible | The number of feasible settings. |
feasible | The settings for the parameter to be considered as feasible. Must be an array of nFeasible strings. |
int abacus::AbacusGlobal::getParameter | ( | const char * | name, |
bool & | param | ||
) | const |
int abacus::AbacusGlobal::getParameter | ( | const char * | name, |
char & | param | ||
) | const |
int abacus::AbacusGlobal::getParameter | ( | const char * | name, |
double & | param | ||
) | const |
int abacus::AbacusGlobal::getParameter | ( | const char * | name, |
int & | param | ||
) | const |
Searches for parameter name in the parameter table and returns its value in param.
This function is overloaded for different types of the argument parameter. See also the functions assignParameter and findParameter with enhanced functionality.
name | The name of the parameter. |
param | The variable parameter receives the value of the parameter, if the function returns 1, otherwise it is undefined. |
int abacus::AbacusGlobal::getParameter | ( | const char * | name, |
string & | param | ||
) | const |
int abacus::AbacusGlobal::getParameter | ( | const char * | name, |
unsigned int & | param | ||
) | const |
|
inline |
Provides a floating point value of "infinite" size.
Especially, we assume that -infinity() is the lower and infinity() is the upper bound of an unbounded variable in the linear program.
|
inline |
Sets the "infinite value" to x.
Please note that this value might be different from the value the LP-solver uses internally. You should make sure that the value used here is always greater than or equal to the value used by the solver.
x | The new value representing "infinity". |
void abacus::AbacusGlobal::insertParameter | ( | const char * | name, |
const char * | value | ||
) |
Inserts parameter name with value value into the parameter table.
If the parameter is already in the table, the value is overwritten.
name | The name of the parameter. |
value | The value of the parameter. |
|
inline |
|
inline |
bool abacus::AbacusGlobal::isInteger | ( | double | x, |
double | eps | ||
) | const |
Returns whether the value x differs at most by eps from an integer value.
|
inline |
|
inline |
Provides a machine dependent zero tolerance.
The machine dependent zero tolerance is used, e.g., to test if a floating point value is 0. This value is usually less than eps(), which provides, e.g., a safety tolerance if a constraint is violated.
|
inline |
|
private |
void abacus::AbacusGlobal::readParameters | ( | const string & | fileName | ) |
Opens the parameter file fileName, reads all parameters, and inserts them in the parameter table.
A parameter file may have at most 1024 characters per line.
fileName | The name of the parameter file. |
|
friend |
The output operator writes some of the data members to an ouput stream out.
out | The output stream. |
rhs | The object being output. |
|
private |
|
private |
|
private |
|
private |