Beispiel #1
0
/**
 * Execute our iterative initialisation phases.
 */
void Iterative::Execute() {
  if (convergence_years_.size() == 0) {
    timesteps::Manager& time_step_manager = *model_->managers().time_step();
    time_step_manager.ExecuteInitialisation(label_, years_);

  } else {
    unsigned total_years = 0;
    for (unsigned years : convergence_years_) {
      timesteps::Manager& time_step_manager = *model_->managers().time_step();
      time_step_manager.ExecuteInitialisation(label_, years - (total_years + 1));


      total_years += years - (total_years + 1);
      if ((total_years + 1) >= years_) {
        time_step_manager.ExecuteInitialisation(label_, 1);
        break;
      }

      cached_partition_.BuildCache();
      time_step_manager.ExecuteInitialisation(label_, 1);
      ++total_years;

      if (CheckConvergence()) {
        LOG_FINEST() << " year Convergence was reached = " << years;
        break;
      }
      LOG_FINEST() << "Initial year = " << years;
    }
  }
}
/**
 * Execute our iterative initialisation phases.
 */
void Iterative::Execute() {
  if (convergence_years_.size() == 0) {
    timesteps::Manager& time_step_manager = *model_->managers().time_step();
    time_step_manager.ExecuteInitialisation(label_, years_);

  } else {
    unsigned total_years = 0;
    for (unsigned years : convergence_years_) {
      timesteps::Manager& time_step_manager = *model_->managers().time_step();
      time_step_manager.ExecuteInitialisation(label_, years - (total_years + 1));


      total_years += years - (total_years + 1);
      if ((total_years + 1) >= years_) {
        time_step_manager.ExecuteInitialisation(label_, 1);
        break;
      }

      cached_partition_.BuildCache();
      time_step_manager.ExecuteInitialisation(label_, 1);
      ++total_years;

      if (CheckConvergence()) {
        LOG_FINEST() << " year Convergence was reached = " << years;
        break;
      }
      LOG_FINEST() << "Initial year = " << years;
    }
  }

/*
 * Ignore B0 Length Based Models for now.
  LOG_FINEST() << "Number of Beverton-Holt recruitment processes in annual cycle = " << recruitment_process_.size();
  LOG_FINEST() << "Number of Beverton-Holt recruitment processes with deviations in annual cycle = " << recruitment_process_with_devs_.size();
  // We are at Equilibrium state here
  // Check if we have B0 initialised or R0 initialised recruitment
  bool B0_intial_recruitment = false;
  for (auto recruitment_process : recruitment_process_) {
    if (recruitment_process->bo_initialised()) {
      LOG_FINEST() << PARAM_B0 << " has been defined for process labelled " << recruitment_process->label();
      recruitment_process->ScalePartition();
      B0_intial_recruitment = true;
    }
  }
  for (auto recruitment_process_with_devs : recruitment_process_with_devs_) {
    if (recruitment_process_with_devs->bo_initialised()) {
      LOG_FINEST() << PARAM_B0 << " has been defined for process labelled " << recruitment_process_with_devs->label();
      recruitment_process_with_devs->ScalePartition();
      B0_intial_recruitment = true;
    }
  }
  if (B0_intial_recruitment) {
    // Calculate derived quanitities in the right space if we have a B0 initialised model
    timesteps::Manager& time_step_manager = *model_->managers().time_step();
    time_step_manager.ExecuteInitialisation(label_, 1);
  }
*/
}