示例#1
0
    # create 4 trajectories
    trajectories = project.new_trajectory(pdb_file, 100, 4)
    tasks = map(engine.run, trajectories)
    map(project.tasks.add, tasks)

    # now start adaptive loop
    def strategy_trajectory(loops, num):
        for loop in range(loops):
            trajectories = project.new_ml_trajectory(20, number=num)
            tasks = map(engine.run, trajectories)
            map(project.tasks.add, tasks)
            yield [t.is_done for t in tasks]

    ev1 = ExecutionPlan(strategy_trajectory(100, 10))

    project.add_event(ev1)

    def strategy_model(steps):
        while ev1:
            num = len(project.trajectories)
            task = modeller.execute(list(project.trajectories))
            project.tasks.add(task)
            yield task.is_done
            cond = project.on_ntraj(num + steps)
            yield lambda: cond() or not ev1

    ev2 = ExecutionPlan(strategy_model(100))
    project.add_event(ev2)

    try:
        while project._events:
    events = [
        ExecutionPlan(strategy_trajectory(scheduler, 100, 10))
        for scheduler in gpu_scheduler
    ]
    map(project.add_event, events)

    def strategy_model(scheduler, steps):
        while any(events):
            num = len(project.trajectories)
            task = scheduler(modeller.execute(list(project.trajectories)))
            yield task.is_done
            cond = project.on_ntraj(num + steps)
            yield lambda: cond() or not any(events)

    ev3 = ExecutionPlan(strategy_model(pyemma_scheduler, steps))
    project.add_event(ev3)

    print

    CURSOR_UP_ONE = '\x1b[1A'
    ERASE_LINE = '\x1b[2K'

    # try:
    #     while project._events:
    #         sys.stdout.write('# of trajectories : %8d / # of models : %8d \n' % (
    #             len(project.trajectories),
    #             len(project.models)
    #         ))
    #         sys.stdout.flush()
    #         time.sleep(1.0)
    #         sys.stdout.write(CURSOR_UP_ONE + ERASE_LINE)