Project Alice
Loading...
Searching...
No Matches
economy.cpp File Reference
#include "economy.hpp"
#include "economy_templates.hpp"
#include "demographics.hpp"
#include "dcon_generated.hpp"
#include "ai.hpp"
#include "system_state.hpp"
#include "prng.hpp"
#include "math_fns.hpp"
#include "nations_templates.hpp"
#include "province_templates.hpp"
#include "triggers.hpp"
Include dependency graph for economy.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  economy::commodity_profit_holder
 
struct  economy::profit_distribution
 

Namespaces

namespace  economy
 

Enumerations

enum class  economy::economy_reason {
  economy::pop , economy::factory , economy::rgo , economy::artisan ,
  economy::construction , economy::nation , economy::stockpile , economy::overseas_penalty ,
  economy::trade
}
 

Functions

float economy::pop_min_wage_factor (sys::state &state, dcon::nation_id n)
 
template<typename T >
ve::fp_vector economy::ve_pop_min_wage_factor (sys::state &state, T n)
 
template<typename T >
ve::fp_vector economy::ve_artisan_min_wage (sys::state &state, T markets)
 
template<typename T >
ve::fp_vector economy::ve_farmer_min_wage (sys::state &state, T markets, ve::fp_vector min_wage_factor)
 
template<typename T >
ve::fp_vector economy::unskilled_labor_supply_multiplier (sys::state &state, T markets)
 
template<typename T >
ve::fp_vector economy::skilled_labor_supply_multiplier (sys::state &state, T markets)
 
float economy::unskilled_labor_supply_multiplier (sys::state &state, dcon::market_id markets)
 
float economy::skilled_labor_supply_multiplier (sys::state &state, dcon::market_id markets)
 
template<typename T >
ve::fp_vector economy::ve_laborer_min_wage (sys::state &state, T markets, ve::fp_vector min_wage_factor)
 
float economy::farmer_min_wage (sys::state &state, dcon::market_id m, float min_wage_factor)
 
float economy::laborer_min_wage (sys::state &state, dcon::market_id m, float min_wage_factor)
 
float economy::expected_savings_per_capita (sys::state &state)
 
void economy::sanity_check (sys::state &state)
 
float economy::price (sys::state const &state, dcon::state_instance_id s, dcon::commodity_id c)
 
float economy::price (sys::state const &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::price (sys::state &state, dcon::commodity_id c)
 
template<typename T >
ve::fp_vector economy::ve_price (sys::state const &state, T s, dcon::commodity_id c)
 
float economy::price (sys::state const &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::supply (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::supply (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::domestic_trade_volume (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::supply (sys::state &state, dcon::commodity_id c)
 
float economy::demand (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::demand (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::demand (sys::state &state, dcon::commodity_id c)
 
float economy::consumption (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::consumption (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::consumption (sys::state &state, dcon::commodity_id c)
 
float economy::market_pool (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::market_pool (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::market_pool (sys::state &state, dcon::commodity_id c)
 
float economy::demand_satisfaction (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::demand_satisfaction (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::demand_satisfaction (sys::state &state, dcon::commodity_id c)
 
float economy::average_capitalists_luxury_cost (sys::state &state, dcon::nation_id s)
 
float economy::export_volume (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::export_volume (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
trade_volume_data_detailed economy::export_volume_detailed (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
float economy::import_volume (sys::state &state, dcon::market_id s, dcon::commodity_id c)
 
float economy::import_volume (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
trade_volume_data_detailed economy::import_volume_detailed (sys::state &state, dcon::nation_id s, dcon::commodity_id c)
 
void economy::register_demand (sys::state &state, dcon::market_id s, dcon::commodity_id commodity_type, float amount, economy_reason reason)
 
template<typename T >
void economy::register_demand (sys::state &state, T s, dcon::commodity_id commodity_type, ve::fp_vector amount, economy_reason reason)
 
template<typename T >
void economy::register_intermediate_demand (sys::state &state, T s, dcon::commodity_id c, ve::fp_vector amount, economy_reason reason)
 
void economy::register_construction_demand (sys::state &state, dcon::market_id s, dcon::commodity_id commodity_type, float amount)
 
void economy::register_domestic_supply (sys::state &state, dcon::market_id s, dcon::commodity_id commodity_type, float amount, economy_reason reason)
 
void economy::register_foreign_supply (sys::state &state, dcon::market_id s, dcon::commodity_id commodity_type, float amount, economy_reason reason)
 
template<typename T >
void economy::register_domestic_supply (sys::state &state, T s, dcon::commodity_id commodity_type, ve::fp_vector amount, economy_reason reason)
 
template void economy::for_each_new_factory< std::function< void(new_factory)> > (sys::state &, dcon::state_instance_id, std::function< void(new_factory)> &&)
 
template void economy::for_each_upgraded_factory< std::function< void(upgraded_factory)> > (sys::state &, dcon::state_instance_id, std::function< void(upgraded_factory)> &&)
 
bool economy::can_take_loans (sys::state &state, dcon::nation_id n)
 
float economy::interest_payment (sys::state &state, dcon::nation_id n)
 
float economy::max_loan (sys::state &state, dcon::nation_id n)
 
int32_t economy::most_recent_price_record_index (sys::state &state)
 
int32_t economy::previous_price_record_index (sys::state &state)
 
int32_t economy::most_recent_gdp_record_index (sys::state &state)
 
int32_t economy::previous_gdp_record_index (sys::state &state)
 
float economy::ideal_pound_conversion_rate (sys::state &state, dcon::market_id n)
 
float economy::gdp_adjusted (sys::state &state, dcon::market_id n)
 
float economy::gdp_adjusted (sys::state &state, dcon::nation_id n)
 
float economy::full_spending_cost (sys::state &state, dcon::nation_id n)
 
void economy::populate_army_consumption (sys::state &state)
 
void economy::populate_navy_consumption (sys::state &state)
 
void economy::populate_construction_consumption (sys::state &state)
 
float economy::commodity_daily_production_amount (sys::state &state, dcon::commodity_id c)
 
float economy::stockpile_commodity_daily_increase (sys::state &state, dcon::commodity_id c, dcon::nation_id n)
 
float economy::global_market_commodity_daily_increase (sys::state &state, dcon::commodity_id c)
 
std::vector< dcon::factory_type_id > economy::commodity_get_factory_types_as_output (sys::state const &state, dcon::commodity_id output_good)
 
bool economy::has_factory (sys::state const &state, dcon::state_instance_id si)
 
void economy::initialize_artisan_distribution (sys::state &state)
 
bool economy::valid_need (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
template<typename T >
ve::mask_vector economy::valid_need (sys::state &state, T n, dcon::commodity_id c)
 
bool economy::valid_life_need (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
bool economy::valid_everyday_need (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
bool economy::valid_luxury_need (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
void economy::initialize_needs_weights (sys::state &state, dcon::market_id n)
 
float economy::need_weight (sys::state &state, dcon::market_id n, dcon::commodity_id c)
 
void economy::rebalance_needs_weights (sys::state &state, dcon::market_id n)
 
void economy::convert_commodities_into_ingredients (sys::state &state, std::vector< float > &buffer_commodities, std::vector< float > &buffer_ingredients, std::vector< float > &buffer_weights)
 
void economy::presimulate (sys::state &state)
 
bool economy::has_building (sys::state const &state, dcon::state_instance_id si, dcon::factory_type_id fac)
 
bool economy::is_bankrupt_debtor_to (sys::state &state, dcon::nation_id debt_holder, dcon::nation_id debtor)
 
bool economy::nation_is_constructing_factories (sys::state &state, dcon::nation_id n)
 
bool economy::nation_has_closed_factories (sys::state &state, dcon::nation_id n)
 
template<typename T >
auto economy::artisan_input_multiplier (sys::state &state, T nations)
 
template<typename T >
auto economy::artisan_output_multiplier (sys::state &state, T nations)
 
template<typename T >
auto economy::artisan_throughput_multiplier (sys::state &state, T nations)
 
template<typename T , typename S >
ve::fp_vector economy::base_artisan_profit (sys::state &state, T markets, S nations, dcon::commodity_id c)
 
float economy::base_artisan_profit (sys::state &state, dcon::market_id market, dcon::commodity_id c)
 
template<typename T >
ve::mask_vector economy::ve_valid_artisan_good (sys::state &state, T nations, dcon::commodity_id cid)
 
bool economy::valid_artisan_good (sys::state &state, dcon::nation_id nations, dcon::commodity_id cid)
 
float economy::pseudo_exp_for_negative (float f)
 
ve::fp_vector economy::ve_pseudo_exp_for_negative (ve::fp_vector f)
 
template<typename T , typename S >
void economy::adjust_artisan_balance (sys::state &state, T markets, S nations)
 
void economy::initialize (sys::state &state)
 
float economy::sphere_leader_share_factor (sys::state &state, dcon::nation_id sphere_leader, dcon::nation_id sphere_member)
 
float economy::effective_tariff_import_rate (sys::state &state, dcon::nation_id n)
 
float economy::effective_tariff_export_rate (sys::state &state, dcon::nation_id n)
 
void economy::update_factory_triggered_modifiers (sys::state &state)
 
float economy::subsistence_size (sys::state const &state, dcon::province_id p)
 
float economy::rgo_effective_size (sys::state const &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::rgo_total_effective_size (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
float economy::subsistence_max_pseudoemployment (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
float economy::rgo_total_employment (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
float economy::rgo_max_employment (sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::rgo_total_max_employment (sys::state &state, dcon::nation_id n, dcon::province_id p)
 
void economy::update_local_subsistence_factor (sys::state &state)
 
float economy::adjusted_subsistence_score (sys::state &state, dcon::province_id p)
 
template<typename T >
ve::fp_vector economy::ve_adjusted_subsistence_score (sys::state &state, T p)
 
void economy::update_land_ownership (sys::state &state)
 
int32_t economy::factory_priority (sys::state const &state, dcon::factory_id f)
 
void economy::set_factory_priority (sys::state &state, dcon::factory_id f, int32_t priority)
 
bool economy::factory_is_profitable (sys::state const &state, dcon::factory_id f)
 
void economy::update_rgo_employment (sys::state &state)
 
float economy::factory_max_employment (sys::state const &state, dcon::factory_id f)
 
float economy::factory_primary_employment (sys::state const &state, dcon::factory_id f)
 
float economy::factory_secondary_employment (sys::state const &state, dcon::factory_id f)
 
float economy::factory_total_employment (sys::state const &state, dcon::factory_id f)
 
void economy::update_factory_employment (sys::state &state)
 
float economy::rgo_efficiency (sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::rgo_full_production_quantity (sys::state &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
 
float economy::factory_min_input_available (sys::state const &state, dcon::market_id m, dcon::factory_type_id fac_type)
 
float economy::factory_input_total_cost (sys::state const &state, dcon::market_id m, dcon::factory_type_id fac_type)
 
float economy::factory_min_e_input_available (sys::state const &state, dcon::market_id m, dcon::factory_type_id fac_type)
 
float economy::factory_e_input_total_cost (sys::state const &state, dcon::market_id m, dcon::factory_type_id fac_type)
 
float economy::priority_multiplier (sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n)
 
float economy::nation_factory_input_multiplier (sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n)
 
float economy::nation_factory_output_multiplier (sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n)
 
float economy::factory_input_multiplier (sys::state const &state, dcon::factory_id fac, dcon::nation_id n, dcon::province_id p, dcon::state_instance_id s)
 
float economy::factory_throughput_multiplier (sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n, dcon::province_id p, dcon::state_instance_id s)
 
float economy::factory_output_multiplier_no_secondary_workers (sys::state const &state, dcon::factory_id fac, dcon::nation_id n, dcon::province_id p)
 
float economy::factory_output_multiplier (sys::state const &state, dcon::factory_id fac, dcon::nation_id n, dcon::market_id m, dcon::province_id p)
 
float economy::factory_max_production_scale_non_modified (sys::state const &state, dcon::factory_fat_id fac)
 
float economy::factory_max_production_scale (sys::state const &state, dcon::factory_id fac, float mobilization_impact, bool occupied)
 
float economy::factory_desired_raw_profit (dcon::factory_id fac, float spendings)
 
void economy::update_single_factory_consumption (sys::state &state, dcon::factory_id f, dcon::province_id p, dcon::state_instance_id s, dcon::market_id m, dcon::nation_id n, float mobilization_impact, bool occupied)
 
void economy::update_single_factory_production (sys::state &state, dcon::factory_id f, dcon::market_id m, dcon::nation_id n)
 
rgo_workers_breakdown economy::rgo_relevant_population (sys::state &state, dcon::province_id p, dcon::nation_id n)
 
float economy::rgo_desired_worker_norm_profit (sys::state &state, dcon::province_id p, dcon::market_id m, dcon::nation_id n, float min_wage, float total_relevant_population)
 
float economy::rgo_expected_worker_norm_profit (sys::state &state, dcon::province_id p, dcon::market_id m, dcon::nation_id n, dcon::commodity_id c)
 
float economy::convex_function (float x)
 
void economy::update_province_rgo_employment (sys::state &state, dcon::province_id p, dcon::market_id m, dcon::nation_id n, float mobilization_impact, float expected_min_wage)
 
void economy::update_province_rgo_production (sys::state &state, dcon::province_id p, dcon::market_id m, dcon::nation_id n)
 
template<typename T , typename S , typename U >
void economy::update_artisan_consumption (sys::state &state, T markets, S nations, U states, ve::fp_vector expected_min_wage, ve::fp_vector mobilization_impact)
 
template<typename T >
void economy::update_market_artisan_production (sys::state &state, T markets)
 
float economy::global_non_factory_construction_time_modifier (sys::state &state)
 
float economy::global_factory_construction_time_modifier (sys::state &state)
 
float economy::estimate_construction_spending_from_budget (sys::state &state, dcon::nation_id n, float current_budget)
 
float economy::estimate_construction_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_private_construction_spendings (sys::state &state, dcon::nation_id nid)
 
void economy::populate_private_construction_consumption (sys::state &state)
 
float economy::estimate_stockpile_filling_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_overseas_penalty_spending (sys::state &state, dcon::nation_id n)
 
float economy::full_private_investment_cost (sys::state &state, dcon::nation_id n)
 
void economy::update_national_consumption (sys::state &state, dcon::nation_id n, float spending_scale, float private_investment_scale)
 
void economy::update_pop_consumption (sys::state &state, ve::vectorizable_buffer< float, dcon::nation_id > &invention_count)
 
void economy::advance_construction (sys::state &state, dcon::nation_id n)
 
profit_distribution economy::distribute_factory_profit (sys::state const &state, dcon::state_instance_const_fat_id s, float total_profit)
 
void economy::emulate_construction_demand (sys::state &state, dcon::nation_id n)
 
std::vector< full_construction_state > economy::estimate_private_investment_upgrade (sys::state &state, dcon::nation_id nid)
 
std::vector< full_construction_state > economy::estimate_private_investment_construct (sys::state &state, dcon::nation_id nid, bool craved)
 
std::vector< full_construction_province > economy::estimate_private_investment_province (sys::state &state, dcon::nation_id nid)
 
void economy::run_private_investment (sys::state &state)
 
void economy::daily_update (sys::state &state, bool presimulation, float presimulation_stage)
 
void economy::regenerate_unsaved_values (sys::state &state)
 
float economy::government_consumption (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::factory_type_build_cost (sys::state &state, dcon::nation_id n, dcon::market_id m, dcon::factory_type_id factory_type)
 
float economy::factory_type_output_cost (sys::state &state, dcon::nation_id n, dcon::market_id m, dcon::factory_type_id factory_type)
 
float economy::factory_type_input_cost (sys::state &state, dcon::nation_id n, dcon::market_id m, dcon::factory_type_id factory_type)
 
float economy::nation_factory_consumption (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::nation_pop_consumption (sys::state &state, dcon::nation_id n, dcon::commodity_id c)
 
float economy::nation_total_imports (sys::state &state, dcon::nation_id n)
 
float economy::nation_total_exports (sys::state &state, dcon::nation_id n)
 
float economy::pop_income (sys::state &state, dcon::pop_id p)
 
trade_and_tariff economy::explain_trade_route_commodity (sys::state &state, dcon::trade_route_id trade_route, dcon::commodity_id cid)
 
std::vector< trade_breakdown_item > economy::explain_national_tariff (sys::state &state, dcon::nation_id n, bool import_flag, bool export_flag)
 
float economy::estimate_gold_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_tariff_import_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_tariff_export_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_social_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_pop_payouts_by_income_type (sys::state &state, dcon::nation_id n, culture::income_type in)
 
float economy::estimate_tax_income_by_strata (sys::state &state, dcon::nation_id n, culture::pop_strata ps)
 
float economy::estimate_subsidy_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_war_subsidies_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_reparations_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_war_subsidies_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_reparations_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_diplomatic_balance (sys::state &state, dcon::nation_id n)
 
float economy::estimate_diplomatic_income (sys::state &state, dcon::nation_id n)
 
float economy::estimate_diplomatic_expenses (sys::state &state, dcon::nation_id n)
 
float economy::estimate_domestic_investment (sys::state &state, dcon::nation_id n)
 
float economy::estimate_land_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_naval_spending (sys::state &state, dcon::nation_id n)
 
float economy::estimate_war_subsidies (sys::state &state, dcon::nation_fat_id target, dcon::nation_fat_id source)
 
float economy::estimate_subject_payments_paid (sys::state &state, dcon::nation_id n)
 
float economy::estimate_subject_payments_received (sys::state &state, dcon::nation_id o)
 
construction_status economy::province_building_construction (sys::state &state, dcon::province_id p, province_building_type t)
 
construction_status economy::factory_upgrade (sys::state &state, dcon::factory_id f)
 
bool economy::state_contains_constructed_factory (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id ft)
 
bool economy::state_contains_factory (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id ft)
 
int32_t economy::state_factory_count (sys::state &state, dcon::state_instance_id sid, dcon::nation_id n)
 
float economy::unit_construction_progress (sys::state &state, dcon::province_land_construction_id c)
 
float economy::unit_construction_progress (sys::state &state, dcon::province_naval_construction_id c)
 
void economy::add_factory_level_to_state (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id t, bool is_upgrade)
 
void economy::resolve_constructions (sys::state &state)
 
float economy::estimate_daily_income (sys::state &state, dcon::nation_id n)
 
void economy::try_add_factory_to_state (sys::state &state, dcon::state_instance_id s, dcon::factory_type_id t)
 
command::budget_settings_data economy::budget_minimums (sys::state &state, dcon::nation_id n)
 
command::budget_settings_data economy::budget_maximums (sys::state &state, dcon::nation_id n)
 
void economy::bound_budget_settings (sys::state &state, dcon::nation_id n)
 
void economy::prune_factories (sys::state &state)
 
dcon::modifier_id economy::get_province_selector_modifier (sys::state &state)
 
dcon::modifier_id economy::get_province_immigrator_modifier (sys::state &state)
 
void economy::go_bankrupt (sys::state &state, dcon::nation_id n)
 
float economy::estimate_investment_pool_daily_loss (sys::state &state, dcon::nation_id n)
 

Variables

constexpr auto economy::utility_decay_p = 0.998f
 
constexpr auto economy::current_profits_weight_p
 
constexpr auto economy::short_term_profits_weight_p
 
constexpr auto economy::mid_term_profits_weight_p
 
constexpr auto economy::long_term_profits_weight_p
 
constexpr auto economy::utility_decay_n = 0.998f
 
constexpr auto economy::current_profits_weight_n
 
constexpr auto economy::short_term_profits_weight_n
 
constexpr auto economy::mid_term_profits_weight_n
 
constexpr auto economy::long_term_profits_weight_n
 
constexpr auto economy::utility_decay_trade = 0.1f
 
constexpr auto economy::current_profits_weight_trade
 
constexpr auto economy::short_term_profits_weight_trade
 
constexpr auto economy::mid_term_profits_weight_trade
 
constexpr auto economy::long_term_profits_weight_trade
 
constexpr float economy::ln_2 = 0.30103f
 
constexpr float economy::day_1_build_time_modifier_non_factory = 2.f
 
constexpr float economy::day_inf_build_time_modifier_non_factory = 0.5f
 
constexpr float economy::day_1_derivative_non_factory = -0.2f
 
constexpr float economy::diff_non_factory = day_1_build_time_modifier_non_factory - day_inf_build_time_modifier_non_factory
 
constexpr float economy::shift_non_factory = -diff_non_factory / day_1_derivative_non_factory
 
constexpr float economy::slope_non_factory = diff_non_factory * shift_non_factory
 
constexpr float economy::day_1_build_time_modifier_factory = 0.9f
 
constexpr float economy::day_inf_build_time_modifier_factory = 0.75f
 
constexpr float economy::day_1_derivative_factory = -0.01f
 
constexpr float economy::diff_factory = day_1_build_time_modifier_factory - day_inf_build_time_modifier_factory
 
constexpr float economy::shift_factory = -diff_factory / day_1_derivative_factory
 
constexpr float economy::slope_factory = diff_factory * shift_factory
 
const float economy::courage = 1.0f
 
const float economy::days_prepaid = 5.f