Esempio n. 1
0
    def get_pickup_timepoint(self, task, travel_edge, insertion_point):
        r_earliest_pickup_time = relative_to_ztp(
            self.ztp, task.pickup_constraint.earliest_time)
        r_latest_pickup_time = relative_to_ztp(
            self.ztp, task.pickup_constraint.latest_time)

        if not task.hard_constraints and insertion_point > 1:
            pickup_time_window = task.pickup_constraint.latest_time - task.pickup_constraint.earliest_time
            r_earliest_delivery_time_previous_task = self.get_r_time_previous_task(
                insertion_point, "delivery")

            r_earliest_pickup_time = r_earliest_delivery_time_previous_task + travel_edge.mean
            r_latest_pickup_time = r_earliest_pickup_time + pickup_time_window.total_seconds(
            )

            earliest_pickup_time = to_timestamp(
                self.ztp, r_earliest_pickup_time).to_datetime()
            latest_pickup_time = to_timestamp(
                self.ztp, r_latest_pickup_time).to_datetime()

            task.update_pickup_constraint(earliest_pickup_time,
                                          latest_pickup_time)

        pickup_timepoint = Timepoint(name="pickup",
                                     r_earliest_time=r_earliest_pickup_time,
                                     r_latest_time=r_latest_pickup_time)
        return pickup_timepoint
Esempio n. 2
0
    def _update_timepoint(self, task, timetable, assigned_time, node_id):
        r_assigned_time = relative_to_ztp(timetable.ztp, assigned_time)
        timetable.check_is_task_delayed(task, r_assigned_time, node_id)
        try:
            self.performance_tracker.update_delay(task.task_id,
                                                  r_assigned_time, node_id,
                                                  timetable)
            self.performance_tracker.update_earliness(task.task_id,
                                                      r_assigned_time, node_id,
                                                      timetable)
        except AttributeError:
            pass
        timetable.update_timepoint(r_assigned_time, node_id)

        nodes = timetable.stn.get_nodes_by_task(task.task_id)
        self._update_edge(timetable, 'start', 'pickup', nodes)
        self._update_edge(timetable, 'pickup', 'delivery', nodes)
        try:
            self.performance_tracker.update_timetables(timetable)
        except AttributeError:
            pass
        self.auctioneer.changed_timetable.append(timetable.robot_id)

        self.logger.debug("Updated stn: \n %s ", timetable.stn)
        self.logger.debug("Updated dispatchable graph: \n %s",
                          timetable.dispatchable_graph)
        timetable.store()

        if self.d_graph_watchdog:
            next_task = timetable.get_next_task(task)
            self._re_compute_dispatchable_graph(timetable, next_task)
    def update_timetable(self, task, task_progress, timestamp):
        r_assigned_time = relative_to_ztp(self.timetable.ztp, timestamp)
        first_action_id = task.plan[0].actions[0].action_id

        if task_progress.action_id == first_action_id and \
                task_progress.action_status.status == ActionStatusConst.ONGOING:
            node_id, node = self.timetable.stn.get_node_by_type(task.task_id, 'start')
            self.update_timepoint(task, task_progress, r_assigned_time, node, node_id)
        else:
            # An action could be associated to two nodes, e.g., between pickup and delivery there is only one action
            nodes = self.timetable.stn.get_nodes_by_action(task_progress.action_id)

            for node_id, node in nodes:
                if (node.node_type == 'pickup' and
                    task_progress.action_status.status == ActionStatusConst.ONGOING) or\
                        (node.node_type == 'delivery' and
                         task_progress.action_status.status == ActionStatusConst.COMPLETED):

                    self.update_timepoint(task, task_progress, r_assigned_time, node, node_id)
Esempio n. 4
0
    def get_start_timepoint(self, pickup_timepoint, travel_edge,
                            insertion_point, earliest_admissible_time):
        start_timepoint = self.stn.get_prev_timepoint("start",
                                                      pickup_timepoint,
                                                      travel_edge)

        if insertion_point == 1:
            r_earliest_admissible_time = relative_to_ztp(
                self.ztp, earliest_admissible_time.to_datetime())
            start_timepoint.r_earliest_time = max(
                r_earliest_admissible_time, start_timepoint.r_earliest_time)

        if insertion_point > 1 and self.previous_task_is_frozen(
                insertion_point):
            r_latest_delivery_time_previous_task = self.get_r_time_previous_task(
                insertion_point, "delivery", earliest=False)
            start_timepoint.r_earliest_time = max(
                start_timepoint.r_earliest_time,
                r_latest_delivery_time_previous_task)
        return start_timepoint