An election that implements cumulative voting.
More...
#include <ElectionCumulative.h>
|
void | reset_votes_pointer (void) |
| calls a reset on the votes_ location in the knowledge base using election_prefix_ + "." + round_. More...
|
|
An election that implements cumulative voting.
Allows multiple votes from each voter.
Definition at line 74 of file ElectionCumulative.h.
◆ ElectionCumulative()
gams::elections::ElectionCumulative::ElectionCumulative |
( |
const std::string & |
election_prefix = "" , |
|
|
const std::string & |
agent_prefix = "" , |
|
|
madara::knowledge::KnowledgeBase * |
knowledge = 0 |
|
) |
| |
Constructor.
- Parameters
-
election_prefix | the name of the election(e.g. election.leader) |
agent_prefix | the name of this bidder(e.g. agent.0) |
knowledge | the knowledge base to use for syncing |
◆ ~ElectionCumulative()
virtual gams::elections::ElectionCumulative::~ElectionCumulative |
( |
| ) |
|
|
virtual |
◆ 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::ElectionCumulative::get_leader |
( |
void |
| ) |
|
Returns the leader of the voting.
◆ get_leaders()
virtual CandidateList gams::elections::ElectionCumulative::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_leaders | maximum 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
-
results | the results of the vote |
◆ get_votes() [2/2]
Gets the votes cast in the election by a specific group of agents.
- Parameters
-
group | the group that is of interest |
results | the 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_prefix | the 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
-
prefix | the 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
-
prefix | the 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
-
knowledge | the 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
-
agent | the agent prefix who is bidding |
candidate | the candidate receiving votes |
votes | the 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
-
candidate | the candidate receiving votes |
votes | the number of votes cast |
◆ agent_prefix_
std::string gams::elections::ElectionBase::agent_prefix_ |
|
protectedinherited |
◆ election_prefix_
std::string gams::elections::ElectionBase::election_prefix_ |
|
protectedinherited |
◆ 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 |
The documentation for this class was generated from the following file: