12#include <unordered_map>
52 [[nodiscard]]
const std::vector<std::string>&
alternatives()
const;
54 [[nodiscard]]
bool empty()
const;
61 bool ignore_missing =
false);
64 const std::string& new_name);
98 [[nodiscard]]
const std::string&
name() const noexcept {
return name_; }
116 [[nodiscard]]
bool invert() const noexcept {
return invert_; }
136 const std::string& dest_cluster)
const;
145 const std::string& dest_cluster)
const;
152 const std::string& dest_cluster)
const;
166 const std::string& dest_cluster);
169 const std::string& dest_cluster)
const;
179 return subnetwork_.get();
183 return subnetwork_ !=
nullptr;
195 std::string description_;
196 bool invert_ =
false;
197 std::map<std::string, NodePrioritizerSlot> node_prioritizers_;
198 std::unique_ptr<AnpNetwork> subnetwork_;
214 [[nodiscard]]
const std::string&
name() const noexcept {
return name_; }
227 [[nodiscard]] std::size_t
nnodes() const noexcept {
return nodes_.size(); }
257 [[nodiscard]] std::vector<AnpNode*>
nodes();
259 [[nodiscard]] std::vector<const AnpNode*>
nodes()
const;
271 return user_prioritizers_;
274 [[nodiscard]]
const std::map<std::string, PairwiseJudgments>&
276 return user_prioritizers_;
287 std::string description_;
288 std::vector<std::unique_ptr<AnpNode>> nodes_;
290 std::map<std::string, PairwiseJudgments> user_prioritizers_;
333 return alts_cluster_;
360 const std::string& a,
361 const std::string& b,
365 const std::string& a,
366 const std::string& b,
374 const std::string& dest_cluster,
381 const std::string& alt,
382 const std::string& category_id);
388 const std::string& alt,
399 void rename_node(
const std::string& old_name,
const std::string& new_name);
409 [[nodiscard]]
const std::string&
name() const noexcept {
return name_; }
428 synthesis_ = std::move(options);
439 return limit_options_;
443 limit_options_ = std::move(options);
466 [[nodiscard]] std::size_t
nnodes()
const;
469 return clusters_.size();
478 [[nodiscard]] std::vector<const AnpCluster*>
clusters()
const;
480 [[nodiscard]] std::vector<AnpNode*>
nodes();
482 [[nodiscard]] std::vector<const AnpNode*>
nodes()
const;
505 [[nodiscard]] std::vector<std::string>
alt_names()
const;
522 const std::string& wrt_node,
529 const std::string& wrt_node,
538 const std::string& wrt_node,
539 double delta_up = 0.1,
540 double delta_down = 0.1,
552 int round_to_decimal = 5,
582 const std::string& wrt_node,
598 [[nodiscard]]
const std::vector<JudgmentParticipant>&
participants()
const {
599 return participants_;
603 return participants_;
617 session_ = std::move(session);
626 std::string email = {});
633 const std::string&
id)
const;
637 std::vector<std::string> member_ids = {});
638 void remove_judgment_group(
const std::string&
id);
639 [[nodiscard]]
JudgmentGroup* find_judgment_group(
const std::string&
id);
641 const std::string&
id)
const;
669 const std::string& wrt_node,
670 const std::string& a,
671 const std::string& b,
676 const std::string& wrt_cluster,
677 const std::string& a,
678 const std::string& b,
683 const std::string& wrt_node,
684 const std::string& alt,
685 const std::string& category_id);
689 const std::string& wrt_node,
690 const std::string& alt,
698 void unregister_node(
const std::string&
name);
699 [[nodiscard]] std::size_t node_index(
const std::string&
name)
const;
701 [[nodiscard]] std::vector<std::size_t> cluster_row_indices(
702 const std::string& node_name)
const;
707 [[nodiscard]]
Vector subnet_synthesize_from_global(
711 [[nodiscard]]
Vector subnet_synthesize(
714 void rebuild_effective_judgments_local();
715 void migrate_effective_into_default_user();
717 std::vector<std::unique_ptr<AnpCluster>> clusters_;
719 std::unordered_map<std::string, AnpNode*> node_index_;
721 std::string description_;
724 std::map<std::string, std::pair<double, double>> cluster_positions_;
725 std::map<std::string, std::pair<double, double>> node_positions_;
726 std::vector<JudgmentParticipant> participants_;
727 std::vector<JudgmentGroup> groups_;
A group of nodes (and cluster-level pairwise comparisons).
Definition network.hpp:204
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:225
AnpNode & node(const std::string &name)
const PairwiseJudgments & cluster_pairwise() const
Const overload of cluster_pairwise.
Definition network.hpp:266
std::size_t nnodes() const noexcept
Definition network.hpp:227
std::vector< std::string > node_names() const
PairwiseJudgments & cluster_pairwise()
Definition network.hpp:264
AnpCluster(AnpNetwork *network, std::string name)
Constructs a cluster (normally via AnpNetwork::add_cluster).
const std::map< std::string, PairwiseJudgments > & user_cluster_pairwise() const
Const overload.
Definition network.hpp:275
std::vector< AnpNode * > nodes()
std::vector< const AnpNode * > nodes() const
void set_description(std::string description)
Sets cluster description.
Definition network.hpp:220
const AnpNode * find_node(const std::string &name) const
Const overload of find_node.
PairwiseJudgments & ensure_user_cluster_pairwise(const std::string &user_id)
Ensures identity pairwise for user_id matching cluster alts.
const std::string & name() const noexcept
Definition network.hpp:214
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:216
void cluster_connect(AnpCluster *dest)
Connects this cluster to dest (enables cluster pairwise).
std::map< std::string, PairwiseJudgments > & user_cluster_pairwise()
Definition network.hpp:270
const AnpNode & node(const std::string &name) const
Const overload of node.
Root ANP model: structure, judgments, supermatrices, and priorities.
Definition network.hpp:296
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.
std::vector< std::string > session_member_ids() const
Participant ids contributing under the current session.
void set_judgment_session(JudgmentSession session)
Sets session scope (does not rebuild; call rebuild_effective_judgments).
Definition network.hpp:616
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< InfluenceTotalEntry > influence_total(double delta=0.25, const LimitMatrixOptions &options={}) const
Fixed-distance total influence for each node (row).
std::vector< std::string > alt_names() const
const LimitMatrixOptions & limit_matrix_options() const noexcept
Definition network.hpp:438
AnpCluster & add_cluster(const std::string &name)
Adds a cluster.
void remove_participant(const std::string &id)
Removes participant and their judgment tables.
const SynthesisOptions & synthesis_options() const noexcept
Definition network.hpp:423
AnpNetwork & subnet(const std::string &node_name)
const std::string & description() const noexcept
Definition network.hpp:414
void set_node_rating_value_for(const std::string &user_id, const std::string &wrt_node, const std::string &alt, double raw)
Sets numeric rating for user_id.
Matrix cluster_weight_matrix() const
std::size_t nnodes() const
JudgmentParticipant & add_participant(std::string id, std::string name, std::string email={})
Adds a participant if id is new.
JudgmentParticipant * find_participant(const std::string &id)
std::vector< JudgmentGroup > & judgment_groups()
Definition network.hpp:610
void set_cluster_comparison_for(const std::string &user_id, const std::string &wrt_cluster, const std::string &a, const std::string &b, double value)
Sets cluster pairwise for user_id.
AnpNode & add_node(const std::string &cluster_name, const std::string &node_name)
Adds a node to cluster_name.
std::vector< AnpCluster * > clusters()
const std::vector< JudgmentParticipant > & participants() const
Definition network.hpp:598
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.
const std::vector< JudgmentGroup > & judgment_groups() const
Definition network.hpp:606
void rename_cluster(const std::string &old_name, const std::string &new_name)
Renames a cluster network-wide (judgment keys, layout).
void clear_subnetwork(const std::string &node_name)
Clears a node's subnetwork.
AnpNetwork(bool create_alts_cluster=true)
Constructs an empty network.
void ensure_multiuser_initialized()
Ensures every participant has user tables on existing links; migrates legacy effective-only data into...
std::vector< const AnpNode * > nodes() const
void rename_node(const std::string &old_name, const std::string &new_name)
Renames a node network-wide (index, judgments, layout).
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).
Vector priority_at_p(const std::string &wrt_node, double p, const P0Mode &p0mode=P0Mode::Direct(0.5), const LimitMatrixOptions &options={}) const
Ordered alternative scores from priority_map_at_p.
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.
void set_limit_matrix_options(LimitMatrixOptions options)
Sets the network default limit-matrix options.
Definition network.hpp:442
AnpNode * find_node(const std::string &name)
std::vector< InfluenceRawEntry > influence_raw(const std::string &wrt_node, double delta_up=0.1, double delta_down=0.1, double p0=0.5, const LimitMatrixOptions &options={}) const
Raw fixed-distance influence on alternative scores (incl.
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.
std::vector< InfluenceMarginalEntry > influence_marginal_smart(double delta=1e-6, const LimitMatrixOptions &options={}) const
Smart-(p_0) marginal influence score for each node (row).
const AnpNode * find_node(const std::string &name) const
Const overload of find_node.
Vector perspective(const std::string &wrt_node, const P0Mode &p0mode=P0Mode::Direct(0.5), const LimitMatrixOptions &options={}) const
Perspective of one node: limit as p approaches 1 of row sensitivity.
AnpNode & node(const std::string &name)
std::vector< InfluenceRankEntry > influence_rank(double error=1e-5, int round_to_decimal=5, const LimitMatrixOptions &options={}) const
Rank influence score for each node (row) in this network.
void set_synthesis_options(SynthesisOptions options)
Sets synthesis options.
Definition network.hpp:427
std::vector< const AnpCluster * > clusters() const
void set_name(std::string name)
Sets the network display name.
Definition network.hpp:411
Matrix perspective_matrix(const P0Mode &p0mode=P0Mode::Direct(0.5), const LimitMatrixOptions &options={}) const
Perspective matrix: column j is perspective for node j.
void set_node_position(const std::string &name, double x, double y)
Stores node canvas position (ignored by calculations).
void set_node_comparison_for(const std::string &user_id, const std::string &wrt_node, const std::string &a, const std::string &b, double value)
Sets node pairwise for user_id (creates connections as needed).
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:468
const JudgmentSession & judgment_session() const
Definition network.hpp:612
std::vector< AnpNode * > nodes()
const std::string & name() const noexcept
Definition network.hpp:409
std::vector< JudgmentParticipant > & participants()
Definition network.hpp:602
const JudgmentParticipant * find_participant(const std::string &id) const
Const overload.
static constexpr const char * kDefaultAlternativesCluster
Default name for the alternatives cluster when auto-created.
Definition network.hpp:299
void set_description(std::string description)
Sets the network description.
Definition network.hpp:418
void rebuild_effective_judgments()
Rebuilds all effective pairwise/ratings slots from user tables and the current judgment_session.
std::map< std::string, double > priority_map_at_p(const std::string &wrt_node, double p, const P0Mode &p0mode=P0Mode::Direct(0.5), const LimitMatrixOptions &options={}) const
Alternative scores after ANP row sensitivity at parameter p.
AnpCluster * alternatives_cluster() const noexcept
Definition network.hpp:332
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
void set_node_rating_for(const std::string &user_id, const std::string &wrt_node, const std::string &alt, const std::string &category_id)
Sets categorical rating for user_id.
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:87
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:118
bool invert() const noexcept
Definition network.hpp:116
NodePrioritizerKind node_prioritizer_kind(const std::string &dest_cluster) const
Prioritizer kind for dest_cluster.
AnpNetwork * subnetwork() const noexcept
Definition network.hpp:178
const std::string & description() const noexcept
Definition network.hpp:100
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:182
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:111
AnpCluster * cluster() const noexcept
Definition network.hpp:109
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:104
const std::string & name() const noexcept
Definition network.hpp:98
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.
Multi-user judgment participants, groups, scope, and aggregation.
Analytic Network Process computational library.
Definition eigen.hpp:14
NodePrioritizerKind
Active prioritizer kind for a node → destination-cluster link.
Definition network.hpp:29
Named pairwise comparison tables.
Ratings-based node prioritizers (categorical or numeric).
ANP row sensitivity and influence (ported from pyanp.rowsens).
Named subset of participants for group-scope analysis.
Definition multiuser.hpp:26
A judge on a model (model-scoped, not an app account).
Definition multiuser.hpp:19
Document session: which judgments are active for editing/calc.
Definition multiuser.hpp:47
Options for limit-matrix calculation.
Definition limit_matrix.hpp:30
Stores either pairwise or ratings judgments for one dest cluster.
Definition network.hpp:38
bool has_alternative(const std::string &name) const
void rename_alternative(const std::string &old_name, const std::string &new_name)
Renames an alternative in the active prioritizer and user tables.
void set_kind(NodePrioritizerKind new_kind)
Switches kind, preserving the alternative name list.
void sync_ratings_scale_to_users()
Syncs categories/interpreter/mode from ratings into all users.
void add_alternative(const std::string &name, bool ignore_existing=false)
Adds name to the active prioritizer and all user tables.
RatingsPrioritizer & ensure_user_ratings(const std::string &user_id)
Ensures a user ratings table exists for user_id.
PairwiseJudgments & ensure_user_pairwise(const std::string &user_id)
Ensures a user pairwise table exists (identity) for user_id.
void remove_alternative(const std::string &name, bool ignore_missing=false)
Removes name from the active prioritizer and all user tables.
std::map< std::string, PairwiseJudgments > user_pairwise
Per-participant pairwise (same alternatives as pairwise).
Definition network.hpp:43
Vector priorities() const
const std::vector< std::string > & alternatives() const
std::map< std::string, RatingsPrioritizer > user_ratings
Per-participant ratings votes.
Definition network.hpp:49
(p_0) selection for row_adjust.
Definition rowsens.hpp:34
static P0Mode Direct(double p0)
Definition rowsens.hpp:42
Synthesis configuration for networks with subnetworks.
Definition synthesis.hpp:30
Combining subnetwork alternative scores.