anpcpp 0.4.0
Analytic Network Process computational library
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
anpcpp Namespace Reference

Analytic Network Process computational library. More...

Classes

class  AnpCluster
 A group of nodes (and cluster-level pairwise comparisons). More...
 
class  AnpNetwork
 Root ANP model: structure, judgments, supermatrices, and priorities. More...
 
class  AnpNode
 A decision element within a cluster (may own a subnetwork). More...
 
struct  ConsistencyOptions
 Options for consistency. More...
 
struct  ConsistencyResult
 Full consistency analysis result. More...
 
class  ConvergenceError
 Thrown when power iteration fails to converge within max_iterations. More...
 
class  DimensionError
 Thrown when vector/matrix dimensions do not match an operation. More...
 
struct  DivideByConstantInterpreter
 Divide each raw value by a fixed positive constant. More...
 
struct  DivideByMaxInterpreter
 Divide each raw value by the max among present values. More...
 
struct  EigenOptions
 Options controlling principal eigen computation. More...
 
struct  EigenResult
 Result of principal_eigen. More...
 
struct  IdentityInterpreter
 Pass-through interpreter (values already in [0, 1]). More...
 
struct  InfluenceMarginalEntry
 Smart-(p_0) marginal influence for one row or alternative. More...
 
struct  InfluenceRankEntry
 Rank-influence result for one row (or one alternative under a fixed Wrt). More...
 
struct  InfluenceRawEntry
 One alternative's raw (fixed-distance) influence result. More...
 
struct  InfluenceTotalEntry
 Fixed-distance total influence for one row (pyanp influence_fixed Total). More...
 
class  JsonIoError
 Thrown on JSON parse, validation, or I/O errors. More...
 
struct  JudgmentFillCounts
 Filled vs needed judgment counts for coverage grids. More...
 
struct  JudgmentGroup
 Named subset of participants for group-scope analysis. More...
 
struct  JudgmentParticipant
 A judge on a model (model-scoped, not an app account). More...
 
struct  JudgmentSession
 Document session: which judgments are active for editing/calc. More...
 
struct  LimitMatrixOptions
 Options for limit-matrix calculation. More...
 
class  Matrix
 Dense row-major matrix stored in a flat buffer. More...
 
struct  MinMaxNormalizeInterpreter
 Map the column's [min, max] onto [0, 1]. More...
 
struct  NodePrioritizerSlot
 Stores either pairwise or ratings judgments for one dest cluster. More...
 
struct  P0Mode
 (p_0) selection for row_adjust. More...
 
struct  PairwiseCellDisagreement
 Disagreement stats for one pairwise upper-triangle cell. More...
 
class  PairwiseJudgments
 Square pairwise comparison table over a named list of alternatives. More...
 
struct  PiecewiseLinearInterpreter
 Piecewise-linear map from raw value to [0, 1] via sorted knots. More...
 
struct  RatingCategory
 A named rating category with an associated score in [0, 1]. More...
 
struct  RatingsAltDisagreement
 Disagreement stats for one ratings alternative. More...
 
class  RatingsPrioritizer
 Ratings table over named alternatives for one (wrt node, dest cluster). More...
 
class  SynthesisError
 Thrown when synthesis or expression evaluation fails. More...
 
struct  SynthesisOptions
 Synthesis configuration for networks with subnetworks. More...
 
class  Vector
 One-dimensional array of doubles with element-wise arithmetic. More...
 
struct  VoteSpreadSummary
 Summary of collected votes for one comparison / ratings alternative. More...
 

Typedefs

using ScoreInterpreter = std::variant< IdentityInterpreter, DivideByMaxInterpreter, DivideByConstantInterpreter, MinMaxNormalizeInterpreter, PiecewiseLinearInterpreter >
 Declarative raw-value → [0, 1] interpreter (JSON-serializable).
 

Enumerations

enum class  LimitMatrixMethod { Calculus , NewHierarchy , Sinks }
 SuperDecisions / pyanp limit-matrix algorithm. More...
 
enum class  JudgmentScopeKind { Average , Participant , Group }
 Whose judgments feed the effective calc slot. More...
 
enum class  NodePrioritizerKind
 Active prioritizer kind for a node → destination-cluster link.
 
enum class  P0ModeKind { Direct , Smart , OriginalWeight }
 How resting parameter (p_0) is chosen for row sensitivity. More...
 
enum class  SynthesisKind { Additive , Multiplicative , Custom }
 How control-node subnetwork scores are combined. More...
 

Functions

Matrix harker_fix (const Matrix &mat)
 Applies Harker's fix for incomplete pairwise matrices.
 
EigenResult principal_eigen (const Matrix &mat, const EigenOptions &options={})
 Power iteration with sum-normalization (pyanp pri_eigen compatible).
 
Vector principal_eigenvector (const Matrix &mat, const EigenOptions &options={})
 Returns the principal eigenvector only.
 
double principal_eigenvalue (const Matrix &mat, const EigenOptions &options={})
 Returns the principal eigenvalue only.
 
double random_index (std::size_t n)
 Saaty random index (RI) for matrix order n.
 
double consistency_index (double lambda_max, std::size_t n)
 Consistency index CI = (lambda_max - n) / (n - 1).
 
double consistency_ratio (double lambda_max, std::size_t n)
 Consistency ratio CR = CI / RI.
 
ConsistencyResult consistency (const Matrix &mat, ConsistencyOptions options={})
 Computes Saaty CI and CR for a pairwise comparison matrix.
 
double consistency_index (const Matrix &mat, ConsistencyOptions options={})
 Consistency index from a matrix (throws on non-convergence).
 
double consistency_ratio (const Matrix &mat, ConsistencyOptions options={})
 Consistency ratio from a matrix (throws on non-convergence).
 
std::string network_to_json (const AnpNetwork &network)
 Serializes a network (including subnetworks and layout hints) to JSON.
 
std::unique_ptr< AnpNetworknetwork_from_json (const std::string &json_text)
 Parses JSON produced by network_to_json.
 
void save_network_file (const AnpNetwork &network, const std::string &path)
 Writes a network to a file.
 
std::unique_ptr< AnpNetworkload_network_file (const std::string &path)
 Loads a network from a file.
 
Matrix column_normalize (const Matrix &mat)
 Column-normalizes each column by its sum (pyanp normalize).
 
void column_normalize_inplace (Matrix &mat)
 In-place column_normalize.
 
Matrix hierarchy_formula (const Matrix &mat)
 Hierarchy limit formula: normalize(sum of W^k for k=1..n-1).
 
std::vector< std::size_t > hierarchy_nodes (const Matrix &mat)
 Indices of hierarchical nodes (zero columns of W^n); pyanp hierarchy_nodes.
 
Matrix calculus_limit (const Matrix &mat, const LimitMatrixOptions &options={})
 SuperDecisions / pyanp calculus limit matrix.
 
Matrix limit_sinks (const Matrix &mat, const LimitMatrixOptions &options={})
 Limit-with-sinks calculation (pyanp limit_sinks).
 
Matrix limit_newhierarchy (const Matrix &mat, const LimitMatrixOptions &options={})
 New Hierarchy limit calculation (pyanp limit_newhierarchy).
 
Matrix compute_limit_matrix (const Matrix &mat, const LimitMatrixOptions &options={})
 Dispatch to the algorithm selected by options.method.
 
Vector priority_from_limit (const Matrix &limit_matrix)
 Row sums of the limit matrix, L1-normalized (pyanp priority_from_limit).
 
void aggregate_pairwise_geometric (const std::vector< const PairwiseJudgments * > &inputs, PairwiseJudgments &out)
 Geometric mean of pairwise ratios into out (same alternatives).
 
void aggregate_ratings_arithmetic (const std::vector< const RatingsPrioritizer * > &inputs, const RatingsPrioritizer &scale_template, RatingsPrioritizer &out)
 Arithmetic mean of rating intensity scores into out.
 
void copy_pairwise_into (const PairwiseJudgments &src, PairwiseJudgments &out)
 Copy src pairwise into out (alternatives aligned to out).
 
void copy_ratings_votes_into (const RatingsPrioritizer &src, RatingsPrioritizer &out)
 Copy votes from src into out, syncing mode/scale from src.
 
std::vector< std::vector< PairwiseCellDisagreement > > pairwise_disagreement (const std::vector< const PairwiseJudgments * > &inputs)
 Per upper-triangle cell max/min ratio across inputs.
 
std::vector< RatingsAltDisagreementratings_disagreement (const std::vector< const RatingsPrioritizer * > &inputs, const std::vector< std::string > &alt_order={})
 Per-alternative intensity range across inputs.
 
JudgmentFillCounts pairwise_fill_counts (const PairwiseJudgments &pw)
 Count filled upper-triangle cells (comparison != 0) vs needed.
 
JudgmentFillCounts ratings_fill_counts (const RatingsPrioritizer &rt)
 Count present ratings votes vs number of alternatives.
 
double pairwise_alignment_pct (double min_v, double max_v)
 Pairwise alignment from min/max ratios.
 
double ratings_alignment_pct (double range, double full_scale)
 Ratings alignment from intensity range vs full_scale.
 
VoteSpreadSummary summarize_pairwise_votes (const std::vector< double > &values)
 Geometric mean / SD spread for positive pairwise ratios.
 
VoteSpreadSummary summarize_ratings_votes (const std::vector< double > &values, double full_scale=1.0)
 Arithmetic mean / SD spread for ratings intensities.
 
std::vector< std::optional< double > > apply_score_interpreter (const ScoreInterpreter &interpreter, const std::vector< std::optional< double > > &raw)
 Apply interpreter to a column of optional raw values.
 
Matrix row_adjust (const Matrix &mat, std::size_t row, double p, const P0Mode &p0mode=P0Mode::Direct(0.5), const std::vector< std::size_t > &cluster_nodes={})
 Adjusts row row of scaled supermatrix mat to parameter p.
 
double smart_p0 (const Matrix &mat, std::size_t row, std::size_t cont_alt, const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={})
 Smart resting (p_0) making score of cont_alt continuous at (p_0).
 
Vector priority_after_row_adjust (const Matrix &mat, std::size_t row, double p, const P0Mode &p0mode=P0Mode::Direct(0.5), const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={}, bool normalize_to_orig=true)
 Priorities after row adjust (pyanp row_adjust_priority, normalize_to_orig).
 
Vector influence_marginal (const Matrix &mat, std::size_t row, double p0, int left_or_right=0, double delta=1e-6, const std::vector< std::size_t > &influence_nodes={}, const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={})
 Marginal influence (finite difference) at a direct (p_0).
 
std::vector< InfluenceMarginalEntryinfluence_marginal_smart (const Matrix &mat, std::size_t row, const std::vector< std::size_t > &influence_nodes, const std::vector< std::string > &names, const std::vector< std::size_t > &cluster_nodes={}, double delta=1e-6, const LimitMatrixOptions &options={})
 Per-alternative smart-(p_0) marginal influence (single value each).
 
std::vector< InfluenceRawEntryinfluence_raw (const Matrix &mat, std::size_t row, const std::vector< std::size_t > &influence_nodes, const std::vector< std::string > &names, double delta_up=0.1, double delta_down=0.1, double p0=0.5, const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={})
 Raw fixed-distance influence table (original / up / down scores).
 
std::vector< InfluenceRankEntryinfluence_rank (const Matrix &mat, std::size_t row, const std::vector< std::size_t > &influence_nodes, const std::vector< std::string > &names, const std::vector< std::size_t > &cluster_nodes={}, double error=1e-5, int round_to_decimal=5, const LimitMatrixOptions &options={})
 Rank influence score per alternative (max of upper/lower searches).
 
InfluenceTotalEntry influence_total_row (const Matrix &mat, std::size_t row, const std::vector< std::size_t > &influence_nodes, double delta=0.25, double p0=0.5, const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={})
 Fixed-distance total influence for one row (L1 and max of abs diffs).
 
std::vector< InfluenceTotalEntryinfluence_total (const Matrix &mat, const std::vector< std::size_t > &rows, const std::vector< std::string > &row_names, const std::vector< std::size_t > &influence_nodes, double delta=0.25, double p0=0.5, const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={})
 Per-row total influence (pyanp multi-row influence_fixed Totals).
 
Vector perspective (const Matrix &mat, std::size_t row, const P0Mode &p0mode=P0Mode::Direct(0.5), const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={}, bool normalize_to_orig=true)
 Perspective of one row: limit as p approaches 1 of row sensitivity.
 
Matrix perspective_matrix (const Matrix &mat, const std::vector< std::size_t > &rows={}, const P0Mode &p0mode=P0Mode::Direct(0.5), const std::vector< std::size_t > &cluster_nodes={}, const LimitMatrixOptions &options={}, bool normalize_to_orig=true)
 Perspective matrix: column j is perspective for rows[j].
 
std::map< std::string, double > synthesize_additive (const std::map< std::string, double > &subnet_weights, const std::map< std::string, std::map< std::string, double > > &alt_scores)
 Weighted average synthesis (matches AnpNetwork::sum_subnetwork_formula).
 
std::map< std::string, double > synthesize_multiplicative (const std::map< std::string, double > &subnet_weights, const std::map< std::string, std::map< std::string, double > > &alt_scores)
 Multiplicative synthesis: product of score^weight per alt, then L1-normalize.
 
std::map< std::string, double > synthesize_custom (const std::string &expression, const std::map< std::string, std::map< std::string, double > > &alt_scores, const std::vector< std::string > &alt_order, const std::map< std::string, double > &subnet_weights={})
 Custom expression synthesis per alternative.
 
std::map< std::string, double > synthesize (const SynthesisOptions &options, const std::map< std::string, double > &subnet_weights, const std::map< std::string, std::map< std::string, double > > &alt_scores, const std::vector< std::string > &alt_order)
 Dispatches on SynthesisOptions::kind.
 
double eval_expression (const std::string &expression, const std::map< std::string, double > &variables)
 Evaluates a numeric expression with named variables.
 

Variables

constexpr const char * kDefaultParticipantId = "default"
 Default participant id used when migrating single-user (v1) models.
 
constexpr double kPairwiseAlignmentSpanRatio = 81.0
 max/min span that maps to 0% alignment on the Saaty strip (9 ÷ 1/9).
 
constexpr double kPerspectivePCoarse = 1.0 - 1e-6
 Near-1 p values for limit-as-p-approaches-1 perspective (never exactly 1).
 
constexpr double kPerspectiveAgreeTol = 1e-6
 Max L-inf gap between coarse/fine before refining further.
 

Detailed Description

Analytic Network Process computational library.

Enumeration Type Documentation

◆ JudgmentScopeKind

enum class anpcpp::JudgmentScopeKind
strong

Whose judgments feed the effective calc slot.

Enumerator
Average 

Geometric / arithmetic average over all participants with data.

Participant 

Single participant.

Group 

Named group members only.

◆ LimitMatrixMethod

enum class anpcpp::LimitMatrixMethod
strong

SuperDecisions / pyanp limit-matrix algorithm.

Enumerator
Calculus 

Calculus Type (default SuperDecisions / pyanp).

NewHierarchy 

New Hierarchy decomposition (pyanp limit_newhierarchy).

Sinks 

Limit with sinks decomposition (pyanp limit_sinks).

◆ P0ModeKind

enum class anpcpp::P0ModeKind
strong

How resting parameter (p_0) is chosen for row sensitivity.

Enumerator
Direct 

Fixed (p_0) (typically 0.5).

Smart 

Smart (p_0) making scores continuous for one alternative index.

OriginalWeight 

Use each column's original row weight as (p_0).

◆ SynthesisKind

enum class anpcpp::SynthesisKind
strong

How control-node subnetwork scores are combined.

Enumerator
Additive 

Weighted average of subnet scores (pyanp default).

Multiplicative 

Product of subnet scores across control nodes, then normalize.

Custom 

Custom expression over subnet-host node names.

Function Documentation

◆ aggregate_pairwise_geometric()

void anpcpp::aggregate_pairwise_geometric ( const std::vector< const PairwiseJudgments * > &  inputs,
PairwiseJudgments out 
)

Geometric mean of pairwise ratios into out (same alternatives).

For each upper-triangle cell, averages only inputs with a positive finite ratio. Incomplete cells (0) are skipped. If no contributor, leaves 0.

◆ aggregate_ratings_arithmetic()

void anpcpp::aggregate_ratings_arithmetic ( const std::vector< const RatingsPrioritizer * > &  inputs,
const RatingsPrioritizer scale_template,
RatingsPrioritizer out 
)

Arithmetic mean of rating intensity scores into out.

out is set to Numeric + Identity; values are the mean of each contributor's RatingsPrioritizer::scores for that alternative (missing scores skipped). Shared categories/interpreter from scale_template are copied onto out for reference but mode is Numeric for exact means.

◆ apply_score_interpreter()

std::vector< std::optional< double > > anpcpp::apply_score_interpreter ( const ScoreInterpreter interpreter,
const std::vector< std::optional< double > > &  raw 
)

Apply interpreter to a column of optional raw values.

Missing entries stay nullopt. Present entries become scores in [0, 1] (clamped). Interpreters that need column statistics ignore missing cells.

◆ calculus_limit()

Matrix anpcpp::calculus_limit ( const Matrix mat,
const LimitMatrixOptions options = {} 
)

SuperDecisions / pyanp calculus limit matrix.

Parameters
matColumn-stochastic supermatrix.
optionsIteration and hierarchy options.

◆ column_normalize()

Matrix anpcpp::column_normalize ( const Matrix mat)

Column-normalizes each column by its sum (pyanp normalize).

Returns
Normalized copy; zero columns remain zero.

◆ column_normalize_inplace()

void anpcpp::column_normalize_inplace ( Matrix mat)

In-place column_normalize.

Parameters
matMatrix to normalize.

◆ consistency()

ConsistencyResult anpcpp::consistency ( const Matrix mat,
ConsistencyOptions  options = {} 
)

Computes Saaty CI and CR for a pairwise comparison matrix.

Parameters
matSquare comparison matrix.
optionsHarker and eigen options.

◆ consistency_index() [1/2]

double anpcpp::consistency_index ( const Matrix mat,
ConsistencyOptions  options = {} 
)

Consistency index from a matrix (throws on non-convergence).

Parameters
matSquare comparison matrix.
optionsHarker and eigen options.

◆ consistency_index() [2/2]

double anpcpp::consistency_index ( double  lambda_max,
std::size_t  n 
)

Consistency index CI = (lambda_max - n) / (n - 1).

Returns
0 for n < 2.

◆ consistency_ratio() [1/2]

double anpcpp::consistency_ratio ( const Matrix mat,
ConsistencyOptions  options = {} 
)

Consistency ratio from a matrix (throws on non-convergence).

Parameters
matSquare comparison matrix.
optionsHarker and eigen options.

◆ consistency_ratio() [2/2]

double anpcpp::consistency_ratio ( double  lambda_max,
std::size_t  n 
)

Consistency ratio CR = CI / RI.

Returns
0 when RI == 0 (n <= 2).

◆ eval_expression()

double anpcpp::eval_expression ( const std::string &  expression,
const std::map< std::string, double > &  variables 
)

Evaluates a numeric expression with named variables.

Parameters
expressionInfix expression (+ - * / parentheses).
variablesName -> value substitutions.

◆ harker_fix()

Matrix anpcpp::harker_fix ( const Matrix mat)

Applies Harker's fix for incomplete pairwise matrices.

Each row diagonal becomes 1 + (number of zero off-diagonal entries in that row), enabling power iteration on incomplete comparisons.

Parameters
matSquare pairwise matrix.
Returns
Adjusted matrix.

◆ hierarchy_formula()

Matrix anpcpp::hierarchy_formula ( const Matrix mat)

Hierarchy limit formula: normalize(sum of W^k for k=1..n-1).

Returns
Empty matrix if mat is not a hierarchy.

◆ influence_marginal()

Vector anpcpp::influence_marginal ( const Matrix mat,
std::size_t  row,
double  p0,
int  left_or_right = 0,
double  delta = 1e-6,
const std::vector< std::size_t > &  influence_nodes = {},
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {} 
)

Marginal influence (finite difference) at a direct (p_0).

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
p0Direct resting parameter.
left_or_right<0 LHS, >0 RHS, 0 average.
deltaFinite-difference step.
influence_nodesNodes whose scores are reported (empty = all but row).
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.

◆ influence_marginal_smart()

std::vector< InfluenceMarginalEntry > anpcpp::influence_marginal_smart ( const Matrix mat,
std::size_t  row,
const std::vector< std::size_t > &  influence_nodes,
const std::vector< std::string > &  names,
const std::vector< std::size_t > &  cluster_nodes = {},
double  delta = 1e-6,
const LimitMatrixOptions options = {} 
)

Per-alternative smart-(p_0) marginal influence (single value each).

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
influence_nodesAlternative indices to score.
namesDisplay names aligned with influence_nodes.
cluster_nodesCluster row indices (empty = full matrix).
deltaFinite-difference step.
optionsLimit-matrix options.

◆ influence_rank()

std::vector< InfluenceRankEntry > anpcpp::influence_rank ( const Matrix mat,
std::size_t  row,
const std::vector< std::size_t > &  influence_nodes,
const std::vector< std::string > &  names,
const std::vector< std::size_t > &  cluster_nodes = {},
double  error = 1e-5,
int  round_to_decimal = 5,
const LimitMatrixOptions options = {} 
)

Rank influence score per alternative (max of upper/lower searches).

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
influence_nodesAlternative indices to score.
namesDisplay names aligned with influence_nodes.
cluster_nodesCluster row indices (empty = full matrix).
errorBinary-search tolerance on (p).
round_to_decimalDecimals used when comparing ranks.
optionsLimit-matrix options.

◆ influence_raw()

std::vector< InfluenceRawEntry > anpcpp::influence_raw ( const Matrix mat,
std::size_t  row,
const std::vector< std::size_t > &  influence_nodes,
const std::vector< std::string > &  names,
double  delta_up = 0.1,
double  delta_down = 0.1,
double  p0 = 0.5,
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {} 
)

Raw fixed-distance influence table (original / up / down scores).

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
influence_nodesAlternative indices to score.
namesDisplay names aligned with influence_nodes.
delta_upUpward change from p0.
delta_downDownward change from p0.
p0Resting parameter (typically 0.5).
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.

◆ influence_total()

std::vector< InfluenceTotalEntry > anpcpp::influence_total ( const Matrix mat,
const std::vector< std::size_t > &  rows,
const std::vector< std::string > &  row_names,
const std::vector< std::size_t > &  influence_nodes,
double  delta = 0.25,
double  p0 = 0.5,
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {} 
)

Per-row total influence (pyanp multi-row influence_fixed Totals).

Parameters
matScaled (column-stochastic) supermatrix.
rowsRow indices to score.
row_namesDisplay names aligned with rows.
influence_nodesAlternative indices used for each row's diffs.
deltaFixed upward change from p0.
p0Resting parameter (typically 0.5).
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.

◆ influence_total_row()

InfluenceTotalEntry anpcpp::influence_total_row ( const Matrix mat,
std::size_t  row,
const std::vector< std::size_t > &  influence_nodes,
double  delta = 0.25,
double  p0 = 0.5,
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {} 
)

Fixed-distance total influence for one row (L1 and max of abs diffs).

Matches pyanp influence_fixed for a single row, then aggregates to Total / Max Alt Change as in the multi-row case.

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
influence_nodesAlternative indices to score.
deltaFixed upward change from p0.
p0Resting parameter (typically 0.5).
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.

◆ limit_newhierarchy()

Matrix anpcpp::limit_newhierarchy ( const Matrix mat,
const LimitMatrixOptions options = {} 
)

New Hierarchy limit calculation (pyanp limit_newhierarchy).

Splits hierarchical vs network nodes, limits each block, and reassembles.

◆ limit_sinks()

Matrix anpcpp::limit_sinks ( const Matrix mat,
const LimitMatrixOptions options = {} 
)

Limit-with-sinks calculation (pyanp limit_sinks).

Splits sinks (zero columns) from nonsinks, applies calculus on the nonsink block, and reassembles.

◆ load_network_file()

std::unique_ptr< AnpNetwork > anpcpp::load_network_file ( const std::string &  path)

Loads a network from a file.

Parameters
pathInput file path.
Returns
Owned network tree.
Exceptions
JsonIoErroron read or parse failure.

◆ network_from_json()

std::unique_ptr< AnpNetwork > anpcpp::network_from_json ( const std::string &  json_text)

Parses JSON produced by network_to_json.

Parameters
json_textJSON document.
Returns
Owned network tree.
Exceptions
JsonIoErroron invalid or unsupported documents.

◆ network_to_json()

std::string anpcpp::network_to_json ( const AnpNetwork network)

Serializes a network (including subnetworks and layout hints) to JSON.

Parameters
networkNetwork to serialize.
Returns
JSON text (anpcpp format v2; v1 documents still load).

◆ pairwise_alignment_pct()

double anpcpp::pairwise_alignment_pct ( double  min_v,
double  max_v 
)

Pairwise alignment from min/max ratios.

100 * (1 - ln(max/min) / ln(81))

clamped to [0, 100]. Returns 100 when max/min <= 1 or count would be identical; 0 at full span.

◆ pairwise_disagreement()

std::vector< std::vector< PairwiseCellDisagreement > > anpcpp::pairwise_disagreement ( const std::vector< const PairwiseJudgments * > &  inputs)

Per upper-triangle cell max/min ratio across inputs.

Alternatives are taken from the first non-null input with size > 0. Inputs with a different size are skipped. Cells with fewer than two positive finite votes get ratio 0.

◆ perspective()

Vector anpcpp::perspective ( const Matrix mat,
std::size_t  row,
const P0Mode p0mode = P0Mode::Direct(0.5),
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {},
bool  normalize_to_orig = true 
)

Perspective of one row: limit as p approaches 1 of row sensitivity.

Evaluates row sensitivity near p = 1 (never at exactly 1, which degenerates row_adjust). Compares p = 1-1e-5 and p = 1-1e-6; if they disagree beyond 1e-6 (L-inf), refines at p = 1-1e-7.

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
p0modeResting-value mode.
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.
normalize_to_origIf true, rescale like priority_after_row_adjust.

◆ perspective_matrix()

Matrix anpcpp::perspective_matrix ( const Matrix mat,
const std::vector< std::size_t > &  rows = {},
const P0Mode p0mode = P0Mode::Direct(0.5),
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {},
bool  normalize_to_orig = true 
)

Perspective matrix: column j is perspective for rows[j].

Empty rows means every row index 0 .. n-1.

Parameters
matScaled (column-stochastic) supermatrix.
rowsRow indices used as columns (empty = all rows).
p0modeResting-value mode.
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.
normalize_to_origIf true, rescale like priority_after_row_adjust.

◆ principal_eigen()

EigenResult anpcpp::principal_eigen ( const Matrix mat,
const EigenOptions options = {} 
)

Power iteration with sum-normalization (pyanp pri_eigen compatible).

Non-convergence is reported via converged == false rather than throwing.

Parameters
matSquare matrix.
optionsIteration and Harker options.
Returns
Eigenvector, eigenvalue estimate, and convergence metadata.

◆ principal_eigenvalue()

double anpcpp::principal_eigenvalue ( const Matrix mat,
const EigenOptions options = {} 
)

Returns the principal eigenvalue only.

Exceptions
ConvergenceErrorif iteration does not converge.

◆ principal_eigenvector()

Vector anpcpp::principal_eigenvector ( const Matrix mat,
const EigenOptions options = {} 
)

Returns the principal eigenvector only.

Exceptions
ConvergenceErrorif iteration does not converge.

◆ priority_after_row_adjust()

Vector anpcpp::priority_after_row_adjust ( const Matrix mat,
std::size_t  row,
double  p,
const P0Mode p0mode = P0Mode::Direct(0.5),
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {},
bool  normalize_to_orig = true 
)

Priorities after row adjust (pyanp row_adjust_priority, normalize_to_orig).

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
pSensitivity parameter in ([0,1]).
p0modeResting-value mode.
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.
normalize_to_origIf true, rescale so the Wrt entry matches the original.

◆ random_index()

double anpcpp::random_index ( std::size_t  n)

Saaty random index (RI) for matrix order n.

n = 1,2: 0 (CR defined as 0). n = 3..15: Saaty table. n > 15: Alonso-Lamata approximation RI ≈ 1.98 * (n - 2) / n.

◆ ratings_alignment_pct()

double anpcpp::ratings_alignment_pct ( double  range,
double  full_scale 
)

Ratings alignment from intensity range vs full_scale.

100 * (1 - range / full_scale)

clamped to [0, 100].

◆ ratings_disagreement()

std::vector< RatingsAltDisagreement > anpcpp::ratings_disagreement ( const std::vector< const RatingsPrioritizer * > &  inputs,
const std::vector< std::string > &  alt_order = {} 
)

Per-alternative intensity range across inputs.

Uses scores() for present votes (categorical rating or numeric value). Alternatives come from alt_order when non-empty; otherwise from the first non-null input.

◆ row_adjust()

Matrix anpcpp::row_adjust ( const Matrix mat,
std::size_t  row,
double  p,
const P0Mode p0mode = P0Mode::Direct(0.5),
const std::vector< std::size_t > &  cluster_nodes = {} 
)

Adjusts row row of scaled supermatrix mat to parameter p.

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
pSensitivity parameter in ([0,1]).
p0modeResting-value mode.
cluster_nodesIndices in the Wrt node's cluster (including row); empty means the full matrix (all rows).
Returns
Adjusted matrix copy.

◆ save_network_file()

void anpcpp::save_network_file ( const AnpNetwork network,
const std::string &  path 
)

Writes a network to a file.

Parameters
networkNetwork to save.
pathOutput file path.
Exceptions
JsonIoErroron write failure.

◆ smart_p0()

double anpcpp::smart_p0 ( const Matrix mat,
std::size_t  row,
std::size_t  cont_alt,
const std::vector< std::size_t > &  cluster_nodes = {},
const LimitMatrixOptions options = {} 
)

Smart resting (p_0) making score of cont_alt continuous at (p_0).

Parameters
matScaled (column-stochastic) supermatrix.
rowRow index (Wrt node).
cont_altAlternative/node index made continuous.
cluster_nodesCluster row indices (empty = full matrix).
optionsLimit-matrix options.

◆ synthesize_additive()

std::map< std::string, double > anpcpp::synthesize_additive ( const std::map< std::string, double > &  subnet_weights,
const std::map< std::string, std::map< std::string, double > > &  alt_scores 
)

Weighted average synthesis (matches AnpNetwork::sum_subnetwork_formula).

Parameters
subnet_weightsWeight per control subnet (host node name -> weight).
alt_scoresPer-subnet alternative scores (subnet -> alt -> score).

◆ synthesize_custom()

std::map< std::string, double > anpcpp::synthesize_custom ( const std::string &  expression,
const std::map< std::string, std::map< std::string, double > > &  alt_scores,
const std::vector< std::string > &  alt_order,
const std::map< std::string, double > &  subnet_weights = {} 
)

Custom expression synthesis per alternative.

When subnet_weights has positive mass over the subnet hosts used in alt_scores, each host variable is bound to score^w (normalized weight). That is the SuperDecisions Ideal / weighted-BOCR form: for "Benefits * Opportunities / (Costs * Risks)" it evaluates B^wB * O^wO / (C^wC * R^wR). Plain weight*score would cancel in multiplicative formulas after normalization, so row sensitivity could not change rankings.

When weights are empty or all zero, variables bind to the raw scores (legacy unweighted custom formulas).

Parameters
expressionArithmetic expression with subnet-host names as variables.
alt_scoresPer-subnet alternative scores.
alt_orderOutput ordering of alternatives.
subnet_weightsWeight per control subnet (host node name -> weight).