Project
Public Member Functions | Protected Attributes | Friends | List of all members
PerformanceTable Class Reference

PerformanceTable data structure. More...

#include <PerformanceTable.h>

Inheritance diagram for PerformanceTable:
Inheritance graph
[legend]

Public Member Functions

 PerformanceTable (std::vector< std::vector< Perf >> &perf_vect, std::string mode="alt")
 
 PerformanceTable (int nb_of_perfs, Criteria &crits, std::string prefix="alt")
 
 PerformanceTable (const PerformanceTable &perfs)
 
void generateRandomPerfValues (unsigned long int seed=time(NULL), int lower_bound=0, int upper_bound=1)
 
std::vector< std::vector< Perf > > getPerformanceTable () const
 
std::string getMode () const
 
bool isSorted () const
 
std::vector< Perfoperator[] (std::string name)
 
Perf getPerf (std::string name, std::string crit)
 
void sort (std::string mode="crit")
 
void changeMode (std::string mode)
 
std::vector< PerfgetAltBetweenSorted (std::string critId, float inf, float sup)
 
std::vector< PerfgetAltBetween (std::string critId, float inf, float sup)
 
std::vector< PerfgetBestPerfByCrit (Criteria &crits)
 
std::vector< PerfgetWorstPerfByCrit (Criteria &crits)
 
bool isAltInTable (std::string altName)
 
int getNumberCrit ()
 
int getNumberAlt ()
 
void display ()
 
bool operator== (const PerformanceTable &pt) const
 

Protected Attributes

std::vector< std::vector< Perf > > pt_
 
std::string mode_ = "alt"
 
bool sorted_ = false
 

Friends

std::ostream & operator<< (std::ostream &out, const PerformanceTable &perfs)
 

Detailed Description

PerformanceTable data structure.

PerformanceTable is a table of Perf objects. It is a Mathematical datastructure that can be interpreted as a Matrix if a few conditions are met, or a vector of vector if the column order cannot be guaranteed.

The PerformanceTable has to mode of representation: crit and alt.

The Perf table can be interpreted as a Matrix if the second dimension has the same order for all row.

This datastructure was designed to be itterated over easily, thus the access time of a certain element (like in a hashmap) is in O(n_crit * n_alt) which is absolutely inefficient and should be avoided.

Constructor & Destructor Documentation

◆ PerformanceTable() [1/3]

PerformanceTable::PerformanceTable ( std::vector< std::vector< Perf >> &  perf_vect,
std::string  mode = "alt" 
)

PerformanceTable constructor with defined vector of performance that represents the PerformanceTable in a certain mode. All Vector of Perf objects should have the same criteria. Need to give the mode of the Performance table that is either "alt" or "crit".

Parameters
perf_vectVector of performance

◆ PerformanceTable() [2/3]

PerformanceTable::PerformanceTable ( int  nb_of_perfs,
Criteria crits,
std::string  prefix = "alt" 
)

PerformanceTable constructor without perf values but set of criteria to evaluate performance over. perf values will be set to 0.

Parameters
prefixPrefix to use for the name of each Performance created
nb_of_perfsNumber of performance
critsCriteria to evaluate performance over

◆ PerformanceTable() [3/3]

PerformanceTable::PerformanceTable ( const PerformanceTable perfs)

Performances constructor by copy

Parameters
perfsBased performances to copy

Member Function Documentation

◆ changeMode()

void PerformanceTable::changeMode ( std::string  mode)

changeMode Change the assigned mode to the performance table given the selected one: alt or crit. alt mode will assign the first dimension to alt and second to crit. crit mode will assign the first dimension to crit and the second dimension to alt.

Parameters
modeselected pt mode (alt or crit)

◆ display()

void PerformanceTable::display ( )

Display PerformanceTable in a nice manner. Please be advised that this method might be counter intuitive since elements do not necessarly have a correct order depending on the mode

◆ generateRandomPerfValues()

void PerformanceTable::generateRandomPerfValues ( unsigned long int  seed = time(NULL),
int  lower_bound = 0,
int  upper_bound = 1 
)

generateRandomPerfValues set all the Perf values to random

Parameters
seed(optional) Random seed to use in the random generator
lower_bound(optional) lower bound of the generated Perf values
upper_bound(optional) upper bound of the generated Perf values

◆ getAltBetween()

std::vector<Perf> PerformanceTable::getAltBetween ( std::string  critId,
float  inf,
float  sup 
)

getAltBetween return all the alternatives / profiles that have a performance (value) between inf and sup on criterion crit. The performance table does not need to be sorted before calling this function.

Parameters
critIdcrit Id to look for
infinferior boudary
supsuperior boundary
Returns
sub_vect

◆ getAltBetweenSorted()

std::vector<Perf> PerformanceTable::getAltBetweenSorted ( std::string  critId,
float  inf,
float  sup 
)

getAltBetween return all the alternatives / profiles that have a performance (value) between inf and sup on criterion crit. The performance table must have been sorted and in mode crit before calling this function.

Parameters
critIdcrit Id to look for
infinferior boudary
supsuperior boundary
Returns
sub_vect

◆ getBestPerfByCrit()

std::vector<Perf> PerformanceTable::getBestPerfByCrit ( Criteria crits)

getBestPerfByRow return a perf vector with the best performance of the alternatives on each criteria

Parameters
critsCriteria to search in the performance table
Returns
best_pv

◆ getMode()

std::string PerformanceTable::getMode ( ) const

getMode getter of the mode of the performance table

Returns
mode

◆ getNumberAlt()

int PerformanceTable::getNumberAlt ( )

getNumberAlt return the amount of alts in the table

Returns
n_alts

◆ getNumberCrit()

int PerformanceTable::getNumberCrit ( )

getNumberCrit return the amount of crits in the table

Returns
n_crit

◆ getPerf()

Perf PerformanceTable::getPerf ( std::string  name,
std::string  crit 
)

getPerf getter of a specific Perf in the performance table. This is highly inneficient and should not be used except for tests or exceptionnal checks.

Parameters
namename of the alt or profile we want
critname of the crit we want

◆ getPerformanceTable()

std::vector<std::vector<Perf> > PerformanceTable::getPerformanceTable ( ) const

getPerformanceTable getter of performance table parameter

Returns
performance_table

◆ getWorstPerfByCrit()

std::vector<Perf> PerformanceTable::getWorstPerfByCrit ( Criteria crits)

getWorstPerfByRow return a perf vector with the worst performance of the alternatives on each criteria

Parameters
critsCriteria to search in the performance table
Returns
worst_pv

◆ isAltInTable()

bool PerformanceTable::isAltInTable ( std::string  altName)

findAlt return true if the alternative is in the performance table

Parameters
altNameAlternative to lookup
Returns
true if found, false if nots

◆ isSorted()

bool PerformanceTable::isSorted ( ) const

isSorted getter of the sorted variable

Returns
sorted

◆ operator==()

bool PerformanceTable::operator== ( const PerformanceTable pt) const

Overload of == operator for PerformanceTable object. It compares the name, criteria and values of the PerformanceTable.

Parameters
ptPerformanceTable object to compare it with

◆ operator[]()

std::vector<Perf> PerformanceTable::operator[] ( std::string  name)

Overloading [] operator for PerformanceTable. If the current mode is crit, will search for the row with the crit name given. If current mode is alt, will search for the row with the alternative (or profile) name given.

Parameters
namename of the row we want to search
Returns
Performance object with associated criterion

◆ sort()

void PerformanceTable::sort ( std::string  mode = "crit")

sort Sort the performance table given the selected mode: alt or crit. Sorted by alt will assign the first dimension to alt and sort the second by crit. Sorting by crit will assign the first dimension to crit and sort the second dimension by alt.

Parameters
modeselected pt mode (alt or crit)

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