Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
abacus::AbacusGlobal Class Reference

Global data and functions. More...

#include <ogdf/lib/abacus/global.h>

+ Inheritance diagram for abacus::AbacusGlobal:

Public Member Functions

 AbacusGlobal (double eps=1.0e-4, double machineEps=1.0e-7, double infinity=1.0e32)
 The constructor.
 
virtual ~AbacusGlobal ()
 The destructor.
 
void assignParameter (bool &param, const char *name) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void assignParameter (bool &param, const char *name, bool defVal) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void assignParameter (char &param, const char *name, const char *feasible, char defVal) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void assignParameter (char &param, const char *name, const char *feasible=nullptr) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void assignParameter (double &param, const char *name, double minVal, double maxVal) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void 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 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.
 
void assignParameter (int &param, const char *name, int minVal, int maxVal, int defVal) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void 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.
 
void 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.
 
void assignParameter (unsigned &param, const char *name, unsigned minVal, unsigned maxVal) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
void assignParameter (unsigned &param, const char *name, unsigned minVal, unsigned maxVal, unsigned defVal) const
 See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
 
double eps () const
 Returns the zero tolerance.
 
void eps (double e)
 Sets the zero tolerance to e.
 
bool equal (double x, double y) const
 Returns whether the absolute difference between x and y is less than the machine dependent zero tolerance.
 
int findParameter (const char *name, const char *feasible) const
 See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description.
 
int findParameter (const char *name, unsigned nFeasible, const char *feasible[]) const
 See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description.
 
int findParameter (const char *name, unsigned nFeasible, const int *feasible) const
 Searches for parameter name in the parameter table.
 
int getParameter (const char *name, bool &param) const
 
int getParameter (const char *name, char &param) const
 
int getParameter (const char *name, double &param) const
 
int getParameter (const char *name, int &param) const
 Searches for parameter name in the parameter table and returns its value in param.
 
int getParameter (const char *name, string &param) const
 
int getParameter (const char *name, unsigned int &param) const
 
double infinity () const
 Provides a floating point value of "infinite" size.
 
void infinity (double x)
 Sets the "infinite value" to x.
 
void insertParameter (const char *name, const char *value)
 Inserts parameter name with value value into the parameter table.
 
bool isInfinity (double x) const
 Returns true if x is regarded as "infinite" large, false otherwise.
 
bool isInteger (double x) const
 Returns whether the value x differs at most by the machine dependent zero tolerance from an integer value.
 
bool isInteger (double x, double eps) const
 Returns whether the value x differs at most by eps from an integer value.
 
bool isMinusInfinity (double x) const
 Returns true if x is regarded as infinite small, false otherwise.
 
double machineEps () const
 Provides a machine dependent zero tolerance.
 
void machineEps (double e)
 Sets the machine dependent zero tolerance to e.
 
void readParameters (const string &fileName)
 Opens the parameter file fileName, reads all parameters, and inserts them in the parameter table.
 
- Public Member Functions inherited from abacus::AbacusRoot
virtual ~AbacusRoot ()
 The destructor.
 

Private Member Functions

 AbacusGlobal (const AbacusGlobal &rhs)
 
const AbacusGlobaloperator= (const AbacusGlobal &rhs)
 

Private Attributes

double eps_
 A zero tolerance.
 
double infinity_
 An "infinite" big number.
 
double machineEps_
 The machine dependent zero tolerance, which is used to , e.g., to test if a floating point value is 0.
 
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.
 

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.
 
static bool endsWith (const string &str, const string &end)
 Returns true if str ends with end, false otherwise.
 
static double fracPart (double x)
 Returns the absolute value of the fractional part of x.
 
static const charonOff (bool value)
 Converts a boolean variable to the strings "on" and "off".
 

Detailed Description

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.

Definition at line 57 of file global.h.

Constructor & Destructor Documentation

◆ AbacusGlobal() [1/2]

abacus::AbacusGlobal::AbacusGlobal ( double  eps = 1.0e-4,
double  machineEps = 1.0e-7,
double  infinity = 1.0e32 
)
inline

The constructor.

Initializes our filtered output and error stream with the standard output stream std::cout and the standard error stream std::cerr.

Parameters
epsThe zero-tolerance used within all member functions of objects which have a pointer to this global object (default value 1.0e-4).
machineEpsThe machine dependent zero tolerance (default value 1.0e-7).
infinityAll 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.

Definition at line 75 of file global.h.

◆ ~AbacusGlobal()

virtual abacus::AbacusGlobal::~AbacusGlobal ( )
inlinevirtual

The destructor.

Definition at line 87 of file global.h.

◆ AbacusGlobal() [2/2]

abacus::AbacusGlobal::AbacusGlobal ( const AbacusGlobal rhs)
private

Member Function Documentation

◆ assignParameter() [1/12]

void abacus::AbacusGlobal::assignParameter ( bool param,
const char name 
) const

See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.

◆ assignParameter() [2/12]

void abacus::AbacusGlobal::assignParameter ( bool param,
const char name,
bool  defVal 
) const

See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.

◆ assignParameter() [3/12]

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.

Parameters
paramThe variable param receives the value of the parameter.
nameThe name of the parameter.
feasibleA string containing all feasible settings. If feasible is zero, then all settings are allowed.
defValThe default value that is used when the paramter is not found in the parameter table.

◆ assignParameter() [4/12]

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.

Parameters
paramThe variable param receives the value of the parameter.
nameThe name of the parameter.
feasibleA string consisting of all feasible characters. If feasible is zero, then all characters are allowed.

◆ assignParameter() [5/12]

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.

◆ assignParameter() [6/12]

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.

◆ assignParameter() [7/12]

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.

Parameters
paramThe variable parameter receives the value of the parameter.
nameThe name of the parameter.
minValThe value of the parameter is considered as infeasible if it is less than minVal.
maxValThe value of the parameter is considered as infeasible if it is larger than maxVal.

◆ assignParameter() [8/12]

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.

Parameters
paramThe variable parameter receives the value of the parameter.
nameThe name of the parameter.
minValThe value of the parameter is considered as infeasible if it is less than minVal.
maxValThe value of the parameter is considered as infeasible if it is larger than maxVal.
defValThe default value that is used when the paramter is not found in the parameter table.

◆ assignParameter() [9/12]

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.

Parameters
paramThe variable parameter receives the value of the parameter.
nameThe name of the parameter.
nFeasibleThe number of feasible settings. If nFeasible is equal to zero, then all settings are allowed.
feasibleThe settings for the parameter to be considered as feasible. Must be an array of nFeasible strings.
defValThe default value that is used when the paramter is not found in the parameter table.

◆ assignParameter() [10/12]

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.

Parameters
paramThe variable parameter receives the value of the parameter.
nameThe name of the parameter.
nFeasibleThe number of feasible settings. If nFeasible is equal to zero, then all values are allowed. 0 is the default value.
feasibleIf nFeasible is greater zero, the this are the settings for the parameter to be considered as feasible. Must be an array of nFeasible strings.

◆ assignParameter() [11/12]

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.

◆ assignParameter() [12/12]

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.

◆ eps() [1/2]

double abacus::AbacusGlobal::eps ( ) const
inline

Returns the zero tolerance.

Definition at line 127 of file global.h.

◆ eps() [2/2]

void abacus::AbacusGlobal::eps ( double  e)
inline

Sets the zero tolerance to e.

Parameters
eThe new value of the zero tolerance.

Definition at line 133 of file global.h.

◆ equal()

bool abacus::AbacusGlobal::equal ( double  x,
double  y 
) const
inline

Returns whether the absolute difference between x and y is less than the machine dependent zero tolerance.

Parameters
xThe first value being compared.
yThe second value being compared.

Definition at line 196 of file global.h.

◆ findParameter() [1/3]

int abacus::AbacusGlobal::findParameter ( const char name,
const char feasible 
) const

See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for description.

◆ findParameter() [2/3]

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.

◆ findParameter() [3/3]

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.

Parameters
nameThe name of the parameter.
nFeasibleThe number of feasible settings.
feasibleThe settings for the parameter to be considered as feasible. Must be an array of nFeasible strings.
Returns
The index of the matched feasible setting.

◆ getParameter() [1/6]

int abacus::AbacusGlobal::getParameter ( const char name,
bool param 
) const

◆ getParameter() [2/6]

int abacus::AbacusGlobal::getParameter ( const char name,
char param 
) const

◆ getParameter() [3/6]

int abacus::AbacusGlobal::getParameter ( const char name,
double param 
) const

◆ getParameter() [4/6]

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.

Returns
0 If the parameter is found, 1 otherwise.
Parameters
nameThe name of the parameter.
paramThe variable parameter receives the value of the parameter, if the function returns 1, otherwise it is undefined.

◆ getParameter() [5/6]

int abacus::AbacusGlobal::getParameter ( const char name,
string &  param 
) const

◆ getParameter() [6/6]

int abacus::AbacusGlobal::getParameter ( const char name,
unsigned int param 
) const

◆ infinity() [1/2]

double abacus::AbacusGlobal::infinity ( ) 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.

Returns
A very large floating point number. The default value of infinity() is 1.0e32.

Definition at line 159 of file global.h.

◆ infinity() [2/2]

void abacus::AbacusGlobal::infinity ( double  x)
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.

Parameters
xThe new value representing "infinity".

Definition at line 172 of file global.h.

◆ insertParameter()

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.

Parameters
nameThe name of the parameter.
valueThe value of the parameter.

◆ isInfinity()

bool abacus::AbacusGlobal::isInfinity ( double  x) const
inline

Returns true if x is regarded as "infinite" large, false otherwise.

Parameters
xThe value compared with "infinity".

Definition at line 179 of file global.h.

◆ isInteger() [1/2]

bool abacus::AbacusGlobal::isInteger ( double  x) const
inline

Returns whether the value x differs at most by the machine dependent zero tolerance from an integer value.

Definition at line 202 of file global.h.

◆ isInteger() [2/2]

bool abacus::AbacusGlobal::isInteger ( double  x,
double  eps 
) const

Returns whether the value x differs at most by eps from an integer value.

◆ isMinusInfinity()

bool abacus::AbacusGlobal::isMinusInfinity ( double  x) const
inline

Returns true if x is regarded as infinite small, false otherwise.

Parameters
xThe value compared with "minus infinity".

Definition at line 187 of file global.h.

◆ machineEps() [1/2]

double abacus::AbacusGlobal::machineEps ( ) const
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.

Returns
The machine dependent zero tolerance.

Definition at line 144 of file global.h.

◆ machineEps() [2/2]

void abacus::AbacusGlobal::machineEps ( double  e)
inline

Sets the machine dependent zero tolerance to e.

Parameters
eThe new value of the machine dependent zero tolerance.

Definition at line 150 of file global.h.

◆ operator=()

const AbacusGlobal & abacus::AbacusGlobal::operator= ( const AbacusGlobal rhs)
private

◆ readParameters()

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.

Parameters
fileNameThe name of the parameter file.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const AbacusGlobal rhs 
)
friend

The output operator writes some of the data members to an ouput stream out.

Parameters
outThe output stream.
rhsThe object being output.
Returns
A reference to the output stream.

Member Data Documentation

◆ eps_

double abacus::AbacusGlobal::eps_
private

A zero tolerance.

Definition at line 408 of file global.h.

◆ infinity_

double abacus::AbacusGlobal::infinity_
private

An "infinite" big number.

Definition at line 417 of file global.h.

◆ machineEps_

double abacus::AbacusGlobal::machineEps_
private

The machine dependent zero tolerance, which is used to , e.g., to test if a floating point value is 0.

This value is usually less than eps_, which represents, e.g., a safety tolerance if a constraint is violated.

Definition at line 415 of file global.h.

◆ paramTable_

AbaHash<string, string> abacus::AbacusGlobal::paramTable_
private

Definition at line 419 of file global.h.


The documentation for this class was generated from the following file: