anpcpp 0.1.0
Analytic Network Process computational library
Loading...
Searching...
No Matches
pairwise.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <cstddef>
9#include <string>
10#include <vector>
11
12#include "anpcpp/eigen.hpp"
14#include "anpcpp/matrix.hpp"
15
16namespace anpcpp {
17
22public:
24 PairwiseJudgments() = default;
25
30 explicit PairwiseJudgments(std::vector<std::string> alternatives);
31
33 [[nodiscard]] std::size_t size() const noexcept { return alternatives_.size(); }
35 [[nodiscard]] bool empty() const noexcept { return alternatives_.empty(); }
37 [[nodiscard]] const std::vector<std::string>& alternatives() const noexcept {
38 return alternatives_;
39 }
41 [[nodiscard]] const Matrix& matrix() const noexcept { return matrix_; }
42
44 [[nodiscard]] bool has_alternative(const std::string& name) const;
49 [[nodiscard]] std::size_t index_of(const std::string& name) const;
50
56 void add_alternative(const std::string& name, bool ignore_existing = false);
57
63 void remove_alternative(const std::string& name, bool ignore_missing = false);
64
71 void set_comparison(std::size_t i, std::size_t j, double value);
72
79 void set_comparison(const std::string& a,
80 const std::string& b,
81 double value);
82
84 [[nodiscard]] double comparison(std::size_t i, std::size_t j) const;
86 [[nodiscard]] double comparison(const std::string& a,
87 const std::string& b) const;
88
90 [[nodiscard]] Vector priorities(const EigenOptions& options = {}) const;
91
93 [[nodiscard]] double consistency_ratio(
94 ConsistencyOptions options = {}) const;
95
96private:
97 std::vector<std::string> alternatives_;
98 Matrix matrix_;
99};
100
101} // namespace anpcpp
Dense row-major matrix stored in a flat buffer.
Definition matrix.hpp:136
Square pairwise comparison table over a named list of alternatives.
Definition pairwise.hpp:21
void set_comparison(const std::string &a, const std::string &b, double value)
Sets comparison by alternative name.
bool has_alternative(const std::string &name) const
void set_comparison(std::size_t i, std::size_t j, double value)
Sets comparison by index.
const std::vector< std::string > & alternatives() const noexcept
Definition pairwise.hpp:37
const Matrix & matrix() const noexcept
Definition pairwise.hpp:41
void add_alternative(const std::string &name, bool ignore_existing=false)
Appends an alternative (diagonal 1).
double comparison(std::size_t i, std::size_t j) const
Vector priorities(const EigenOptions &options={}) const
void remove_alternative(const std::string &name, bool ignore_missing=false)
Removes an alternative and its row/column.
bool empty() const noexcept
Definition pairwise.hpp:35
double consistency_ratio(ConsistencyOptions options={}) const
std::size_t index_of(const std::string &name) const
std::size_t size() const noexcept
Definition pairwise.hpp:33
PairwiseJudgments(std::vector< std::string > alternatives)
Constructs a table with the given alternative names.
double comparison(const std::string &a, const std::string &b) const
PairwiseJudgments()=default
Default-constructs an empty table.
One-dimensional array of doubles with element-wise arithmetic.
Definition matrix.hpp:34
Principal eigenvector computation for pairwise matrices.
Saaty consistency index and ratio for pairwise matrices.
Dense row-major vectors and matrices.
Analytic Network Process computational library.
Definition eigen.hpp:14
Options for consistency.
Definition inconsistency.hpp:38
Options controlling principal eigen computation.
Definition eigen.hpp:42