Exemple #1
0
    def check_termination_test(self):
        unallocated_tasks = Task.get_tasks_by_status(
            TaskStatusConst.UNALLOCATED)
        allocated_tasks = Task.get_tasks_by_status(TaskStatusConst.ALLOCATED)
        preempted_tasks = Task.get_tasks_by_status(TaskStatusConst.PREEMPTED)
        planned_tasks = Task.get_tasks_by_status(TaskStatusConst.PLANNED)
        dispatched_tasks = Task.get_tasks_by_status(TaskStatusConst.DISPATCHED)
        ongoing_tasks = Task.get_tasks_by_status(TaskStatusConst.ONGOING)

        with switch_collection(TaskStatus, TaskStatus.Meta.archive_collection):
            completed_tasks = Task.get_tasks_by_status(
                TaskStatusConst.COMPLETED)
            canceled_tasks = Task.get_tasks_by_status(TaskStatusConst.CANCELED)
            aborted_tasks = Task.get_tasks_by_status(TaskStatusConst.ABORTED)

        self.logger.info("Unallocated: %s", len(unallocated_tasks))
        self.logger.info("Allocated: %s", len(allocated_tasks))
        self.logger.info("Planned: %s ", len(planned_tasks))
        self.logger.info("Dispatched: %s", len(dispatched_tasks))
        self.logger.info("Ongoing: %s", len(ongoing_tasks))
        self.logger.info("Completed: %s ", len(completed_tasks))
        self.logger.info("Preempted: %s ", len(preempted_tasks))
        self.logger.info("Canceled: %s", len(canceled_tasks))
        self.logger.info("Aborted: %s", len(aborted_tasks))

        tasks = completed_tasks + preempted_tasks

        if len(tasks) == len(self.tasks):
            self.logger.info("Terminating test")
            self.logger.info("Allocations: %s", self.allocations)
            self.terminated = True
Exemple #2
0
    def start_test_cb(self, msg):
        self.simulator_interface.stop()
        initial_time = msg["payload"]["initial_time"]
        self.logger.info("Start test at %s", initial_time)

        tasks = Task.get_tasks_by_status(TaskStatusConst.UNALLOCATED)
        for robot_id in self.auctioneer.robot_ids:
            RobotPerformance.create_new(robot_id=robot_id)
        for task in tasks:
            self.add_task_plan(task)
            TaskPerformance.create_new(task_id=task.task_id)

        self.simulator_interface.start(initial_time)

        self.auctioneer.allocate(tasks)
Exemple #3
0
    def merge_temporal_graph(previous_graph, new_graph):
        tasks = list()
        new_task_ids = new_graph.get_tasks()

        scheduled_tasks = [
            task.task_id
            for task in Task.get_tasks_by_status(TaskStatusConst.SCHEDULED)
            if task
        ]
        ongoing_tasks = [
            task.task_id
            for task in Task.get_tasks_by_status(TaskStatusConst.ONGOING)
            if task
        ]

        for i, task_id in enumerate(new_task_ids):
            if task_id in scheduled_tasks or task_id in ongoing_tasks:
                # Keep current version of task
                tasks.append(previous_graph.get_task_graph(task_id))
            else:
                # Use new version of task
                tasks.append(new_graph.get_task_graph(task_id))

        # Get type of previous graph
        merged_graph = previous_graph.__class__()

        for task_graph in tasks:
            merged_graph.add_nodes_from(task_graph.nodes(data=True))
            merged_graph.add_edges_from(task_graph.edges(data=True))

        for i in merged_graph.nodes():
            if i != 0 and merged_graph.has_node(
                    i + 1) and not merged_graph.has_edge(i, i + 1):
                merged_graph.add_constraint(i, i + 1)

        return merged_graph