Example #1
0
def twooption_get_new_state(batt_funs, battery_capacity, max_batt, max_t,
                            old_state, action):
    """batt_funs is a dictionary of battery functions"""
    action_num, action_val = action
    action_key = 'S' + str(action_num)
    #print('getting reward,{}:{}'.format(state, reward))
    full_actions = {
        k: multi_sensor_env.what_is_noop(old_state[k])
        for k in old_state if k != action_key
    }
    full_actions[action_key] = action_val

    new_statuses = {
        k: twooption_status_dynamics(v[0], v[1], full_actions[k])
        for k, v in old_state.items()
    }
    new_batteries = {
        k: batt_funs[k](battery_capacity, max_batt, max_t, v[0], v[1])
        for k, v in old_state.items()
    }
    diffs = {
        k: batt_diff(v, old_state[k][1])
        for k, v in new_batteries.items()
    }
    times = {k: new_time(max_t, v[3]) for k, v, in old_state.items()}
    new_state = multi_sensor_env.zip_4dicts(new_statuses, new_batteries, diffs,
                                            times)
    #new_state = multi_sensor_env.zip_3dicts(new_statuses, new_batteries, diffs)
    return new_state
def eno_get_new_state(batt_funs, battery_capacity, max_batt, max_t, old_state,
                      full_actions):
    """batt_funs is a dictionary of battery functions"""

    new_statuses = {
        k: eno_status_dynamics(v[0], v[1], full_actions[k])
        for k, v in old_state.items()
    }
    new_batteries = {
        k: batt_funs[k](battery_capacity, max_batt, max_t, v[0], v[1])
        for k, v in old_state.items()
    }
    diffs = {
        k: batt_diff(v, old_state[k][1])
        for k, v in new_batteries.items()
    }
    times = {k: new_time(max_t, v[3]) for k, v, in old_state.items()}
    new_state = multi_sensor_env.zip_4dicts(new_statuses, new_batteries, diffs,
                                            times)
    #new_state = multi_sensor_env.zip_3dicts(new_statuses, new_batteries, diffs)
    return new_state