Ejemplo n.º 1
0
    def test_bad_count_parameters(self, count_job, count_machine):
        msg = 'count_job and count_machine must be integers > 0'

        with pytest.raises(ValueError, match=msg):
            create_schedule(self.frame1,
                            self.frame1_solution1,
                            count_job=count_job,
                            count_machine=count_machine)
Ejemplo n.º 2
0
    def test_create_schedule(self):
        sch = create_schedule(self.frame1, self.frame1_solution1)
        assert sch.end_time() == self.end_time_f1_s1
        assert str(sch) == self.str_f1_s1

        sch2 = create_schedule(self.frame1, self.frame1_solution2)
        assert sch2.end_time() == self.end_time_f1_s2
        assert str(sch2) == self.str_f1_s2
Ejemplo n.º 3
0
def _weighted_idle_time(frame: JobSchedulingFrame, scheduled_jobs: list,
                        next_job: int) -> float:
    # TODO make sure that `jobs` does not change
    # during the operation of the function
    scheduled_jobs.append(next_job)
    sch = create_schedule(frame, scheduled_jobs)
    idle_time = 0.

    if len(scheduled_jobs) != 1:
        idx_second_last_job = scheduled_jobs[-2]
        idx_last_job = scheduled_jobs[-1]
        for idx_machine in range(1, frame.count_machines):
            cmpl_time1 = sch.end_time(idx_last_job, idx_machine - 1)
            cmpl_time2 = sch.end_time(idx_second_last_job, idx_machine)
            numerator = frame.count_machines * max(cmpl_time1 - cmpl_time2, 0)
            denominator = idx_machine + (len(scheduled_jobs) - 1) * \
                (frame.count_machines - idx_machine) / (frame.count_jobs - 2)
            idle_time += numerator / denominator
    else:
        idx_last_job = scheduled_jobs[-1]
        for idx_machine in range(1, frame.count_machines):
            cmpl_time1 = sch.end_time(idx_last_job, idx_machine - 1)
            numerator = frame.count_machines * cmpl_time1
            denominator = idx_machine + (len(scheduled_jobs) - 1) * \
                (frame.count_machines - idx_machine) / (frame.count_jobs - 2)
            idle_time += numerator / denominator

    scheduled_jobs.pop()  # remove this; see TODO
    return idle_time
Ejemplo n.º 4
0
    def test_create_schedule_with_count_machine(self):
        sch = create_schedule(self.frame1,
                              self.frame1_solution1,
                              count_machine=self.frame1.count_machines)
        assert sch.end_time() == self.end_time_f1_s1
        assert self.str_f1_s1.startswith(str(sch))

        sch2_end_time = compute_end_time(self.frame1,
                                         self.frame1_solution1,
                                         count_machine=1)
        assert sch2_end_time == 82
Ejemplo n.º 5
0
 def test_create_schedule_with_count_job(self, count_job, end_time):
     sch = create_schedule(self.frame1, self.frame1_solution1, count_job)
     assert sch.end_time() == end_time
     assert self.str_f1_s1.startswith(str(sch))