12#include <unordered_map>
38 [[nodiscard]]
const std::vector<std::string>&
alternatives()
const;
40 [[nodiscard]]
bool empty()
const;
47 bool ignore_missing =
false);
73 [[nodiscard]]
const std::string&
name() const noexcept {
return name_; }
75 [[nodiscard]]
const std::string&
description() const noexcept {
91 [[nodiscard]]
bool invert() const noexcept {
return invert_; }
111 const std::string& dest_cluster)
const;
120 const std::string& dest_cluster)
const;
127 const std::string& dest_cluster)
const;
141 const std::string& dest_cluster);
144 const std::string& dest_cluster)
const;
154 return subnetwork_.get();
158 return subnetwork_ !=
nullptr;
170 std::string description_;
171 bool invert_ =
false;
172 std::map<std::string, NodePrioritizerSlot> node_prioritizers_;
173 std::unique_ptr<AnpNetwork> subnetwork_;
189 [[nodiscard]]
const std::string&
name() const noexcept {
return name_; }
202 [[nodiscard]] std::size_t
nnodes() const noexcept {
return nodes_.size(); }
232 [[nodiscard]] std::vector<AnpNode*>
nodes();
234 [[nodiscard]] std::vector<const AnpNode*>
nodes()
const;
251 std::string description_;
252 std::vector<std::unique_ptr<AnpNode>> nodes_;
296 return alts_cluster_;
304 void move_node(
const std::string& name, std::size_t new_index);
323 const std::string& a,
324 const std::string& b,
328 const std::string& a,
329 const std::string& b,
337 const std::string& dest_cluster,
344 const std::string& alt,
345 const std::string& category_id);
351 const std::string& alt,
367 synthesis_ = std::move(options);
390 [[nodiscard]] std::size_t
nnodes()
const;
393 return clusters_.size();
402 [[nodiscard]] std::vector<const AnpCluster*>
clusters()
const;
404 [[nodiscard]] std::vector<AnpNode*>
nodes();
406 [[nodiscard]] std::vector<const AnpNode*>
nodes()
const;
429 [[nodiscard]] std::vector<std::string>
alt_names()
const;
443 void unregister_node(
const std::string& name);
444 [[nodiscard]] std::size_t node_index(
const std::string& name)
const;
446 [[nodiscard]]
Vector subnet_synthesize(
449 std::vector<std::unique_ptr<AnpCluster>> clusters_;
451 std::unordered_map<std::string, AnpNode*> node_index_;
453 std::map<std::string, std::pair<double, double>> cluster_positions_;
454 std::map<std::string, std::pair<double, double>> node_positions_;
A group of nodes (and cluster-level pairwise comparisons).
Definition network.hpp:179
AnpNode & add_node(const std::string &name)
Adds a node to this cluster.
AnpNode * find_node(const std::string &name)
AnpNetwork * network() const noexcept
Definition network.hpp:200
AnpNode & node(const std::string &name)
const PairwiseJudgments & cluster_pairwise() const
Const overload of cluster_pairwise.
Definition network.hpp:241
std::size_t nnodes() const noexcept
Definition network.hpp:202
std::vector< std::string > node_names() const
PairwiseJudgments & cluster_pairwise()
Definition network.hpp:239
AnpCluster(AnpNetwork *network, std::string name)
Constructs a cluster (normally via AnpNetwork::add_cluster).
std::vector< AnpNode * > nodes()
std::vector< const AnpNode * > nodes() const
void set_description(std::string description)
Sets cluster description.
Definition network.hpp:195
const AnpNode * find_node(const std::string &name) const
Const overload of find_node.
const std::string & name() const noexcept
Definition network.hpp:189
void move_node(const std::string &name, std::size_t new_index)
Reorders a node within this cluster (preserves pairwise data).
const std::string & description() const noexcept
Definition network.hpp:191
void cluster_connect(AnpCluster *dest)
Connects this cluster to dest (enables cluster pairwise).
const AnpNode & node(const std::string &name) const
Const overload of node.
Root ANP model: structure, judgments, supermatrices, and priorities.
Definition network.hpp:259
std::vector< std::string > cluster_names() const
bool cluster_position(const std::string &name, double &x, double &y) const
Retrieves cluster layout position.
void set_node_prioritizer_kind(const std::string &wrt_node, const std::string &dest_cluster, NodePrioritizerKind kind)
Sets prioritizer kind for wrt_node → dest_cluster.
void move_node(const std::string &name, std::size_t new_index)
Reorders a node within its cluster.
void set_cluster_comparison(const std::string &wrt_cluster, const std::string &a, const std::string &b, double value)
Sets cluster-level pairwise comparison.
std::vector< std::string > alt_names() const
AnpCluster & add_cluster(const std::string &name)
Adds a cluster.
const SynthesisOptions & synthesis_options() const noexcept
Definition network.hpp:362
AnpNetwork & subnet(const std::string &node_name)
Matrix cluster_weight_matrix() const
std::size_t nnodes() const
AnpNode & add_node(const std::string &cluster_name, const std::string &node_name)
Adds a node to cluster_name.
std::vector< AnpCluster * > clusters()
AnpCluster & cluster(const std::string &name)
Vector priority(const LimitMatrixOptions &options={}) const
void node_connect(const std::string &src, const std::string &dest)
Connects two nodes by name.
void clear_subnetwork(const std::string &node_name)
Clears a node's subnetwork.
AnpNetwork(bool create_alts_cluster=true)
Constructs an empty network.
std::vector< const AnpNode * > nodes() const
AnpCluster * find_cluster(const std::string &name)
bool node_position(const std::string &name, double &x, double &y) const
Retrieves node layout position.
void set_cluster_position(const std::string &name, double x, double y)
Stores GUI layout hint (ignored by calculations).
const AnpNode & node(const std::string &name) const
Const overload of node.
void set_node_comparison(const std::string &wrt_node, const std::string &a, const std::string &b, double value)
Sets node pairwise comparison (w.r.t.
AnpNode * find_node(const std::string &name)
void set_node_rating_value(const std::string &wrt_node, const std::string &alt, double raw)
Sets a numeric rating value (ensures connection; switches to ratings).
void node_disconnect(const std::string &src, const std::string &dest)
Disconnects two nodes.
Matrix unscaled_supermatrix() const
AnpNetwork(AnpNetwork &&) noexcept=default
Move constructor.
const AnpNode * find_node(const std::string &name) const
Const overload of find_node.
AnpNode & node(const std::string &name)
void set_synthesis_options(SynthesisOptions options)
Sets synthesis options.
Definition network.hpp:366
std::vector< const AnpCluster * > clusters() const
void set_node_position(const std::string &name, double x, double y)
Stores node canvas position (ignored by calculations).
std::vector< std::string > node_names() const
void remove_node(const std::string &name)
Removes a node and its connections.
std::size_t nclusters() const noexcept
Definition network.hpp:392
std::vector< AnpNode * > nodes()
static constexpr const char * kDefaultAlternativesCluster
Default name for the alternatives cluster when auto-created.
Definition network.hpp:262
AnpCluster * alternatives_cluster() const noexcept
Definition network.hpp:295
void set_node_rating(const std::string &wrt_node, const std::string &alt, const std::string &category_id)
Sets a categorical rating (ensures connection; switches to ratings).
Matrix scaled_supermatrix() const
void set_alternatives_cluster(const std::string &name)
Marks name as the alternatives cluster.
Vector global_priority(const LimitMatrixOptions &options={}) const
Matrix limit_matrix(const LimitMatrixOptions &options={}) const
std::map< std::string, double > priority_map(const LimitMatrixOptions &options={}) const
void remove_cluster(const std::string &name)
Removes a cluster and its nodes.
A decision element within a cluster (may own a subnetwork).
Definition network.hpp:62
NodePrioritizerSlot * node_prioritizer(const std::string &dest_cluster)
Mutable prioritizer slot for dest_cluster, if present.
void set_invert(bool value)
Sets invert flag for subnet synthesis.
Definition network.hpp:93
bool invert() const noexcept
Definition network.hpp:91
NodePrioritizerKind node_prioritizer_kind(const std::string &dest_cluster) const
Prioritizer kind for dest_cluster.
AnpNetwork * subnetwork() const noexcept
Definition network.hpp:153
const std::string & description() const noexcept
Definition network.hpp:75
PairwiseJudgments * node_pairwise(const std::string &dest_cluster)
Pairwise judgments of this node w.r.t.
void disconnect_from(AnpNode *dest)
Removes connection to dest.
bool has_subnetwork() const noexcept
Definition network.hpp:157
AnpNode(AnpNetwork *network, AnpCluster *cluster, std::string name)
Constructs a node (normally called via AnpCluster::add_node).
RatingsPrioritizer * node_ratings(const std::string &dest_cluster)
Ratings judgments of this node w.r.t.
AnpNetwork * network() const noexcept
Definition network.hpp:86
AnpCluster * cluster() const noexcept
Definition network.hpp:84
bool is_connected_to_cluster(const std::string &cluster_name) const
void set_node_prioritizer_kind(const std::string &dest_cluster, NodePrioritizerKind kind)
Sets prioritizer kind for an existing link to dest_cluster.
AnpNetwork & ensure_subnetwork()
Creates subnetwork if absent and returns it.
bool is_connected_to(const AnpNode *dest) const
const RatingsPrioritizer * node_ratings(const std::string &dest_cluster) const
Const overload of node_ratings.
void set_description(std::string description)
Sets the node description.
Definition network.hpp:79
const std::string & name() const noexcept
Definition network.hpp:73
void connect_to(AnpNode *dest)
Creates node-to-node connection (and cluster-level link).
const PairwiseJudgments * node_pairwise(const std::string &dest_cluster) const
Const overload of node_pairwise.
Vector unscaled_column() const
Column of the unscaled supermatrix for this node.
const NodePrioritizerSlot * node_prioritizer(const std::string &dest_cluster) const
Const overload of node_prioritizer.
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
Ratings table over named alternatives for one (wrt node, dest cluster).
Definition ratings.hpp:85
One-dimensional array of doubles with element-wise arithmetic.
Definition matrix.hpp:34
Limit matrix and priority extraction from supermatrices.
Dense row-major vectors and matrices.
Analytic Network Process computational library.
Definition eigen.hpp:14
NodePrioritizerKind
Active prioritizer kind for a node → destination-cluster link.
Definition network.hpp:27
Named pairwise comparison tables.
Ratings-based node prioritizers (categorical or numeric).
Options for limit-matrix calculation.
Definition limit_matrix.hpp:17
Stores either pairwise or ratings judgments for one dest cluster.
Definition network.hpp:32
bool has_alternative(const std::string &name) const
void set_kind(NodePrioritizerKind new_kind)
Switches kind, preserving the alternative name list.
void add_alternative(const std::string &name, bool ignore_existing=false)
Adds name to the active prioritizer.
void remove_alternative(const std::string &name, bool ignore_missing=false)
Removes name from the active prioritizer.
Vector priorities() const
const std::vector< std::string > & alternatives() const
Synthesis configuration for networks with subnetworks.
Definition synthesis.hpp:30
Combining subnetwork alternative scores.