예제 #1
0
 def test_create_indicator(self) -> None:
     pb = ps.SchedulingProblem("CreateIndicator", horizon=3)
     i_1 = ps.Indicator("SquareHorizon", pb.horizon**2)  # ArithRef
     self.assertIsInstance(i_1, ps.Indicator)
     i_2 = ps.Indicator("IsLooooong ?", pb.horizon > 1000)  # BoolRef
     self.assertIsInstance(i_2, ps.Indicator)
     with self.assertRaises(TypeError):
         ps.Indicator("foo", 4)
예제 #2
0
    def test_indicator_flowtime(self) -> None:
        problem = ps.SchedulingProblem("IndicatorFlowTime", horizon=2)
        t_1 = ps.FixedDurationTask("t1", 2)
        t_2 = ps.FixedDurationTask("t2", 2)

        i_1 = ps.Indicator("FlowTime", t_1.end + t_2.end)

        solution = ps.SchedulingSolver(problem).solve()

        self.assertTrue(solution)
        self.assertEqual(solution.indicators[i_1.name], 4)
예제 #3
0
    def test_incremental_optimizer_1(self) -> None:
        problem = ps.SchedulingProblem("IncrementalOptimizer1", horizon=100)
        task_1 = ps.FixedDurationTask("task1", duration=2)

        task_1_start_ind = ps.Indicator("Task1Start", task_1.start)
        problem.maximize_indicator(task_1_start_ind)

        solver = ps.SchedulingSolver(problem)
        solution = solver.solve()

        self.assertTrue(solution)
        self.assertEqual(solution.indicators[task_1_start_ind.name], 98)
예제 #4
0
    def test_multi_two_tasks_1(self) -> None:
        pb = ps.SchedulingProblem("MultiObjective1", horizon=20)
        task_1 = ps.FixedDurationTask("task1", duration=3)
        task_2 = ps.FixedDurationTask("task2", duration=3)

        pb.add_constraint(task_1.end == 20 - task_2.start)

        # Maximize only task_1 end
        ind = ps.Indicator("Task1End", task_1.end)
        pb.maximize_indicator(ind)

        solution = ps.SchedulingSolver(pb).solve()

        self.assertTrue(solution)
        self.assertEqual(solution.tasks[task_1.name].end, 20)
        self.assertEqual(solution.tasks[task_2.name].start, 0)