Newer
Older
notebooks / py / 20200221_experiment_scheduling.py
#%% [markdown]
# Complex experiments in cognitive science require participants to perform multiple tasks and capture observations with different modalities. This notebook demonstrates some possible solutions for the problem of scheduling experimental tasks.

# First, we model a study with 12 sessions. Sessions consist of several surveys before and after a set of experimental tasks. We then define constraints and solve for a schedule for the given scenario. This scenario only plans the experiment for a single subject.

#%%
#! pip install pyschedule

from pyschedule import Scenario, solvers, plotters, alt

# the planning horizon has 
s = Scenario('Prolific500', horizon=60)

session = s.Resource('Session', num=1)

mmi = s.Task('MMI', length=3, delay_cost=1)
games = s.Task('games',length=45, delay_cost=1, is_group=True)
nasa_tlx = s.Task('NSA_TLX', length=1, delay_cost=1)

# define the tasks that each subject must perform in first session
mmi += alt(session)
games += alt(session)
nasa_tlx += alt(session)

# add precedences
s += mmi < games 
s += games < nasa_tlx

# compute and print session schedules
solvers.mip.solve(s,msg=1)
print(s.solution())

plotters.matplotlib.plot(s)