creativity  v1.3.0
Agent-based model of creativity and piracy
BookMarket.hpp
1 #pragma once
2 #include <eris/Market.hpp>
3 #include <eris/Optimize.hpp>
4 #include <limits>
5 
6 namespace creativity {
7 // Forward declarations:
8 class Book;
9 class Creativity;
10 
14 class BookMarket : public eris::Market, public virtual eris::intraopt::Finish {
15  public:
17  BookMarket() = delete;
21  BookMarket(const Creativity &creativity, eris::SharedMember<Book> b, double price);
22 
29  virtual price_info price(double q) const override;
30 
39  virtual quantity_info quantity(double p) const override;
40 
46  virtual void setPrice(double p);
47 
54  virtual const double& price();
55 
57  virtual void added() override;
58 
62  virtual Reservation reserve(
63  eris::SharedMember<eris::Agent> agent,
64  double q,
65  double p_max = std::numeric_limits<double>::infinity()) override;
66 
68  eris::SharedMember<Book> book();
69 
72  virtual void intraFinish() override;
73 
77  virtual bool isPublic() const { return false; }
78 
85  virtual void buy(Reservation &res) override;
86 
87  protected:
88 
92  eris::SharedMember<Book> book_;
94  double price_;
96  eris::Bundle proceeds_;
97 };
98 
99 }
eris::Bundle proceeds_
Accrued income of the book (these get transferred in the interApply phase)
Definition: BookMarket.hpp:96
Primary namespace for all Creativity library code.
Definition: config.hpp:4
double price_
The current price of the book.
Definition: BookMarket.hpp:94
virtual void setPrice(double p)
Sets the price of copies of the book on the market for future sales.
virtual void intraFinish() override
Transfers all sales (less unit costs) generated in the just-ending period to the author.
virtual Reservation reserve(eris::SharedMember< eris::Agent > agent, double q, double p_max=std::numeric_limits< double >::infinity()) override
Reserves a copy of a book, paying at most p_max for it.
virtual void buy(Reservation &res) override
We override reservation completion to transfer the payment to the author and put the book into the b_...
virtual quantity_info quantity(double p) const override
Returns quantity info for a given payment.
eris::SharedMember< Book > book()
Returns the Book sold by this market.
Central class for a creativity simulation; this class handles setting up the simulation according to ...
Definition: Creativity.hpp:22
A BookMarket is very simple: it has an exogenously determined price and can supply infinite copies of...
Definition: BookMarket.hpp:14
eris::SharedMember< Book > book_
The book this market object sells.
Definition: BookMarket.hpp:92
virtual bool isPublic() const
Returns true if this is a public market.
Definition: BookMarket.hpp:77
BookMarket()=delete
Not default constructible.
const Creativity & creativity_
The creativity object pointer.
Definition: BookMarket.hpp:90
virtual const double & price()
Returns the price of a single copy of the book.
virtual void added() override
Registers this market as the book&#39;s market when added to the simulation.