コード例 #1
0
    def get_single_resource_utilization_problem(self, problem_name):
        problem = ps.SchedulingProblem("IndicatorFlowtimeSingleResource1", horizon=50)

        dur1 = 5
        dur2 = 5
        dur3 = 4
        dur4 = 3
        dur5 = 2

        t_1 = ps.FixedDurationTask("T1", duration=dur1)
        t_2 = ps.FixedDurationTask("T2", duration=dur2)
        t_3 = ps.FixedDurationTask("T3", duration=dur3)
        t_4 = ps.FixedDurationTask("T4", duration=dur4)
        t_5 = ps.FixedDurationTask("T5", duration=dur5)
        worker_1 = ps.Worker("Worker1")

        t_1.add_required_resource(worker_1)
        t_2.add_required_resource(worker_1)
        t_3.add_required_resource(worker_1)
        t_4.add_required_resource(worker_1)
        t_5.add_required_resource(worker_1)

        ps.TaskEndBeforeLax(t_3, 35)
        ps.TaskEndBeforeLax(t_2, 35)
        ps.TaskEndBeforeLax(t_1, 35)
        ps.TaskEndBeforeLax(t_4, 35)
        ps.TaskEndBeforeLax(t_5, 35)

        ps.TaskStartAfterLax(t_3, 10)
        ps.TaskStartAfterLax(t_2, 10)
        ps.TaskStartAfterLax(t_1, 10)
        ps.TaskStartAfterLax(t_4, 10)
        ps.TaskStartAfterLax(t_5, 10)

        return problem, worker_1, dur1 + dur2 + dur3 + dur4 + dur5
コード例 #2
0
 def test_operator_and_(self) -> None:
     new_problem_or_clear()
     t_1 = ps.FixedDurationTask("t1", duration=2)
     and_constraint = ps.and_(
         [ps.TaskStartAfterLax(t_1, 1), ps.TaskEndBeforeLax(t_1, 7)]
     )
     self.assertIsInstance(and_constraint, ps.BoolRef)
コード例 #3
0
    def test_resource_tasks_distance_double_time_period_2(self) -> None:
        """Same as above, but force the tasks to be scheduled within the time intervals"""
        pb = ps.SchedulingProblem("ResourceTasksDistanceMultiTimePeriod2")
        tasks = [
            ps.FixedDurationTask("task%i" % i, duration=1) for i in range(4)
        ]

        worker_1 = ps.Worker("Worker1")
        for t in tasks:
            t.add_required_resource(worker_1)

        c1 = ps.ResourceTasksDistance(worker_1,
                                      distance=4,
                                      mode="exact",
                                      time_periods=[[10, 20], [30, 40]])
        pb.add_constraint(c1)

        # add a makespan objective, all tasks should be scheduled from 0 to 4
        pb.add_constraint(ps.TaskStartAt(tasks[0], 10))
        pb.add_constraint(ps.TaskStartAfterLax(tasks[1], 10))
        pb.add_constraint(ps.TaskEndBeforeLax(tasks[1], 20))
        pb.add_constraint(ps.TaskStartAt(tasks[2], 30))
        pb.add_constraint(ps.TaskStartAfterLax(tasks[3], 30))
        pb.add_constraint(ps.TaskEndBeforeLax(tasks[3], 40))
        # as a consequence, task2 should be scheduled 4 periods after and start at 15
        solver = ps.SchedulingSolver(pb)

        solution = solver.solve()

        self.assertTrue(solution)
        self.assertEqual(solution.horizon, 36)
        t0_start = solution.tasks[tasks[0].name].start
        t1_start = solution.tasks[tasks[1].name].start
        t2_start = solution.tasks[tasks[2].name].start
        t3_start = solution.tasks[tasks[3].name].start
        t0_end = solution.tasks[tasks[0].name].end
        t1_end = solution.tasks[tasks[1].name].end
        t2_end = solution.tasks[tasks[2].name].end
        t3_end = solution.tasks[tasks[3].name].end
        self.assertEqual(t0_start, 10)
        self.assertEqual(t0_end, 11)
        self.assertEqual(t1_start, 15)
        self.assertEqual(t1_end, 16)
        self.assertEqual(t2_start, 30)
        self.assertEqual(t2_end, 31)
        self.assertEqual(t3_start, 35)
        self.assertEqual(t3_end, 36)
コード例 #4
0
ファイル: test_fol.py プロジェクト: tpaviot/ProcessScheduler
    def test_operator_and_1(self) -> None:
        pb = ps.SchedulingProblem("OperatorAnd1", horizon=23)
        t_1 = ps.FixedDurationTask("t1", duration=2)
        and_constraint = ps.and_(
            [ps.TaskStartAfterLax(t_1, 3),
             ps.TaskEndBeforeLax(t_1, 5)])
        self.assertIsInstance(and_constraint, ps.BoolRef)
        pb.add_constraint(and_constraint)
        solution = ps.SchedulingSolver(pb).solve()

        self.assertTrue(solution)
        self.assertEqual(solution.tasks["t1"].start, 3)
コード例 #5
0
    def get_single_resource_utilization_problem_2(time_intervals):
        horizon = time_intervals[-1][-1] + 3
        nb_tasks = [5 for interval in time_intervals if interval[1] - interval[0] > 3]
        problem = ps.SchedulingProblem(
            "IndicatorFlowtimeSingleResource", horizon=horizon
        )
        worker_1 = ps.Worker("Worker1")

        tasks: list[ps.FixedDurationTask] = []
        for interval, nb_tasks_i in zip(time_intervals, nb_tasks):
            for _ in range(nb_tasks_i):
                tasks.append(ps.FixedDurationTask("T%s" % len(tasks), duration=1))
                tasks[-1].add_required_resource(worker_1)
                ps.TaskStartAfterLax(tasks[-1], interval[0])
                ps.TaskEndBeforeLax(tasks[-1], interval[1])
        return problem, worker_1, len(tasks)
コード例 #6
0
    def test_optional_tasks_end_before_strict_end_before_lax(self) -> None:
        pb = ps.SchedulingProblem("OptionalTasksEndBefore", horizon=8)
        task_1 = ps.FixedDurationTask("task1", duration=3)  # mandatory
        task_2 = ps.FixedDurationTask("task2", duration=4,
                                      optional=True)  # optional

        # force task_2 to be scheduled
        pb.add_constraint(task_2.scheduled == True)

        pb.add_constraint(ps.TaskEndBeforeStrict(task_2, 7))
        pb.add_constraint(ps.TaskEndBeforeLax(task_2, 4))

        solver = ps.SchedulingSolver(pb)
        solution = solver.solve()
        self.assertTrue(solution)
        self.assertTrue(solution.tasks[task_1.name].scheduled)
        self.assertTrue(solution.tasks[task_2.name].scheduled)
        self.assertEqual(solution.tasks[task_2.name].start, 0)
        self.assertEqual(solution.tasks[task_2.name].end, 4)
コード例 #7
0
 def test_create_task_before_lax(self) -> None:
     new_problem_or_clear()
     task = ps.FixedDurationTask("task", 2)
     constraint = ps.TaskEndBeforeLax(task, 3)
     self.assertIsInstance(constraint, ps.TaskEndBeforeLax)
     self.assertEqual(constraint.value, 3)