anpcpp 0.4.0
Analytic Network Process computational library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
anpcpp::AnpNetwork Class Reference

Root ANP model: structure, judgments, supermatrices, and priorities. More...

#include <network.hpp>

Public Member Functions

 AnpNetwork (bool create_alts_cluster=true)
 Constructs an empty network.
 
 AnpNetwork (AnpNetwork &&) noexcept=default
 Move constructor.
 
AnpNetworkoperator= (AnpNetwork &&) noexcept=default
 Move assignment.
 
AnpClusteradd_cluster (const std::string &name)
 Adds a cluster.
 
AnpClusterfind_cluster (const std::string &name)
 
const AnpClusterfind_cluster (const std::string &name) const
 Const overload of find_cluster.
 
AnpClustercluster (const std::string &name)
 
const AnpClustercluster (const std::string &name) const
 Const overload of cluster.
 
AnpClusteralternatives_cluster () const noexcept
 
void set_alternatives_cluster (const std::string &name)
 Marks name as the alternatives cluster.
 
AnpNodeadd_node (const std::string &cluster_name, const std::string &node_name)
 Adds a node to cluster_name.
 
void move_node (const std::string &name, std::size_t new_index)
 Reorders a node within its cluster.
 
AnpNodefind_node (const std::string &name)
 
const AnpNodefind_node (const std::string &name) const
 Const overload of find_node.
 
AnpNodenode (const std::string &name)
 
const AnpNodenode (const std::string &name) const
 Const overload of node.
 
void node_connect (const std::string &src, const std::string &dest)
 Connects two nodes by name.
 
void node_disconnect (const std::string &src, const std::string &dest)
 Disconnects two nodes.
 
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_cluster_comparison (const std::string &wrt_cluster, const std::string &a, const std::string &b, double value)
 Sets cluster-level pairwise comparison.
 
void set_node_prioritizer_kind (const std::string &wrt_node, const std::string &dest_cluster, NodePrioritizerKind kind)
 Sets prioritizer kind for wrt_nodedest_cluster.
 
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).
 
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 remove_node (const std::string &name)
 Removes a node and its connections.
 
void remove_cluster (const std::string &name)
 Removes a cluster and its nodes.
 
void rename_node (const std::string &old_name, const std::string &new_name)
 Renames a node network-wide (index, judgments, layout).
 
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.
 
const std::string & name () const noexcept
 
void set_name (std::string name)
 Sets the network display name.
 
const std::string & description () const noexcept
 
void set_description (std::string description)
 Sets the network description.
 
const SynthesisOptionssynthesis_options () const noexcept
 
void set_synthesis_options (SynthesisOptions options)
 Sets synthesis options.
 
const LimitMatrixOptionslimit_matrix_options () const noexcept
 
void set_limit_matrix_options (LimitMatrixOptions options)
 Sets the network default limit-matrix options.
 
void set_cluster_position (const std::string &name, double x, double y)
 Stores GUI layout hint (ignored by calculations).
 
void set_node_position (const std::string &name, double x, double y)
 Stores node canvas position (ignored by calculations).
 
bool cluster_position (const std::string &name, double &x, double &y) const
 Retrieves cluster layout position.
 
bool node_position (const std::string &name, double &x, double &y) const
 Retrieves node layout position.
 
std::size_t nnodes () const
 
std::size_t nclusters () const noexcept
 
std::vector< std::string > cluster_names () const
 
std::vector< std::string > node_names () const
 
std::vector< AnpCluster * > clusters ()
 
std::vector< const AnpCluster * > clusters () const
 
std::vector< AnpNode * > nodes ()
 
std::vector< const AnpNode * > nodes () const
 
Matrix unscaled_supermatrix () const
 
Matrix cluster_weight_matrix () const
 
Matrix scaled_supermatrix () const
 
Matrix limit_matrix (const LimitMatrixOptions &options={}) const
 
Vector global_priority (const LimitMatrixOptions &options={}) const
 
bool has_subnet () const
 
AnpNetworksubnet (const std::string &node_name)
 
std::vector< std::string > alt_names () const
 
Vector priority (const LimitMatrixOptions &options={}) const
 
std::map< std::string, double > priority_map (const LimitMatrixOptions &options={}) const
 
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.
 
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.
 
std::vector< InfluenceRawEntryinfluence_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.
 
std::vector< InfluenceRankEntryinfluence_rank (double error=1e-5, int round_to_decimal=5, const LimitMatrixOptions &options={}) const
 Rank influence score for each node (row) in this network.
 
std::vector< InfluenceMarginalEntryinfluence_marginal_smart (double delta=1e-6, const LimitMatrixOptions &options={}) const
 Smart-(p_0) marginal influence score for each node (row).
 
std::vector< InfluenceTotalEntryinfluence_total (double delta=0.25, const LimitMatrixOptions &options={}) const
 Fixed-distance total influence for each node (row).
 
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.
 
Matrix perspective_matrix (const P0Mode &p0mode=P0Mode::Direct(0.5), const LimitMatrixOptions &options={}) const
 Perspective matrix: column j is perspective for node j.
 
const std::vector< JudgmentParticipant > & participants () const
 
std::vector< JudgmentParticipant > & participants ()
 
const std::vector< JudgmentGroup > & judgment_groups () const
 
std::vector< JudgmentGroup > & judgment_groups ()
 
const JudgmentSessionjudgment_session () const
 
void set_judgment_session (JudgmentSession session)
 Sets session scope (does not rebuild; call rebuild_effective_judgments).
 
JudgmentParticipantadd_participant (std::string id, std::string name, std::string email={})
 Adds a participant if id is new.
 
void remove_participant (const std::string &id)
 Removes participant and their judgment tables.
 
JudgmentParticipantfind_participant (const std::string &id)
 
const JudgmentParticipantfind_participant (const std::string &id) const
 Const overload.
 
std::vector< std::string > session_member_ids () const
 Participant ids contributing under the current session.
 
void rebuild_effective_judgments ()
 Rebuilds all effective pairwise/ratings slots from user tables and the current judgment_session.
 
void ensure_multiuser_initialized ()
 Ensures every participant has user tables on existing links; migrates legacy effective-only data into default if needed.
 
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).
 
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.
 
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.
 
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.
 

Static Public Attributes

static constexpr const char * kDefaultAlternativesCluster = "Alternatives"
 Default name for the alternatives cluster when auto-created.
 

Detailed Description

Root ANP model: structure, judgments, supermatrices, and priorities.

Constructor & Destructor Documentation

◆ AnpNetwork()

anpcpp::AnpNetwork::AnpNetwork ( bool  create_alts_cluster = true)
explicit

Constructs an empty network.

Parameters
create_alts_clusterIf true, creates an "Alternatives" cluster.

Member Function Documentation

◆ add_cluster()

AnpCluster & anpcpp::AnpNetwork::add_cluster ( const std::string &  name)

Adds a cluster.

Exceptions
std::runtime_errorif the name already exists.

◆ add_participant()

JudgmentParticipant & anpcpp::AnpNetwork::add_participant ( std::string  id,
std::string  name,
std::string  email = {} 
)

Adds a participant if id is new.

Returns
Reference to the participant.

◆ alt_names()

std::vector< std::string > anpcpp::AnpNetwork::alt_names ( ) const
Returns
Alternative names (from subnetworks or flat alts cluster).

◆ alternatives_cluster()

AnpCluster * anpcpp::AnpNetwork::alternatives_cluster ( ) const
inlinenoexcept
Returns
The designated alternatives cluster, if any.

◆ cluster()

AnpCluster & anpcpp::AnpNetwork::cluster ( const std::string &  name)
Returns
Named cluster.
Exceptions
std::out_of_rangeif not found.

◆ cluster_names()

std::vector< std::string > anpcpp::AnpNetwork::cluster_names ( ) const
Returns
All cluster names.

◆ cluster_position()

bool anpcpp::AnpNetwork::cluster_position ( const std::string &  name,
double &  x,
double &  y 
) const

Retrieves cluster layout position.

Returns
False if no position stored.

◆ cluster_weight_matrix()

Matrix anpcpp::AnpNetwork::cluster_weight_matrix ( ) const
Returns
Cluster weight matrix.

◆ clusters() [1/2]

std::vector< AnpCluster * > anpcpp::AnpNetwork::clusters ( )
Returns
Cluster pointers.

◆ clusters() [2/2]

std::vector< const AnpCluster * > anpcpp::AnpNetwork::clusters ( ) const
Returns
Const cluster pointers.

◆ description()

const std::string & anpcpp::AnpNetwork::description ( ) const
inlinenoexcept
Returns
Optional description text.

◆ find_cluster()

AnpCluster * anpcpp::AnpNetwork::find_cluster ( const std::string &  name)
Returns
Cluster pointer or nullptr.

◆ find_node()

AnpNode * anpcpp::AnpNetwork::find_node ( const std::string &  name)
Returns
Node pointer or nullptr.

◆ find_participant()

JudgmentParticipant * anpcpp::AnpNetwork::find_participant ( const std::string &  id)
Returns
Participant pointer or nullptr.

◆ global_priority()

Vector anpcpp::AnpNetwork::global_priority ( const LimitMatrixOptions options = {}) const
Returns
Global priority vector from the limit matrix.

◆ has_subnet()

bool anpcpp::AnpNetwork::has_subnet ( ) const
Returns
True if any node has a subnetwork.

◆ influence_marginal_smart()

std::vector< InfluenceMarginalEntry > anpcpp::AnpNetwork::influence_marginal_smart ( double  delta = 1e-6,
const LimitMatrixOptions options = {} 
) const

Smart-(p_0) marginal influence score for each node (row).

Per row: L1 of absolute per-alternative smart marginals; representative smart (p_0) is that of the alternative with largest absolute marginal.

◆ influence_rank()

std::vector< InfluenceRankEntry > anpcpp::AnpNetwork::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.

No Wrt selector: for each node, measures how far (p) must move from 0.5 before alternative rankings change when that node's row is adjusted.

◆ influence_raw()

std::vector< InfluenceRawEntry > anpcpp::AnpNetwork::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.

subnets).

◆ influence_total()

std::vector< InfluenceTotalEntry > anpcpp::AnpNetwork::influence_total ( double  delta = 0.25,
const LimitMatrixOptions options = {} 
) const

Fixed-distance total influence for each node (row).

pyanp influence_fixed Total / Max Alt Change: L1 and max of absolute alternative-score diffs after moving (p) from 0.5 by delta.

◆ judgment_groups() [1/2]

std::vector< JudgmentGroup > & anpcpp::AnpNetwork::judgment_groups ( )
inline
Returns
Mutable groups.

◆ judgment_groups() [2/2]

const std::vector< JudgmentGroup > & anpcpp::AnpNetwork::judgment_groups ( ) const
inline
Returns
Named judgment groups.

◆ judgment_session()

const JudgmentSession & anpcpp::AnpNetwork::judgment_session ( ) const
inline
Returns
Current judgment session scope.

◆ limit_matrix()

Matrix anpcpp::AnpNetwork::limit_matrix ( const LimitMatrixOptions options = {}) const
Returns
Limit matrix from scaled supermatrix.

◆ limit_matrix_options()

const LimitMatrixOptions & anpcpp::AnpNetwork::limit_matrix_options ( ) const
inlinenoexcept
Returns
Limit-matrix options used as the network default for calculations.

Callers that want the network setting should pass limit_matrix_options to limit_matrix / global_priority / sensitivity APIs. Explicit LimitMatrixOptions arguments still override.

◆ name()

const std::string & anpcpp::AnpNetwork::name ( ) const
inlinenoexcept
Returns
Optional display name (empty means UI default such as "Root").

◆ nclusters()

std::size_t anpcpp::AnpNetwork::nclusters ( ) const
inlinenoexcept
Returns
Cluster count.

◆ nnodes()

std::size_t anpcpp::AnpNetwork::nnodes ( ) const
Returns
Total node count in this network.

◆ node()

AnpNode & anpcpp::AnpNetwork::node ( const std::string &  name)
Returns
Named node.
Exceptions
std::out_of_rangeif not found.

◆ node_names()

std::vector< std::string > anpcpp::AnpNetwork::node_names ( ) const
Returns
All node names (global order).

◆ node_position()

bool anpcpp::AnpNetwork::node_position ( const std::string &  name,
double &  x,
double &  y 
) const

Retrieves node layout position.

Returns
False if no position stored.

◆ nodes() [1/2]

std::vector< AnpNode * > anpcpp::AnpNetwork::nodes ( )
Returns
Node pointers in global order.

◆ nodes() [2/2]

std::vector< const AnpNode * > anpcpp::AnpNetwork::nodes ( ) const
Returns
Const node pointers.

◆ participants() [1/2]

std::vector< JudgmentParticipant > & anpcpp::AnpNetwork::participants ( )
inline
Returns
Mutable participants list.

◆ participants() [2/2]

const std::vector< JudgmentParticipant > & anpcpp::AnpNetwork::participants ( ) const
inline
Returns
Model participants (root network owns the roster).

◆ perspective()

Vector anpcpp::AnpNetwork::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.

Same pipeline as priority_at_p near p = 1 (never exactly 1); see perspective for the two-point / refine sampling.

◆ perspective_matrix()

Matrix anpcpp::AnpNetwork::perspective_matrix ( const P0Mode p0mode = P0Mode::Direct(0.5),
const LimitMatrixOptions options = {} 
) const

Perspective matrix: column j is perspective for node j.

Rows are alt_names order; columns are node_names order.

◆ priority()

Vector anpcpp::AnpNetwork::priority ( const LimitMatrixOptions options = {}) const
Returns
Alternative priority vector (synthesized when subnetworks exist).

◆ priority_map()

std::map< std::string, double > anpcpp::AnpNetwork::priority_map ( const LimitMatrixOptions options = {}) const
Returns
Alternative scores as a name -> value map.

◆ priority_map_at_p()

std::map< std::string, double > anpcpp::AnpNetwork::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.

Pipeline: scaled SM → row_adjust → limit → global priorities; if this network has subnetworks, those global priorities weight subnet synthesis (same as priority_map, but with the adjusted parent limit).

◆ rebuild_effective_judgments()

void anpcpp::AnpNetwork::rebuild_effective_judgments ( )

Rebuilds all effective pairwise/ratings slots from user tables and the current judgment_session.

Call after editing user judgments or changing scope. Subnetworks are rebuilt recursively.

◆ rename_cluster()

void anpcpp::AnpNetwork::rename_cluster ( const std::string &  old_name,
const std::string &  new_name 
)

Renames a cluster network-wide (judgment keys, layout).

Exceptions
std::invalid_argumentif unknown or new_name already exists.

◆ rename_node()

void anpcpp::AnpNetwork::rename_node ( const std::string &  old_name,
const std::string &  new_name 
)

Renames a node network-wide (index, judgments, layout).

Exceptions
std::invalid_argumentif unknown or new_name already exists.

◆ scaled_supermatrix()

Matrix anpcpp::AnpNetwork::scaled_supermatrix ( ) const
Returns
Cluster-weighted, column-normalized supermatrix.

◆ session_member_ids()

std::vector< std::string > anpcpp::AnpNetwork::session_member_ids ( ) const

Participant ids contributing under the current session.

Average → all participants; Participant → that id; Group → members.

◆ set_node_comparison()

void anpcpp::AnpNetwork::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.

wrt_node's cluster links).

Exceptions
std::logic_errorif the link uses ratings.

◆ set_node_prioritizer_kind()

void anpcpp::AnpNetwork::set_node_prioritizer_kind ( const std::string &  wrt_node,
const std::string &  dest_cluster,
NodePrioritizerKind  kind 
)

Sets prioritizer kind for wrt_nodedest_cluster.

Exceptions
std::out_of_rangeif there is no link to that cluster.

◆ subnet()

AnpNetwork & anpcpp::AnpNetwork::subnet ( const std::string &  node_name)
Returns
Subnetwork owned by node_name.
Exceptions
std::out_of_rangeif the node has no subnetwork.

◆ synthesis_options()

const SynthesisOptions & anpcpp::AnpNetwork::synthesis_options ( ) const
inlinenoexcept
Returns
Synthesis options for subnetwork score combination.

◆ unscaled_supermatrix()

Matrix anpcpp::AnpNetwork::unscaled_supermatrix ( ) const
Returns
Unscaled supermatrix (columns = global node priorities).

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