anpcpp 0.1.0
Analytic Network Process computational library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
anpcpp::PairwiseJudgments Class Reference

Square pairwise comparison table over a named list of alternatives. More...

#include <pairwise.hpp>

Public Member Functions

 PairwiseJudgments ()=default
 Default-constructs an empty table.
 
 PairwiseJudgments (std::vector< std::string > alternatives)
 Constructs a table with the given alternative names.
 
std::size_t size () const noexcept
 
bool empty () const noexcept
 
const std::vector< std::string > & alternatives () const noexcept
 
const Matrixmatrix () const noexcept
 
bool has_alternative (const std::string &name) const
 
std::size_t index_of (const std::string &name) const
 
void add_alternative (const std::string &name, bool ignore_existing=false)
 Appends an alternative (diagonal 1).
 
void remove_alternative (const std::string &name, bool ignore_missing=false)
 Removes an alternative and its row/column.
 
void set_comparison (std::size_t i, std::size_t j, double value)
 Sets comparison by index.
 
void set_comparison (const std::string &a, const std::string &b, double value)
 Sets comparison by alternative name.
 
double comparison (std::size_t i, std::size_t j) const
 
double comparison (const std::string &a, const std::string &b) const
 
Vector priorities (const EigenOptions &options={}) const
 
double consistency_ratio (ConsistencyOptions options={}) const
 

Detailed Description

Square pairwise comparison table over a named list of alternatives.

Constructor & Destructor Documentation

◆ PairwiseJudgments()

anpcpp::PairwiseJudgments::PairwiseJudgments ( std::vector< std::string >  alternatives)
explicit

Constructs a table with the given alternative names.

Parameters
alternativesOrdered list of names (diagonal initialized to 1).

Member Function Documentation

◆ add_alternative()

void anpcpp::PairwiseJudgments::add_alternative ( const std::string &  name,
bool  ignore_existing = false 
)

Appends an alternative (diagonal 1).

Parameters
nameAlternative name.
ignore_existingIf true, no-op when already present; else throws.

◆ alternatives()

const std::vector< std::string > & anpcpp::PairwiseJudgments::alternatives ( ) const
inlinenoexcept
Returns
Ordered alternative names.

◆ comparison() [1/2]

double anpcpp::PairwiseJudgments::comparison ( const std::string &  a,
const std::string &  b 
) const
Returns
Comparison value for alternatives a and b.

◆ comparison() [2/2]

double anpcpp::PairwiseJudgments::comparison ( std::size_t  i,
std::size_t  j 
) const
Returns
Comparison value at (i, j).

◆ consistency_ratio()

double anpcpp::PairwiseJudgments::consistency_ratio ( ConsistencyOptions  options = {}) const
Returns
Saaty consistency ratio.

◆ empty()

bool anpcpp::PairwiseJudgments::empty ( ) const
inlinenoexcept
Returns
True if there are no alternatives.

◆ has_alternative()

bool anpcpp::PairwiseJudgments::has_alternative ( const std::string &  name) const
Returns
True if name is in the alternative list.

◆ index_of()

std::size_t anpcpp::PairwiseJudgments::index_of ( const std::string &  name) const
Returns
Index of name.
Exceptions
std::out_of_rangeif not found.

◆ matrix()

const Matrix & anpcpp::PairwiseJudgments::matrix ( ) const
inlinenoexcept
Returns
Underlying comparison matrix.

◆ priorities()

Vector anpcpp::PairwiseJudgments::priorities ( const EigenOptions options = {}) const
Returns
Normalized priority vector from the comparison matrix.

◆ remove_alternative()

void anpcpp::PairwiseJudgments::remove_alternative ( const std::string &  name,
bool  ignore_missing = false 
)

Removes an alternative and its row/column.

Parameters
nameAlternative to remove.
ignore_missingIf true, no-op when absent; else throws.

◆ set_comparison() [1/2]

void anpcpp::PairwiseJudgments::set_comparison ( const std::string &  a,
const std::string &  b,
double  value 
)

Sets comparison by alternative name.

Parameters
aFirst alternative.
bSecond alternative.
valueComparison value (reciprocal applied automatically).

◆ set_comparison() [2/2]

void anpcpp::PairwiseJudgments::set_comparison ( std::size_t  i,
std::size_t  j,
double  value 
)

Sets comparison by index.

Parameters
iRow index.
jColumn index.
valuea_ij; reciprocal set for a_ji unless 0 (incomplete).

◆ size()

std::size_t anpcpp::PairwiseJudgments::size ( ) const
inlinenoexcept
Returns
Number of alternatives (matrix order).

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