Added ctrl_cell_ids

This commit is contained in:
rastogi 2025-10-30 21:36:03 +01:00
parent 1901400f7b
commit 8e377d4ca0
4 changed files with 20 additions and 12 deletions

View File

@ -117,8 +117,10 @@ setup <- list(
iterations <- 20
dt <- 100
control_iteration <- 10
species_epsilon <- rep(0.001, length(dht_species))
checkpoint_interval <- 10
control_interval <- 10
mape_threshold <- rep(3.5e-3, 13)
ctrl_cell_ids <- seq(0, (rows*cols)/2 - 1, by = rows+1)
#out_save <- seq(50, iterations, by = 50)
@ -126,6 +128,8 @@ list(
timesteps = rep(dt, iterations),
store_result = TRUE,
#out_save = out_save,
control_iteration = control_iteration,
species_epsilon = species_epsilon
checkpoint_interval = checkpoint_interval,
control_interval = control_interval,
mape_threshold = mape_threshold,
ctrl_cell_ids = ctrl_cell_ids
)

View File

@ -52,6 +52,7 @@ public:
std::uint32_t control_interval;
std::vector<std::string> species_names;
std::vector<double> mape_threshold;
std::vector<double> ctrl_cell_ids;
};
void enableControlLogic(const ControlSetup &setup) {
@ -60,6 +61,7 @@ public:
this->control_interval = setup.control_interval;
this->species_names = setup.species_names;
this->mape_threshold = setup.mape_threshold;
this->ctrl_cell_ids = setup.ctrl_cell_ids;
}
bool getControlIntervalEnabled() const {
@ -78,6 +80,8 @@ public:
std::vector<double> getMapeThreshold() const { return this->mape_threshold; }
std::vector<uint32_t> getCtrlCellIds() const { return this->ctrl_cell_ids; }
/* Profiling getters */
auto getUpdateCtrlLogicTime() const { return this->prep_t; }
@ -100,6 +104,7 @@ private:
std::uint32_t rollback_count = 0;
std::uint32_t sur_disabled_counter = 0;
std::vector<double> mape_threshold;
std::vector<uint32_t> ctrl_cell_ids;
std::vector<std::string> species_names;
std::string out_dir;

View File

@ -250,10 +250,13 @@ int parseInitValues(int argc, char **argv, RuntimeParameters &params) {
params.timesteps =
Rcpp::as<std::vector<double>>(global_rt_setup->operator[]("timesteps"));
params.checkpoint_interval = Rcpp::as<uint32_t>(global_rt_setup->operator[]("checkpoint_interval"));
params.control_interval =
Rcpp::as<uint32_t>(global_rt_setup->operator[]("control_interval"));
params.mape_threshold = Rcpp::as<std::vector<double>>(
global_rt_setup->operator[]("mape_threshold"));
params.ctrl_cell_ids = Rcpp::as<std::vector<uint32_t>>(
global_rt_setup->operator[]("ctrl_cell_ids"));
catch (const std::exception &e) {
ERRMSG("Error while parsing R scripts: " + std::string(e.what()));

View File

@ -41,7 +41,6 @@ static const inline std::string r_runtime_parameters = "mysetup";
struct RuntimeParameters {
std::string out_dir;
std::vector<double> timesteps;
std::vector<double> species_epsilon;
Rcpp::List init_params;
@ -52,13 +51,10 @@ struct RuntimeParameters {
bool print_progress = false;
std::uint32_t penalty_iteration = 0;
std::uint32_t max_penalty_iteration = 0;
std::uint32_t penalty_counter = 0;
std::uint32_t next_penalty_check = 0;
bool rollback_simulation = false;
bool control_iteration_active = false;
std::uint32_t control_iteration = 1;
std::uint32_t checkpoint_interval = 0;
std::uint32_t control_interval = 0;
std::vector<double> mape_threshold;
std::vector<double> ctrl_cell_ids;
static constexpr std::uint32_t WORK_PACKAGE_SIZE_DEFAULT = 32;
std::uint32_t work_package_size = WORK_PACKAGE_SIZE_DEFAULT;