Skip to content

Commit

Permalink
add: farming_stillbirth_rate
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPJT committed Jun 9, 2024
1 parent e818fe1 commit 22572b0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
8 changes: 5 additions & 3 deletions Data/Simulations/Settings.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ birthable_age_min 15 出産の最小可能年齢(歳)
birthable_age_max 50 出産の最大可能年齢(歳)
#Childbirth -------------------- #出産 --------------------------------------------------
birth_interval 10 出産の間隔:10ヶ月(Step)
stillbirth_rate 0.16 死産率
hunter_gatherer_stillbirth_rate 0.18 狩猟採集死産率
farming_stillbirth_rate 0.16 水田稲作死産率
child_agriculture_priority 0.7 片親が農耕文化を持ち、もう一方の片親が農耕文化を持たない時の農耕文化継承の優先度
#Movement -------------------- #移動 --------------------------------------------------
max_settlement_population 80 集落の最大人数(人)
max_hunter_gatherer_settlement_population 25 狩猟採集集落の最大人数(人)
max_farming_settlement_population 80 水田稲作集落の最大人数(人)
min_move_distance 10 最小移動距離
max_move_distance 800 最大移動距離
min_move_probability 1 移動確率下限
max_move_probability 10 移動確率上限
max_move_probability 1 移動確率上限
move_probability_normalization_coefficient 1000 移動確率の正規化係数
4 changes: 2 additions & 2 deletions Library/PAX_MAHOROBA/LocationPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ namespace paxs {
// if (lli.lpe == MurMur3::calcHash("agent1"))
{
// const std::size_t pop_original = settlement.getFarmingPopulation(); // settlement.getPopulation();
//const float pop_original = settlement.getFarmingPopulation() / float(settlement.getPopulation()) * 75.0f; // settlement.getPopulation();
const float pop_original = settlement.getMostMtDNA() / 27.0f * 75.0f; // settlement.getPopulation();
const float pop_original = settlement.getFarmingPopulation() / float(settlement.getPopulation()) * 75.0f; // settlement.getPopulation();
//const float pop_original = settlement.getMostMtDNA() / 27.0f * 75.0f; // settlement.getPopulation();

const std::uint_least8_t pop = (pop_original >= 75) ? 75 : static_cast<std::uint_least8_t>(pop_original);
paxg::Circle(draw_pos,
Expand Down
29 changes: 25 additions & 4 deletions Library/PAX_SAPIENTICA/Simulation/Settlement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace paxs {
}
// 選択居住婚
else {
is_matrilocality = random_dist(*gen);
is_matrilocality = (SimulationConstants::getInstance()->maternal_residence_probability >= random_dist(*gen));
}

// シミュレーションの設定で母方に移住するか父方に移住するかを決める
Expand Down Expand Up @@ -367,6 +367,22 @@ namespace paxs {
/// @brief 人口を取得
std::size_t getPopulation() const noexcept { return agents.size(); }

/// @brief Get the weight population.
/// @brief 重み人口を取得
double getPopulationWeight() const noexcept {
double population_weight = 0;

for (std::size_t i = 0; i < agents.size(); ++i) {
if (agents[i].cgetFarming() > 0) { // 農耕
population_weight += SimulationConstants::getInstance()->max_farming_settlement_weight;
}
else { // 狩猟採集
population_weight += SimulationConstants::getInstance()->max_hunter_gatherer_settlement_weight;
}
}
return population_weight;
}

/// @brief Get the population.
/// @brief 渡来人口を取得
std::size_t getFarmingPopulation() const noexcept {
Expand Down Expand Up @@ -455,11 +471,16 @@ namespace paxs {
if (agent.getBirthIntervalCount() > 0) {
std::uint_least8_t count = agent.decrementBirthIntervalCount();
if (count == 0) {
// 生業文化別の死産率を格納
const float stillbirth_rate = (agent.cgetFarming() > 0) ?
SimulationConstants::getInstance()->farming_stillbirth_rate :
SimulationConstants::getInstance()->hunter_gatherer_stillbirth_rate;

// 死産率 100 %の場合は出産しない
if (SimulationConstants::getInstance()->stillbirth_rate >= 1.0f) continue;
else if (SimulationConstants::getInstance()->stillbirth_rate > 0.0f) {
if (stillbirth_rate >= 1.0f) continue;
else if (stillbirth_rate > 0.0f) {
// 死産
if (random_dist(*gen) < SimulationConstants::getInstance()->stillbirth_rate) continue;
if (random_dist(*gen) < stillbirth_rate) continue;
}
// TODO: 直す
//if (!agent.isMarried()) continue;
Expand Down
2 changes: 1 addition & 1 deletion Library/PAX_SAPIENTICA/Simulation/SettlementGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace paxs {
void divideSettlements() noexcept {
// 人口が最大人口を超えている集落を複数探し、分割する
for (auto& settlement : settlements) {
if (settlement.getPopulation() > SimulationConstants::getInstance()->max_settlement_population) {
if (settlement.getPopulationWeight() >= 1.0) {
// 分割
Settlement divided_settlement = settlement.divide();
moveSettlementToThis(divided_settlement);
Expand Down
6 changes: 4 additions & 2 deletions Library/PAX_SAPIENTICA/Simulation/SettlementSimulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ namespace paxs {
settlement.preUpdate(kanakuma_life_span, emigration_count);
}
}

randomizeSettlements(1, 255, 0);
// 前901年から稲作文化開始
if (step_count > SimulationConstants::getInstance()->steps_per_year * 200) {
randomizeSettlements(1, 255, 0);
}

m_start_time = std::chrono::system_clock::now(); // 婚姻計測開始

Expand Down
15 changes: 10 additions & 5 deletions Library/PAX_SAPIENTICA/Simulation/SimulationConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ namespace paxs {
// 集落をグループ分けする際の1グリッド辺の長さ
std::uint_least32_t grid_length = 64;

// 集落の最大人数
std::uint_least8_t max_settlement_population = 80;
// 農耕集落の最大人数
double max_farming_settlement_weight = 1.0 / 80.0;
// 狩猟採集集落の最大人数
double max_hunter_gatherer_settlement_weight = 1.0 / 25.0;

// 最小移動距離
std::uint_least32_t min_move_distance = 10;
Expand All @@ -91,7 +93,8 @@ namespace paxs {
float child_agriculture_priority = 0.7f;

// 死産率
float stillbirth_rate = 0.1f;
float hunter_gatherer_stillbirth_rate = 0.1f;
float farming_stillbirth_rate = 0.1f;

// 母方居住婚の確率
float maternal_residence_probability = 0.5f;
Expand Down Expand Up @@ -148,15 +151,17 @@ namespace paxs {
stoiFunc(kvt, MurMur3::calcHash("birth_interval"), [&](const std::string& str_) {birth_interval = static_cast<std::uint_least8_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("marriage_search_range"), [&](const std::string& str_) {marriage_search_range = static_cast<std::uint_least32_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("grid_length"), [&](const std::string& str_) {grid_length = static_cast<std::uint_least32_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("max_settlement_population"), [&](const std::string& str_) {max_settlement_population = static_cast<std::uint_least8_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("max_farming_settlement_population"), [&](const std::string& str_) {max_farming_settlement_weight = 1.0 / static_cast<std::uint_least64_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("max_hunter_gatherer_settlement_population"), [&](const std::string& str_) {max_hunter_gatherer_settlement_weight = 1.0 / static_cast<std::uint_least64_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("min_move_distance"), [&](const std::string& str_) {min_move_distance = static_cast<std::uint_least32_t>(std::stoul(str_)); });
stoiFunc(kvt, MurMur3::calcHash("max_move_distance"), [&](const std::string& str_) {max_move_distance = static_cast<std::uint_least32_t>(std::stoul(str_)); });

stoiFunc(kvt, MurMur3::calcHash("min_move_probability"), [&](const std::string& str_) {min_move_probability = std::stoi(str_); });
stoiFunc(kvt, MurMur3::calcHash("max_move_probability"), [&](const std::string& str_) {max_move_probability = std::stoi(str_); });
stoiFunc(kvt, MurMur3::calcHash("move_probability_normalization_coefficient"), [&](const std::string& str_) {move_probability_normalization_coefficient = std::stoi(str_); });
stoiFunc(kvt, MurMur3::calcHash("child_agriculture_priority"), [&](const std::string& str_) {child_agriculture_priority = std::stof(str_); });
stoiFunc(kvt, MurMur3::calcHash("stillbirth_rate"), [&](const std::string& str_) {stillbirth_rate = std::stof(str_); });
stoiFunc(kvt, MurMur3::calcHash("hunter_gatherer_stillbirth_rate"), [&](const std::string& str_) {hunter_gatherer_stillbirth_rate = std::stof(str_); });
stoiFunc(kvt, MurMur3::calcHash("farming_stillbirth_rate"), [&](const std::string& str_) {farming_stillbirth_rate = std::stof(str_); });
stoiFunc(kvt, MurMur3::calcHash("maternal_residence_probability"), [&](const std::string& str_) {maternal_residence_probability = std::stof(str_); });

}
Expand Down

0 comments on commit 22572b0

Please sign in to comment.