Exemplo n.º 1
0
def unify_obs(observation):
    '''
    TODO: accumulate and apply them all at once
    '''
    action = copy.deepcopy(observation.action)
    action.update_start_time(observation.start_time)
    action.update_end_time(observation.end_time)

    # Constraint check
    action_cons, return_state = constraints_satisfied(action,
                                                      Plan(),
                                                      Proposed(),
                                                      is_observation=True)

    if not action_cons:
        return_state.update_subs({
            var('T1'): observation.start_time,
            var('T2'): observation.end_time,
        })
        process_return_state(observation, return_state)
        return

    KB.log_action_new(action, from_obs=True)
    KB.add_cycle_obs(observation)

    initiates, terminates = process_causalities(action)

    return initiates, terminates
Exemplo n.º 2
0
def process_cycle(cycle_events):
    '''
    TODO - Delay all commitment into KB until all are processed
    '''

    for event in cycle_events:

        # Convert args for action
        converted_args = convert_args_to_python(event)

        # Add into observations
        KB.add_cycle_obs(Observation(event, event.start_time, event.end_time))

        # Log action
        KB.log_action_new(event, converted_args=converted_args)

        initiates, terminates = process_causalities(event)
        commit_outcomes(initiates, terminates)