MAPF-Competition / Start-Kit

MIT License
21 stars 11 forks source link

[Question] Task assignment validation and application #71

Open miquelramirez opened 6 days ago

miquelramirez commented 6 days ago

Dear MAPF-Competition team,

why is TaskManager::set_task_assignment applying the changes on the schedule tracked by the simulation before checking that the assignment is valid? That is, why we have

    for (int a = 0; a < assignment.size(); a++)
    {
        if (planner_schedule[a].empty() || assignment[a] != planner_schedule[a].back().second)
        {
            planner_schedule[a].push_back(make_pair(curr_timestep,assignment[a]));
        }
    }
    if (! validate_task_assgnment(assignment))
    {
        if (assignment.size() < num_of_agents)
            logger->log_info("task scheduler tiemout");
        else
            logger->log_warning("attempt to set invalid task assignment");
        return false;
    }

rather than

    if (! validate_task_assgnment(assignment))
    {
        if (assignment.size() < num_of_agents)
            logger->log_info("task scheduler tiemout");
        else
            logger->log_warning("attempt to set invalid task assignment");
        return false;
    }
    for (int a = 0; a < assignment.size(); a++)
    {
        if (planner_schedule[a].empty() || assignment[a] != planner_schedule[a].back().second)
        {
            planner_schedule[a].push_back(make_pair(curr_timestep,assignment[a]));
        }
    }

in lines 55-59 of TaskManager.cpp?

Thank you in advance,

Miquel.

YueZhang-studyuse commented 6 days ago

Hi Miquel,

The planner_schedule is for storing the proposed schedule returned from Entry regardless of whether the schedule is valid or not. However, we validate and accept the proposed schedule and store it in actual_schedule (see line 71-88). In other words, the planner_schedule acts as logging the Entry returns and uses it for output. Please let me know if you have further questions.

Best, Yue

miquelramirez commented 6 days ago

Thank you for the answer @YueZhang-studyuse. That leads me to the follow-up question: Why are schedules being double-buffered? The validity check is binary (either it is valid and the proposed schedule becomes the actual one, or it is not valid and nothing happens) so I am unsure of what is the reasoning here.

Best,

Miquel.

YueZhang-studyuse commented 6 days ago

We store the raw schedule for logging purposes. This might help for locating and understanding the reason about the errors in their task scheduler in the output JSON file, i.e., when and where the planner schedule does not match the actual schedule.

Best, Yue

miquelramirez commented 6 days ago

Hi @YueZhang-studyuse

I can see that errors in schedules are logged in the validate_task_assgnment routine. But those logs are only written if the lifelong program terminates execution normally. If some exception is raised (like the ones std::vector<T>::at does) or SIGABRT/SIGSEV happens, all that information is lost. Last night it became apparent to me that is actually very useful to understand what one has done wrong.