test_naive_assignment
Module Contents
Classes
Protocol for CostFn. |
|
Protocol for CostFn. |
|
Protocol for CostFn. |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Functions
|
Creates and returns a list of role ids with skills SkillA, SkillB and SkillC for |
Manually create a Requests and check that get_sorted_requests returns a list of |
|
|
Creates a simple tactic context for convenience. |
|
Tests get_sorted_requests with a more complicated example. |
|
Tests the compute_costs_matrix function. |
|
Tests that for the role requests and free robots above that role assignment |
|
Tests that NaiveRoleAssignment.assign_roles assigns HIGH, then MEDIUM, then LOW |
|
Tests that NaiveRoleAssignment.assign_roles respects constraints, ie. even though |
|
|
|
- class test_naive_assignment.AssignCostFn
Bases:
stp.role.CostFn
Protocol for CostFn.
- __call__(self, robot: stp.rc.Robot, prev_result: Optional[stp.role.RoleResult], world_state: stp.rc.WorldState) float
Given a robot and the current world state, returns the cost of assigning that robot to a given role. :param robot: The current robot to check costs for. :param world_state: The current world state. :return:
- unassigned_cost_fn(self, prev_result: Optional[stp.role.RoleResult], world_state: stp.rc.WorldState) float
Given the previous role assigment and current world state, returns the cost of not assigning any robot. :param prev_result: The previous role assignment result. :param world_state: The current world state. :return: cost of not assigning
- class test_naive_assignment.UnassignCostFn
Bases:
stp.role.CostFn
Protocol for CostFn.
- __call__(self, robot: stp.rc.Robot, prev_result: Optional[stp.role.RoleResult], world_state: stp.rc.WorldState) float
Given a robot and the current world state, returns the cost of assigning that robot to a given role. :param robot: The current robot to check costs for. :param world_state: The current world state. :return:
- unassigned_cost_fn(self, prev_result: Optional[stp.role.RoleResult], world_state: stp.rc.WorldState) float
Given the previous role assigment and current world state, returns the cost of not assigning any robot. :param prev_result: The previous role assignment result. :param world_state: The current world state. :return: cost of not assigning
- class test_naive_assignment.TestCostFn(fn: Callable[[stp.rc.Robot, Optional[stp.role.RoleResult], stp.rc.WorldState], float])
Bases:
stp.role.CostFn
Protocol for CostFn.
- __call__(self, robot: stp.rc.Robot, prev_result: Optional[stp.role.RoleResult], world_state: stp.rc.WorldState) float
Given a robot and the current world state, returns the cost of assigning that robot to a given role. :param robot: The current robot to check costs for. :param world_state: The current world state. :return:
- unassigned_cost_fn(self, prev_result: Optional[stp.role.RoleResult], world_state: stp.rc.WorldState) float
Given the previous role assigment and current world state, returns the cost of not assigning any robot. :param prev_result: The previous role assignment result. :param world_state: The current world state. :return: cost of not assigning
- class test_naive_assignment.SkillBase
Bases:
stp.skill.ISkill
Helper class that provides a standard way to create an ABC using inheritance.
- define(self)
- tick(self)
- create_request(self) stp.role.RoleRequest
- __repr__(self) str
Return repr(self).
- class test_naive_assignment.SkillA
Bases:
SkillBase
Helper class that provides a standard way to create an ABC using inheritance.
- class test_naive_assignment.SkillB
Bases:
SkillBase
Helper class that provides a standard way to create an ABC using inheritance.
- class test_naive_assignment.SkillC
Bases:
SkillBase
Helper class that provides a standard way to create an ABC using inheritance.
- class test_naive_assignment.BallSkill
Bases:
SkillBase
Helper class that provides a standard way to create an ABC using inheritance.
- class test_naive_assignment.Skills
Bases:
stp.tactic.SkillsEnum
- A1
- A2
- B1
- B2
- C1
- C2
- BALL_SKILL
- class test_naive_assignment.TacticBase(ctx: stp.tactic.Ctx)
Bases:
stp.tactic.ITactic
[None
]- compute_props(self, prev_props: None) None
- tick(self, role_results: stp.tactic.RoleResults, props: None) List[stp.action.IAction]
- get_requests(self, world_state: stp.rc.WorldState, props: None) stp.tactic.RoleRequests
- create_request(self)
- test_naive_assignment.get_simple_role_ids() List[stp.role.assignment.RoleId]
Creates and returns a list of role ids with skills SkillA, SkillB and SkillC for TacticBase. :return: List of role ids with skills SkillA, SkillB and SkillC for TacticBase.
- test_naive_assignment.test_get_sorted_requests_simple()
Manually create a Requests and check that get_sorted_requests returns a list of three dictionaries, one for each priority level.
- test_naive_assignment.get_tactic_ctx() stp.tactic.Ctx
Creates a simple tactic context for convenience. :return: Tactic context containing SkillA, SkillB and SkillC.
- test_naive_assignment.test_get_sorted_requests_multiple() None
Tests get_sorted_requests with a more complicated example.
- test_naive_assignment.test_compute_costs_matrix() None
Tests the compute_costs_matrix function.
- Costs:
A: Dist to (0, 0) B: Dist to (1, 1) C: Dist to (2, 2)
- test_naive_assignment.test_assign_prioritized_roles() None
Tests that for the role requests and free robots above that role assignment returns the expected result.
- test_naive_assignment.test_assign_roles() None
Tests that NaiveRoleAssignment.assign_roles assigns HIGH, then MEDIUM, then LOW priority. This is tested by having a MEDIUM priority role request that has a lower cost than a HIGH priority role request, and expecting that the HIGH role request is fulfilled first.
- test_naive_assignment.test_assign_roles_constrained() None
Tests that NaiveRoleAssignment.assign_roles respects constraints, ie. even though role_id_a and role_id_ball both are HIGH priority, the robot at (0, 0) has the ball and thus is assigned BALL_SKILL.
This test will fail as has_ball has been removed from Robot thus breaking the ball constraint
- test_naive_assignment.test_unassigned_role() None
- test_naive_assignment.test_unassigned_roles() None