7 #include <eris/types.hpp> 14 namespace creativity {
struct CreativitySettings; }
26 const std::function<long(const CreativitySettings&)>
calc_int;
28 const std::function<double(const CreativitySettings&)>
calc_double;
33 template <typename IntType, typename = typename std::enable_if<std::is_integral<IntType>::value>::type>
35 : name(
std::move(name)), calc_int(
std::move(calc_int)) {}
38 : name(
std::move(name)), calc_double(
std::move(calc_double)) {}
50 const std::function<double(const state::Storage&, eris::eris_time_t, eris::eris_time_t)>
calculate;
70 datum(std::string &&name, decltype(calculate) calc,
bool pre =
true,
bool piracy =
true,
bool policy =
true)
71 : name(
std::move(name)), calculate(
std::move(calc)), applies_to{pre, piracy, policy} {}
142 #define DIST_FNS(variable) \ 143 double variable(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 144 double variable##_sd(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 145 double variable##_min(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 146 double variable##_5th(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 147 double variable##_10th(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 148 double variable##_25th(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 149 double variable##_median(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 150 double variable##_75th(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 151 double variable##_90th(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 152 double variable##_95th(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); \ 153 double variable##_max(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to); 187 double books_written_pc(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
191 double books_bought(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
197 double books_pirated(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
201 double books_public_copies(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
229 double reader_spending(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
236 double reader_taxes(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
243 double reader_spending_total(
const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to);
262 std::string
csv_fix(std::string val);
std::string csv_fix(std::string val)
Takes a string, manipulates it into our simplified CSV-suitable value by replacing any special charac...
double books_bought(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average number of books purchased per reader per period.
double book_p1(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Returns the average second-period price of books written in the given period range.
double book_p0(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Returns the average first-sale-period price of books written in the given period range.
double book_market_periods(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Calculates the average market life of books written between from and to, in simulation periods...
double book_profit(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average profit (i.e.
Primary namespace for all Creativity library code.
Definition: config.hpp:4
double book_author_level(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Distribution values (mean, standard deviation, min, max, quantiles) for author creation scale of the ...
double book_p2(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Returns the average third-period price of books.
bool piracy
True if this field applies to piracy periods.
Definition: simdata.hpp:54
const std::string name
The name of this parameter (to be included in the output header).
Definition: simdata.hpp:24
Definition: Variable.hpp:389
double book_author_effort(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Distribution values (mean, standard deviation, min, max, quantiles) for author effort level of each b...
std::vector< initial_datum > initial_data_fields()
Average number of readers caught per 100 readers per period for piracy.
double books_written_pc(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average number of books written per 100 agents per period.
double reader_piracy_spending(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average per-reader piracy cost expenditure for obtaining pirated copies of books, averaged over the g...
double books_public_copies(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average number of books obtained from the public provider per reader per period.
double net_u(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Distribution of reader net utility values over the period range.
bool pre
True if this field applies to pre-piracy periods.
Definition: simdata.hpp:53
double book_gross_margin(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average gross margin (i.e.
double reader_spending(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average per-reader expenditure for obtaining books from any source.
double book_sales(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average copies sold per book.
Class for state storage access which accesses State values.
Definition: Storage.hpp:27
Struct for holding a simulation data value calculator.
Definition: simdata.hpp:42
double reader_spending_total(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average per-reader expenditure on books, including lump-sum taxes (e.g.
initial_datum(std::string name, std::function< IntType(const CreativitySettings &)> &&calc_int)
Constructs a simulation parameter datum that returns an integral value.
Definition: simdata.hpp:34
initial_datum(std::string name, std::function< double(const CreativitySettings &)> &&calc_double)
Constructs a simulation parameter datum that returns a double value.
Definition: simdata.hpp:37
double reader_market_spending(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average per-reader private market spending on books, averaged over the given period.
#define DIST_FNS(variable)
Macro to generate mean, sd, and quantile functions for a given variable.
Definition: simdata.hpp:142
datum(std::string &&name, decltype(calculate) calc, bool pre=true, bool piracy=true, bool policy=true)
Constructor.
Definition: simdata.hpp:70
const std::function< long(const CreativitySettings &)> calc_int
Returns an integer value for this parameter, if callable.
Definition: simdata.hpp:26
const std::function< double(const state::Storage &, eris::eris_time_t, eris::eris_time_t)> calculate
Callable object called to calculate the value of the parameter.
Definition: simdata.hpp:50
double books_pirated(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average number of books pirated per reader per period.
const std::string name
The name of this parameter (will be prefixed with pre_, new_, or post_)
Definition: simdata.hpp:44
double book_revenue(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average per-book revenue over the given period.
bool policy
True if this field applies to policy periods.
Definition: simdata.hpp:55
Struct for holding a simulator parameter.
Definition: simdata.hpp:22
Simulation parameters that are used to configure the simulation when calling setup().
Definition: CreativitySettings.hpp:10
std::vector< datum > data_fields()
Returns a vector of all supported calculated datum values.
double reader_public_spending(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Average per-reader public sharing expenditure for obtaining public provider copies of books...
const std::function< double(const CreativitySettings &)> calc_double
Returns a double value for this parameter, if callable.
Definition: simdata.hpp:28
double book_quality(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Distribution values (mean, standard deviation, min, max, quantiles) for quality of books written duri...
double reader_taxes(const state::Storage &cs, eris::eris_time_t from, eris::eris_time_t to)
Returns the average per-reader lump-sum taxes collected, averaged over the given period.