Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results doesn't have the results of last simulation when running 4 parallelized configurations #195

Closed
Stefenon opened this issue Sep 16, 2020 · 3 comments
Assignees

Comments

@Stefenon
Copy link

Hello,

I had an issue trying to execute cadCAD with multiple configurations. It works properly when running up to 3 configs. However, when the number of configs is increased to 4, the last configuration's result doesn't appear on the resulting dataframe, although the configuration count indicates the right number when executing run().

This is the run.py script:

# The following imports NEED to be in the exact order
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor

# Simulation configs, input any new simulations here
from covid_19_sir import config
from covid_19_seir import config
from covid_19_seird import config
from covid_19_seir_3778 import config


from cadCAD import configs
import pandas as pd


def run(drop_midsteps: bool=True) -> pd.DataFrame:
    """
    Run all experiments and return their output on the dataset column.
    Each line represents an iteration of the parameter-sweep combinations.
    """
    exec_mode = ExecutionMode()
    multi_mode_ctx = ExecutionContext(context=exec_mode.local_mode)
    run = Executor(exec_context=multi_mode_ctx, configs=configs)
    raw_result, _, _ = run.execute()
    results = pd.DataFrame(raw_result)
    return results

The config scripts follow the same pattern:

MONTE_CARLO_RUNS = 1 # N monte carlo runs

from cadCAD.configuration.utils import config_sim
from cadCAD.configuration import Experiment
from .model.state_variables import genesis_states
from .model.partial_state_update_block import partial_state_update_block
from .model.sys_params import sys_params as sys_params
from .sim_params import SIMULATION_TIME_STEPS


sim_config = config_sim (
    {
        'N': MONTE_CARLO_RUNS,
        'T': range(SIMULATION_TIME_STEPS), # number of timesteps
        'M': sys_params,
    }
)

exp = Experiment()

exp.append_configs(
    sim_configs=sim_config,
    initial_state=genesis_states,
    partial_state_update_blocks=partial_state_update_block
)

If I change the order they are imported, the last config that was imported is still not on the dataframe.

Has anyone had a similar problem?

@JEJodesty JEJodesty self-assigned this Sep 22, 2020
@JEJodesty
Copy link
Member

JEJodesty commented Sep 22, 2020

Thanks @Stefenon
Coincidentally Encountered this issue last night and found a solution
Hot-Fixing today

@JEJodesty
Copy link
Member

JEJodesty commented Sep 22, 2020

@Stefenon
Try it now
Sorry for the wait
Thanks for your contribution!

@Stefenon
Copy link
Author

Great! It's working properly now, thanks!

@JEJodesty JEJodesty changed the title Resulting dataframe doesn't have the results of last simulation when running 4 configurations Results doesn't have the results of last simulation when running 4 parallelized configurations Oct 26, 2020
JEJodesty added a commit that referenced this issue Nov 19, 2020
JEJodesty added a commit that referenced this issue Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants