Kei18 / py-lacam

Minimal Python implementation of LaCAM* for MAPF
https://kei18.github.io/lacam/
MIT License
13 stars 3 forks source link

There is no checking for collisions between agents, that were already preassigned to specific locations by `LowLevelNode` #6

Closed Arseni1919 closed 1 month ago

Arseni1919 commented 1 month ago

Inside the following function (and in any other place in the algorithm), there is no checking for collisions between agents, that were already preassigned to specific locations by the LowLevelNode's constraints.

def configuration_generaotr(
        self, N: HighLevelNode, C: LowLevelNode
    ) -> Config | None:
        # setup next configuration
        Q_to = Config([self.pibt.NIL_COORD for _ in range(self.num_agents)])
        for k in range(C.depth):
            Q_to[C.who[k]] = C.where[k]

        # apply PIBT
        success = self.pibt.step(N.Q, Q_to, N.order)
        return Q_to if success else None

Something like the following code may assist to check the constraints:

# prep conf check
for agent1, agent2 in combinations(N.order, 2):
    node_from_1 = config_from[agent1.name]
    node_from_2 = config_from[agent2.name]
    if node_from_1 == node_from_2:
        return None
    if agent1.name in config_to and agent2.name in config_to:
        node_to_1 = config_to[agent1.name]
        node_to_2 = config_to[agent2.name]
        if node_to_1 == node_to_2:
            return None
        edge1 = (node_from_1.x, node_from_1.y, node_to_1.x, node_to_1.y)
        edge2 = (node_to_2.x, node_to_2.y, node_from_2.x, node_from_2.y)
        if edge1 == edge2:
            return None

Am I missing something?..

Thank you in advance

Kei18 commented 1 month ago

In this implementation, infeasible assignment is confirmed in PIBT. Please check: https://github.com/Kei18/py-lacam/blob/pibt/pycam/pibt.py#L75-L88

Arseni1919 commented 1 month ago

Got it! Thanks