<jupyter_start><jupyter_text>Minimal model*<NAME>*The shortest model ever<jupyter_code>from cadCAD.configuration import Experiment
from cadCAD.configuration.utils import config_sim
from cadCAD.configuration import Configuration
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor
import pandas as pd
import numpy as np
MONTE_CARLO_RUNS = 1
SIMULATION_TIMESTEPS = 100

sys_params = {
    'parameter': [1]
}

genesis_states = {
    'something': 0
}

def s_something(params, 
                substep, 
                state_history, 
                prev_state, 
                policy_input):
    new_value = np.random.randn()
    return ('something', new_value)


partial_state_update_blocks = [
    {
        'policies': {
            
        },
        'variables': {
            'something': s_something
        }
    }
]

sim_config = {
    'N': MONTE_CARLO_RUNS,
    'T': range(SIMULATION_TIMESTEPS),
    'M': sys_params
}
sim_params = config_sim(sim_config)

exp = Experiment()
exp.append_configs(
    sim_configs=sim_params,
    initial_state=genesis_states,
    partial_state_update_blocks=partial_state_update_blocks
)

from cadCAD import configs

exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx,
                      configs=configs)
raw_system_events, tensor_field, sessions = simulation.execute()
df = pd.DataFrame(raw_system_events)
df.set_index('timestep')['something'].plot()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup