Example #1
0
    def get_time_distribution(self, run_info):
        travel_time = 0
        work_time = 0
        idle_time = 0
        # Robot tasks include completed tasks (have execution information) only
        tasks_performance = list()
        for task_id in self.robot_tasks:
            performance = FleetPerformanceMetrics.get_task_performance(
                run_info, from_str(task_id))
            tasks_performance.append(performance)

        # Order from earliest to latest
        tasks_performance = sorted(tasks_performance,
                                   key=lambda p: p.execution.start_time)

        for i, performance in enumerate(tasks_performance):
            travel_time += (performance.execution.pickup_time -
                            performance.execution.start_time).total_seconds()
            work_time += (performance.execution.delivery_time -
                          performance.execution.pickup_time).total_seconds()

            if i > 0:
                previous_performance = tasks_performance[i - 1]
                idle_time += (performance.execution.start_time -
                              previous_performance.execution.delivery_time
                              ).total_seconds()

        start_time = tasks_performance[0].execution.start_time
        finish_time = tasks_performance[-1].execution.delivery_time
        total_time = (finish_time - start_time).total_seconds()

        return TimeDistribution(total_time, travel_time, work_time, idle_time)
Example #2
0
 def _get_value(cls, key, value):
     if key in ['task_id', 'round_id', 'action_id']:
         return from_str(value)
     elif key in ['ztp', 'earliest_admissible_time', 'earliest_start_time']:
         return TimeStamp.from_str(value)
     else:
         return value
Example #3
0
    def from_payload(cls, bid_dict):
        robot_id = bid_dict['robotId']
        round_id = from_str(bid_dict['roundId'])
        task_id = from_str(bid_dict['taskId'])
        position = bid_dict['position']
        risk_metric = bid_dict['riskMetric']
        temporal_metric = bid_dict['temporalMetric']
        hard_constraints = bid_dict['hardConstraints']
        alternative_start_time = bid_dict['alternativeStartTime']

        bid = cls(robot_id, round_id, task_id,
                  position=position,
                  risk_metric=risk_metric,
                  temporal_metric=temporal_metric,
                  hard_constraints=hard_constraints,
                  alternative_start_time=alternative_start_time)
        return bid
Example #4
0
    def from_payload(payload):
        round_id = from_str(payload['roundId'])
        zero_timepoint = TimeStamp.from_str(payload['zeroTimepoint'])

        tasks_dict = payload['tasksLots']
        tasks_lots = list()

        for task_id, task_dict in tasks_dict.items():
            Task.create_new(task_id=task_id)
            tasks_lots.append(TaskLot.from_payload(task_dict))

        task_announcement = TaskAnnouncement(tasks_lots, round_id,
                                             zero_timepoint)

        return task_announcement
Example #5
0
    def from_payload(payload):
        allocation = Allocation
        allocation.task_id = from_str(payload['taskId'])
        allocation.robot_id = payload['robotId']

        return allocation