reputation/weighted_consensus.hpp¶
Weighted consensus selection (PTDS §7.3) More...
Namespaces¶
| Name |
|---|
| sgns |
| sgns::neoswarm |
| sgns::neoswarm::reputation |
Classes¶
| Name | |
|---|---|
| class | sgns::neoswarm::reputation::WeightedConsensus Selects the winning output from a set of node responses. |
| struct | sgns::neoswarm::reputation::WeightedConsensus::Config |
Detailed Description¶
Weighted consensus selection (PTDS §7.3)
Date: 2026-05-06
Source code¶
#ifndef NEOSWARM_REPUTATION_WEIGHTEDCONSENSUS_HPP
#define NEOSWARM_REPUTATION_WEIGHTEDCONSENSUS_HPP
#include "common/types.hpp"
#include <vector>
namespace sgns::neoswarm::reputation
{
class WeightedConsensus
{
public:
enum class Strategy : uint8_t
{
WeightedVoting = 0,
BestWeightedScore = 1
};
struct Config
{
Strategy strategy_ = Strategy::WeightedVoting;
double epsilon_ = 1e-6;
double min_weight_ = 0.0;
};
WeightedConsensus();
explicit WeightedConsensus( Config cfg );
NodeOutput SelectWinner( const std::vector<NodeOutput>& outputs ) const;
private:
Config m_cfg;
std::vector<double> ComputeWeights( const std::vector<NodeOutput>& outputs ) const;
NodeOutput WeightedVoting( const std::vector<NodeOutput>& outputs, const std::vector<double>& weights ) const;
NodeOutput BestWeightedScore( const std::vector<NodeOutput>& outputs,
const std::vector<double>& weights ) const;
};
} // namespace sgns::neoswarm::reputation
#endif // NEOSWARM_REPUTATION_WEIGHTEDCONSENSUS_HPP
Updated on 2026-07-25 at 22:56:57 +0000