import psyneulink as pnl comp = pnl.Composition(name='comp') A = pnl.TransferMechanism(name='A') B = pnl.TransferMechanism(name='B') C = pnl.TransferMechanism(name='C') comp.add_linear_processing_pathway([A, B, C]) comp.scheduler.add_condition_set({ A: pnl.AtNCalls(A, 0), B: pnl.Always(), C: pnl.EveryNCalls(B, 5), }) comp.run(inputs={A: 1}) # A, B, B, B, B, B, C print(comp.scheduler.execution_list[comp.default_execution_id]) with open(__file__.replace('.py', '.json'), 'w') as f: f.write(comp.json_summary + '\n')
comp.add_projection( projection=pnl.MappingProjection( name="MappingProjection_from_A_RESULT__to_B_InputPort_0_", function=pnl.LinearMatrix(matrix=[[1.0]]), ), sender=A, receiver=B, ) comp.add_projection( projection=pnl.MappingProjection( name="MappingProjection_from_B_RESULT__to_C_InputPort_0_", function=pnl.LinearMatrix(matrix=[[1.0]]), ), sender=B, receiver=C, ) comp.scheduler.add_condition( A, pnl.AtNCalls(dependency=A, n=0, time_scale=pnl.TimeScale.ENVIRONMENT_STATE_UPDATE), ) comp.scheduler.add_condition(B, pnl.Always()) comp.scheduler.add_condition(C, pnl.EveryNCalls(dependency=B, n=5)) comp.scheduler.termination_conds = { pnl.TimeScale.ENVIRONMENT_SEQUENCE: pnl.Never(), pnl.TimeScale.ENVIRONMENT_STATE_UPDATE: pnl.AllHaveRun(), }