pub struct ConstraintSet { /* private fields */ }Expand description
The constraints of one agent, indexed for the checks of a space-time search.
Implementations§
Source§impl ConstraintSet
impl ConstraintSet
Sourcepub fn for_agent(agent: AgentId, constraints: &[Constraint]) -> Self
pub fn for_agent(agent: AgentId, constraints: &[Constraint]) -> Self
The set of what constraints mean for agent: those that name it, and the
negative constraints implied by the positive ones on other agents
(Constraint::implied_for).
§Examples
use mapf_search::{Constraint, ConstraintSet};
// Agent 0 must be at vertex 4 at time 2, so agent 1 must not.
let positive = Constraint::PositiveVertex { agent: 0, vertex: 4, time: 2 };
let first = ConstraintSet::for_agent(0, &[positive]);
let second = ConstraintSet::for_agent(1, &[positive]);
assert!(!first.allows_vertex(3, 2));
assert!(first.allows_vertex(4, 2));
assert!(!second.allows_vertex(4, 2));
assert!(second.allows_vertex(3, 2));Sourcepub fn insert(&mut self, constraint: &Constraint)
pub fn insert(&mut self, constraint: &Constraint)
Adds constraint, ignoring which agent it names.
Sourcepub fn block_from(&mut self, vertex: Vertex, time: Time)
pub fn block_from(&mut self, vertex: Vertex, time: Time)
Forbids vertex at time and at every later time, as for a vertex where another
agent stays for good after arriving at time.
§Examples
use mapf_search::ConstraintSet;
let mut constraints = ConstraintSet::new();
constraints.block_from(4, 2);
assert!(constraints.allows_vertex(4, 1));
assert!(!constraints.allows_vertex(4, 9));
assert_eq!(constraints.blocked_until(4), Some(u32::MAX));Sourcepub fn allows(&self, from: Vertex, to: Vertex, time: Time) -> bool
pub fn allows(&self, from: Vertex, to: Vertex, time: Time) -> bool
Returns true if the agent may move (or wait, when from == to) from from at
time to to at time + 1.
Sourcepub fn allows_vertex(&self, vertex: Vertex, time: Time) -> bool
pub fn allows_vertex(&self, vertex: Vertex, time: Time) -> bool
Returns true if the agent may occupy vertex at time.
Sourcepub fn latest_step(&self) -> Time
pub fn latest_step(&self) -> Time
The latest time step any constraint touches; 0 while empty.
After this step the constraints no longer change: the agent is free except for the
vertices blocked forever (ConstraintSet::block_from).
Sourcepub fn blocked_until(&self, vertex: Vertex) -> Option<Time>
pub fn blocked_until(&self, vertex: Vertex) -> Option<Time>
The latest time vertex is forbidden, if ever: by a negative constraint, or by a
positive one that requires another vertex then.
For the goal vertex, an agent must not finish at or before this time: goal-stay
semantics would put it there. Time::MAX if the vertex is blocked forever
(ConstraintSet::block_from).