anpcpp 0.4.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
88[[nodiscard]] std::map<std::string, double> synthesize_custom(
89 const std::string& expression,
90 const std::map<std::string, std::map<std::string, double>>& alt_scores,
91 const std::vector<std::string>& alt_order,
92 const std::map<std::string, double>& subnet_weights = {});
93
97[[nodiscard]] std::map<std::string, double> synthesize(
98 const SynthesisOptions& options,
99 const std::map<std::string, double>& subnet_weights,
100 const std::map<std::string, std::map<std::string, double>>& alt_scores,
101 const std::vector<std::string>& alt_order);
102
108[[nodiscard]] double eval_expression(
109 const std::string& expression,
110 const std::map<std::string, double>& variables);
111
112} // 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
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_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_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