GAMS  1.4.0
gams::elections::ElectionPlurality Class Reference

An election that implements plurality voting(NOT IMPLEMENTED) More...

#include <ElectionPlurality.h>

Inheritance diagram for gams::elections::ElectionPlurality:
gams::elections::ElectionBase

Public Member Functions

 ElectionPlurality (const std::string &election_prefix="", const std::string &agent_prefix="", madara::knowledge::KnowledgeBase *knowledge=0)
 Constructor. More...
 
virtual ~ElectionPlurality ()
 Constructor. More...
 
virtual void advance_round (void)
 Proceeds to the next election round in a multi-round election. More...
 
const std::string & get_agent_prefix (void) const
 Gets the prefix for the current agent. More...
 
const std::string & get_election_prefix (void) const
 Gets the prefix for the election in the knowledge base. More...
 
std::string get_leader (void)
 Returns the leader of the voting. More...
 
virtual CandidateList get_leaders (int num_leaders=1)
 Returns the leaders of the election in order of popularity or whatever conditions constitute winning the election. More...
 
int get_round (void) const
 Retrieves the round number, usually in a multi-round election. More...
 
virtual void get_votes (CandidateVotes &results)
 Gets the votes cast in the election. More...
 
virtual void get_votes (groups::GroupBase *group, CandidateVotes &results)
 Gets the votes cast in the election by a specific group of agents. More...
 
virtual bool has_voted (const std::string &agent_prefix)
 Checks if the agent has voted in this round. More...
 
virtual void reset_round (void)
 Resets the round. More...
 
virtual void set_agent_prefix (const std::string &prefix)
 Sets the prefix for the current bidding agent. More...
 
virtual void set_election_prefix (const std::string &prefix)
 Sets the prefix for the election in the knowledge base. More...
 
virtual void set_knowledge_base (madara::knowledge::KnowledgeBase *knowledge)
 Sets the knowledge base. More...
 
virtual void sync (void)
 Syncs the election information from the knowledge base. More...
 
virtual void vote (const std::string &agent, const std::string &candidate, int votes=1)
 Bids in the election. More...
 
void vote (const std::string &candidate, int votes=1)
 Votes in the election. More...
 

Protected Member Functions

void reset_votes_pointer (void)
 calls a reset on the votes_ location in the knowledge base using election_prefix_ + "." + round_. More...
 

Protected Attributes

std::string agent_prefix_
 self prefix of the agent More...
 
std::string election_prefix_
 the prefix for the election More...
 
madara::knowledge::KnowledgeBase * knowledge_
 The knowledge base to use as a data plane. More...
 
int round_
 the election round in a multi-round election More...
 
madara::knowledge::containers::Map votes_
 convenience class for bids More...
 

Detailed Description

An election that implements plurality voting(NOT IMPLEMENTED)

Definition at line 73 of file ElectionPlurality.h.

Constructor & Destructor Documentation

◆ ElectionPlurality()

gams::elections::ElectionPlurality::ElectionPlurality ( const std::string &  election_prefix = "",
const std::string &  agent_prefix = "",
madara::knowledge::KnowledgeBase *  knowledge = 0 
)

Constructor.

Parameters
election_prefixthe name of the election(e.g. election.leader)
agent_prefixthe name of this bidder(e.g. agent.0)
knowledgethe knowledge base to use for syncing

◆ ~ElectionPlurality()

virtual gams::elections::ElectionPlurality::~ElectionPlurality ( )
virtual

Constructor.

Member Function Documentation

◆ advance_round()

virtual void gams::elections::ElectionBase::advance_round ( void  )
virtualinherited

Proceeds to the next election round in a multi-round election.

◆ get_agent_prefix()

const std::string& gams::elections::ElectionBase::get_agent_prefix ( void  ) const
inherited

Gets the prefix for the current agent.

Returns
the name of this bidding agent(e.g. agent.0)

◆ get_election_prefix()

const std::string& gams::elections::ElectionBase::get_election_prefix ( void  ) const
inherited

Gets the prefix for the election in the knowledge base.

Returns
the name of the election(e.g. election.protectors)

◆ get_leader()

std::string gams::elections::ElectionPlurality::get_leader ( void  )

Returns the leader of the voting.

◆ get_leaders()

virtual CandidateList gams::elections::ElectionPlurality::get_leaders ( int  num_leaders = 1)
virtual

Returns the leaders of the election in order of popularity or whatever conditions constitute winning the election.

Parameters
num_leadersmaximum leaders to return
Returns
the leaders of the election up to num_leaders

Implements gams::elections::ElectionBase.

◆ get_round()

int gams::elections::ElectionBase::get_round ( void  ) const
inherited

Retrieves the round number, usually in a multi-round election.

Returns
the agent prefix of the leader of the election

◆ get_votes() [1/2]

virtual void gams::elections::ElectionBase::get_votes ( CandidateVotes results)
virtualinherited

Gets the votes cast in the election.

Parameters
resultsthe results of the vote

◆ get_votes() [2/2]

virtual void gams::elections::ElectionBase::get_votes ( groups::GroupBase group,
CandidateVotes results 
)
virtualinherited

Gets the votes cast in the election by a specific group of agents.

Parameters
groupthe group that is of interest
resultsthe results of the vote

◆ has_voted()

virtual bool gams::elections::ElectionBase::has_voted ( const std::string &  agent_prefix)
virtualinherited

Checks if the agent has voted in this round.

Parameters
agent_prefixthe participating agent's prefix(e.g. agent.0)
Returns
true if the agent is a member of the election

◆ reset_round()

virtual void gams::elections::ElectionBase::reset_round ( void  )
virtualinherited

Resets the round.

Returns
the agent prefix of the leader of the election

◆ reset_votes_pointer()

void gams::elections::ElectionBase::reset_votes_pointer ( void  )
protectedinherited

calls a reset on the votes_ location in the knowledge base using election_prefix_ + "." + round_.

◆ set_agent_prefix()

virtual void gams::elections::ElectionBase::set_agent_prefix ( const std::string &  prefix)
virtualinherited

Sets the prefix for the current bidding agent.

Parameters
prefixthe name of the agent(e.g. agent.0)

◆ set_election_prefix()

virtual void gams::elections::ElectionBase::set_election_prefix ( const std::string &  prefix)
virtualinherited

Sets the prefix for the election in the knowledge base.

Parameters
prefixthe name of the election(e.g. election.protectors)

◆ set_knowledge_base()

virtual void gams::elections::ElectionBase::set_knowledge_base ( madara::knowledge::KnowledgeBase *  knowledge)
virtualinherited

Sets the knowledge base.

Parameters
knowledgethe knowledge base to use for syncing

◆ sync()

virtual void gams::elections::ElectionBase::sync ( void  )
virtualinherited

Syncs the election information from the knowledge base.

◆ vote() [1/2]

virtual void gams::elections::ElectionBase::vote ( const std::string &  agent,
const std::string &  candidate,
int  votes = 1 
)
virtualinherited

Bids in the election.

Parameters
agentthe agent prefix who is bidding
candidatethe candidate receiving votes
votesthe number of votes cast

◆ vote() [2/2]

void gams::elections::ElectionBase::vote ( const std::string &  candidate,
int  votes = 1 
)
inherited

Votes in the election.

Uses the agent prefix that has been set in this Election as the voter id.

Parameters
candidatethe candidate receiving votes
votesthe number of votes cast

Member Data Documentation

◆ agent_prefix_

std::string gams::elections::ElectionBase::agent_prefix_
protectedinherited

self prefix of the agent

Definition at line 221 of file ElectionBase.h.

◆ election_prefix_

std::string gams::elections::ElectionBase::election_prefix_
protectedinherited

the prefix for the election

Definition at line 216 of file ElectionBase.h.

◆ knowledge_

madara::knowledge::KnowledgeBase* gams::elections::ElectionBase::knowledge_
mutableprotectedinherited

The knowledge base to use as a data plane.

Definition at line 211 of file ElectionBase.h.

◆ round_

int gams::elections::ElectionBase::round_
protectedinherited

the election round in a multi-round election

Definition at line 226 of file ElectionBase.h.

◆ votes_

madara::knowledge::containers::Map gams::elections::ElectionBase::votes_
protectedinherited

convenience class for bids

Definition at line 231 of file ElectionBase.h.


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