stp.role.assignment.naive

Module that contains NaiveRoleAssignment.

Module Contents

Classes

NaiveRoleAssignment

Naive implementation of role assignment that simply performs the Hungarian

Attributes

SortedRequests

INVALID_COST

stp.role.assignment.naive.SortedRequests
stp.role.assignment.naive.INVALID_COST
class stp.role.assignment.naive.NaiveRoleAssignment

Bases: stp.role.assignment.IRoleAssignment

Naive implementation of role assignment that simply performs the Hungarian Algorithm (from scipy.optimize) on HIGH, then MEDIUM, then LOW priority in that order.

static get_sorted_requests(requests: stp.role.assignment.FlatRoleRequests) SortedRequests

Returns a list of FlatRoleRequests sorted in ascending priority order. :param requests: Flat list of requests. :return: List of FlatRoleRequests in sorted ascending priority order, ie. [LOW, MEDIUM, HIGH].

static compute_costs_matrix(free_robots: numpy.ndarray, flat_requests: stp.role.assignment.FlatRoleRequests, world_state: stp.rc.WorldState, prev_results: stp.role.assignment.FlatRoleResults) numpy.ndarray

Computes the n_free_robots x n_requests cost matrix corresponding to the passed in free robots and role requests. :param flat_requests: Role requests to compute cost matrix for. :param free_robots: Free robots to compute cost matrix for. :param world_state: Current world state. :param prev_results: The previous results. :return: The m x n cost matrix corresponding to the passed in free robots and role requests.

static assign_prioritized_roles(flat_requests: stp.role.assignment.FlatRoleRequests, world_state: stp.rc.WorldState, free_robots: numpy.ndarray, prev_results: stp.role.assignment.FlatRoleResults) Tuple[stp.role.assignment.FlatRoleResults, numpy.ndarray]

Assigns roles using the Hungarian algorithm. :param flat_requests: The role requests. :param world_state: The current state of the game. :param free_robots: The array of free robots that haven’t been assigned yet. This list will be mutated. Array of stp.rc.Robot. :param prev_results: The previous results. :return: The results of the role assignment and the new free_robots after assignment.

assign_roles(self, flat_requests: stp.role.assignment.FlatRoleRequests, world_state: stp.rc.WorldState, prev_results: stp.role.assignment.FlatRoleResults) stp.role.assignment.FlatRoleResults

Assigns roles. :param flat_requests: The role requests. :param world_state: The current state of the game. :param prev_results: The previous results. :return: The results of the role assignment.