Median Graph Agent

or_suite.agents.ambulance.median_graph.find_lengths(graph, num_nodes)[source]

Given a graph, find_lengths first calculates the pairwise shortest distance between all the nodes, which is stored in a (symmetric) matrix.

class or_suite.agents.ambulance.median_graph.medianAgent(epLen, edges, num_ambulance)[source]

Agent that implements a median-like heuristic algorithm for the graph ambulance environment

reset()[source]

Clears data and call_locs which contain data on what has occurred so far in the environment

update_config()[source]

(UNIMPLEMENTED)

pick_action(state, step)[source]

Chooses locations for each of the ambulances that minimize the distance they would have travelled to respond to all calls that have occurred in the past

epLen

(int) number of time steps to run the experiment for

data

(int list list) a list of all the states of the environment observed so far

graph

(networkx Graph) a graph representing the observation space

num_nodes

(int) the number of nodes in the graph

num_ambulance

(int) the number of ambulances in the environment

lengths

(float matrix) symmetric matrix containing the distance between each pair of nodes

call_locs

(int list) the node locations of all calls observed so far

__init__(epLen, edges, num_ambulance)[source]
Parameters
  • epLen – (int) number of time steps to run the experiment for

  • edges – (tuple list) a list of tuples, each tuple corresponds to an edge in the graph. The tuples are of the form (int1, int2, {‘travel_time’: int3}). int1 and int2 are the two endpoints of the edge, and int3 is the time it takes to travel from one endpoint to the other

  • num_ambulance – (int) the number of ambulances in the environment

greedy(state, timestep, epsilon=0)[source]

Chooses locations for each of the ambulances that minimize the distance they would have travelled to respond to all calls that have occurred in the past

update_obs(obs, action, reward, newObs, timestep, info)[source]

Adds newObs, the most recently observed state, to data adds the most recent call arrival, found in info[‘arrival’] to call_locs

update_policy(k)[source]

Update internal policy based upon records.

Not used, because a greedy algorithm does not have a policy.