Skip to content

Commit

Permalink
Merge pull request cadCAD-org#52 from joraojr/master
Browse files Browse the repository at this point in the history
Fix tutorials and demo code
  • Loading branch information
tylerdmace authored Jun 2, 2022
2 parents 6382676 + f6740ff commit b99c82d
Show file tree
Hide file tree
Showing 30 changed files with 2,493 additions and 4,255 deletions.

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions demos/Agent_Based_Modeling/prey_predator_abm/model/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pandas as pd
from .parts.utils import *
from model import config
from cadCAD.engine import ExecutionMode, ExecutionContext,Executor
from cadCAD import configs
from .config import exp

def run():
'''
Expand All @@ -13,7 +12,7 @@ def run():
exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx, configs=configs)
simulation = Executor(exec_context=local_mode_ctx, configs=exp.configs)
raw_system_events, tensor_field, sessions = simulation.execute()
# Result System Events DataFrame
df = pd.DataFrame(raw_system_events)
Expand Down
769 changes: 213 additions & 556 deletions demos/Multiscale/ThreeSided/ThreeSidedMarket.ipynb

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions demos/Multiscale/ThreeSided/model/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pandas as pd
from .parts.utils import *
from model import config
from cadCAD.engine import ExecutionMode, ExecutionContext,Executor
from cadCAD import configs
from .config import exp

def run():
'''
Expand All @@ -12,7 +11,7 @@ def run():
exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx, configs=configs)
simulation = Executor(exec_context=local_mode_ctx, configs=exp.configs)
raw_system_events, tensor_field, sessions = simulation.execute()
# Result System Events DataFrame
df = pd.DataFrame(raw_system_events)
Expand Down
530 changes: 156 additions & 374 deletions demos/Multiscale/ThreeSidedBasic/BasicThreeSidedMarketModel.ipynb

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions demos/Multiscale/ThreeSidedBasic/model/run.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pandas as pd
from .parts.utils import *
from model import config
from .parts.utils import *
from cadCAD.engine import ExecutionMode, ExecutionContext,Executor
from cadCAD import configs

from .config import exp
def run():
'''
Definition:
Expand All @@ -12,7 +9,7 @@ def run():
exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx, configs=configs)
simulation = Executor(exec_context=local_mode_ctx, configs=exp.configs)
raw_system_events, tensor_field, sessions = simulation.execute()
# Result System Events DataFrame
df = pd.DataFrame(raw_system_events)
Expand Down
421 changes: 180 additions & 241 deletions demos/Multiscale/adoption_funnel/adoption_funnel_model.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demos/Multiscale/adoption_funnel/model/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# # # # # # # # # # # # # # # # # # # # GENESIS SWEEP LOGIC # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

for c in configs: # for each configuration object
for c in exp.configs: # for each configuration object
c.initial_state = deepcopy(c.initial_state) # make a deepcopy of the initial state dict (it's shared across configs by default)

c.initial_state['pool'] = Adoption_Pool(c.sim_config['M']['SOURCE_POOL'])
10 changes: 4 additions & 6 deletions demos/Multiscale/adoption_funnel/model/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import pandas as pd
from .parts.utils import *
from model import config
from cadCAD.engine import ExecutionMode, ExecutionContext,Executor
from cadCAD import configs
from .config import exp


def get_M(k, v):
Expand All @@ -13,7 +11,7 @@ def get_M(k, v):
config_ids = [
dict(
get_M(k, v) for k, v in config.__dict__.items() if k in ['simulation_id', 'run_id', 'sim_config', 'subset_id']
) for config in configs
) for config in exp.configs
]


Expand All @@ -25,15 +23,15 @@ def run(drop_midsteps=True):
exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx, configs=configs)
simulation = Executor(exec_context=local_mode_ctx, configs=exp.configs)
raw_system_events, tensor_field, sessions = simulation.execute()
# Result System Events DataFrame
df = pd.DataFrame(raw_system_events)

config_ids = [
dict(
get_M(k, v) for k, v in config.__dict__.items() if k in ['simulation_id', 'run_id', 'sim_config', 'subset_id']
) for config in configs
) for config in exp.configs
]

results = pd.DataFrame()
Expand Down
6 changes: 2 additions & 4 deletions demos/Multiscale/amm_mechanism/model/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import pandas as pd
from .parts.utils import *
from model import config
from cadCAD.engine import ExecutionMode, ExecutionContext,Executor
from cadCAD import configs
from .config import exp

def run():
'''
Expand All @@ -13,7 +11,7 @@ def run():
exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx, configs=configs)
simulation = Executor(exec_context=local_mode_ctx, configs=exp.configs)
raw_system_events, tensor_field, sessions = simulation.execute()
# Result System Events DataFrame
df = pd.DataFrame(raw_system_events)
Expand Down
Loading

0 comments on commit b99c82d

Please sign in to comment.