anpcpp 0.1.0
Analytic Network Process computational library
Loading...
Searching...
No Matches
synthesis.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <map>
9#include <stdexcept>
10#include <string>
11#include <vector>
12
13namespace anpcpp {
14
18enum class SynthesisKind {
24 Custom,
25};
26
39
43class SynthesisError : public std::runtime_error {
44public:
48 explicit SynthesisError(const std::string& message)
49 : std::runtime_error(message) {}
50};
51
58[[nodiscard]] std::map<std::string, double> synthesize_additive(
59 const std::map<std::string, double>& subnet_weights,
60 const std::map<std::string, std::map<std::string, double>>& alt_scores);
61
65[[nodiscard]] std::map<std::string, double> synthesize_multiplicative(
66 const std::map<std::string, double>& subnet_weights,
67 const std::map<std::string, std::map<std::string, double>>& alt_scores);
68
76[[nodiscard]] std::map<std::string, double> synthesize_custom(
77 const std::string& expression,
78 const std::map<std::string, std::map<std::string, double>>& alt_scores,
79 const std::vector<std::string>& alt_order);
80
84[[nodiscard]] std::map<std::string, double> synthesize(
85 const SynthesisOptions& options,
86 const std::map<std::string, double>& subnet_weights,
87 const std::map<std::string, std::map<std::string, double>>& alt_scores,
88 const std::vector<std::string>& alt_order);
89
95[[nodiscard]] double eval_expression(
96 const std::string& expression,
97 const std::map<std::string, double>& variables);
98
99} // namespace anpcpp
Thrown when synthesis or expression evaluation fails.
Definition synthesis.hpp:43
SynthesisError(const std::string &message)
Definition synthesis.hpp:48
Analytic Network Process computational library.
Definition eigen.hpp:14
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)
Custom expression synthesis per alternative.
double eval_expression(const std::string &expression, const std::map< std::string, double > &variables)
Evaluates a numeric expression with named variables.
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.
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.
SynthesisKind
How control-node subnetwork scores are combined.
Definition synthesis.hpp:18
@ Multiplicative
Product of subnet scores across control nodes, then normalize.
@ Additive
Weighted average of subnet scores (pyanp default).
@ Custom
Custom expression over subnet-host node names.
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).
Synthesis configuration for networks with subnetworks.
Definition synthesis.hpp:30
SynthesisKind kind
Selected synthesis method.
Definition synthesis.hpp:32
std::string custom_expr
Expression when kind == Custom.
Definition synthesis.hpp:37