GAMS  1.4.0
AuctionBase.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_AUCTIONS_AUCTION_BASE_H_
55 #define _GAMS_AUCTIONS_AUCTION_BASE_H_
56 
57 #include <vector>
58 #include <string>
59 #include <map>
60 
61 #include "madara/knowledge/KnowledgeBase.h"
62 #include "madara/knowledge/containers/Map.h"
63 
64 #include "AuctionTypesEnum.h"
65 #include "gams/groups/GroupBase.h"
67 #include "gams/GamsExport.h"
68 
70 
71 namespace gams
72 {
73  namespace auctions
74  {
79  {
80  public:
87  AuctionBase(const std::string & auction_prefix = "",
88  const std::string & agent_prefix = "",
89  madara::knowledge::KnowledgeBase * knowledge = 0);
90 
94  virtual ~AuctionBase();
95 
100  virtual void add_group(groups::GroupBase * group);
101 
105  virtual void clear_group(void);
106 
112  virtual bool is_member(const std::string & agent_prefix) const;
113 
122  virtual madara::knowledge::KnowledgeRecord get_bid(
123  const std::string & id);
124 
129  virtual void set_agent_prefix(const std::string & prefix);
130 
135  virtual void set_auction_prefix(const std::string & prefix);
136 
141  virtual void set_knowledge_base(
142  madara::knowledge::KnowledgeBase * knowledge);
143 
147  virtual void sync(void);
148 
153  const std::string & get_agent_prefix(void) const;
154 
159  const std::string & get_auction_prefix(void) const;
160 
165  virtual double get_participation(void) const;
166 
177  void bid(const madara::knowledge::KnowledgeRecord & amount);
178 
189  virtual void bid(const std::string & agent,
190  const madara::knowledge::KnowledgeRecord & amount);
191 
196  virtual std::string get_leader(void) = 0;
197 
204  virtual void get_bids(AuctionBids & bids,
205  bool strip_prefix = true,
206  bool include_all_members = false) const;
207 
212  virtual void advance_round(void);
213 
218  int get_round(void) const;
219 
223  virtual void reset_round(void);
224 
230  void set_round(int round);
231 
237  std::string get_auction_round_prefix(void) const;
238 
239  protected:
240 
245  void reset_bids_pointer(void);
246 
250  mutable madara::knowledge::KnowledgeBase * knowledge_;
251 
255  std::string auction_prefix_;
256 
260  std::string agent_prefix_;
261 
265  int round_;
266 
270  madara::knowledge::containers::Map bids_;
271 
276  };
277  }
278 }
279 
280 #include "AuctionBase.inl"
281 
282 #endif // _GAMS_AUCTIONS_AUCTION_BASE_H_
Copyright(c) 2016 Carnegie Mellon University.
Copyright (c) 2016 Carnegie Mellon University.
#define GAMS_EXPORT
Definition: GamsExport.h:20
Copyright(c) 2016 Carnegie Mellon University.
Copyright(c) 2016 Carnegie Mellon University.
Base class for an auction.
Definition: AuctionBase.h:79
void set_round(int round)
Explicitly sets the round number.
virtual madara::knowledge::KnowledgeRecord get_bid(const std::string &id)
Checks if the agent is a member of the action participants.
virtual void bid(const std::string &agent, const madara::knowledge::KnowledgeRecord &amount)
Bids in the auction.
int round_
the auction round in a multi-round auction
Definition: AuctionBase.h:265
virtual void set_agent_prefix(const std::string &prefix)
Sets the prefix for the current bidding agent.
virtual void reset_round(void)
Resets the round.
groups::GroupFixedList group_
the expected participant group
Definition: AuctionBase.h:275
std::string agent_prefix_
self prefix of the agent
Definition: AuctionBase.h:260
void bid(const madara::knowledge::KnowledgeRecord &amount)
Bids in the auction.
virtual double get_participation(void) const
Gets participation rate in the group for this round.
madara::knowledge::KnowledgeBase * knowledge_
The knowledge base to use as a data plane.
Definition: AuctionBase.h:250
const std::string & get_agent_prefix(void) const
Gets the prefix for the current agent.
madara::knowledge::containers::Map bids_
convenience class for bids
Definition: AuctionBase.h:270
virtual void set_auction_prefix(const std::string &prefix)
Sets the prefix for the auction in the knowledge base.
virtual ~AuctionBase()
Constructor.
virtual std::string get_leader(void)=0
Returns the leader of the bidding process.
virtual bool is_member(const std::string &agent_prefix) const
Checks if the agent is a member of the action participants.
int get_round(void) const
Retrieves the round number, usually in a multi-round auction.
const std::string & get_auction_prefix(void) const
Gets the prefix for the auction in the knowledge base.
virtual void advance_round(void)
Proceeds to the next auction round in a multi-round auction.
virtual void clear_group(void)
Clears the underlying auction participants group.
virtual void sync(void)
Syncs the auction information from the knowledge base.
std::string get_auction_round_prefix(void) const
Returns the full auction prefix string, including round.
std::string auction_prefix_
the prefix for the auction
Definition: AuctionBase.h:255
virtual void add_group(groups::GroupBase *group)
Adds a group of auction participants.
AuctionBase(const std::string &auction_prefix="", const std::string &agent_prefix="", madara::knowledge::KnowledgeBase *knowledge=0)
Constructor.
virtual void set_knowledge_base(madara::knowledge::KnowledgeBase *knowledge)
Sets the knowledge base.
virtual void get_bids(AuctionBids &bids, bool strip_prefix=true, bool include_all_members=false) const
Returns the list of bids in this round.
void reset_bids_pointer(void)
calls a reset on the bids_ location in the knowledge base using auction_prefix_ + "....
Base class for a group of agents.
Definition: GroupBase.h:91
A fixed list of agent members.
std::vector< AuctionBid > AuctionBids
convenience typedef for vector fo AuctionBid
Definition: AuctionBid.h:126
Contains all GAMS-related tools, classes and code.