Пример #1
0
    def test_constant_cost_per_period_2(self) -> None:
        problem = ps.SchedulingProblem(
            "IndicatorResourceConstantCostPerPeriod12")
        t_1 = ps.VariableDurationTask("t1", work_amount=100)
        worker_1 = ps.Worker("Worker1",
                             productivity=4,
                             cost=ps.ConstantCostPerPeriod(10))
        worker_2 = ps.Worker("Worker2",
                             productivity=7,
                             cost=ps.ConstantCostPerPeriod(20))
        all_workers = [worker_1, worker_2]
        problem.add_objective_makespan()
        t_1.add_required_resources(all_workers)
        cost_ind = problem.add_indicator_resource_cost(all_workers)

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

        self.assertTrue(solution)
        self.assertEqual(solution.indicators[cost_ind.name], 300)
Пример #2
0
    def test_constant_cost_per_period_1(self) -> None:
        problem = ps.SchedulingProblem(
            "IndicatorResourceConstantCostPerPeriod1")
        t_1 = ps.FixedDurationTask("t1", duration=11)
        worker_1 = ps.Worker("Worker1", cost=ps.ConstantCostPerPeriod(7))
        t_1.add_required_resource(worker_1)
        cost_ind = problem.add_indicator_resource_cost([worker_1])

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

        self.assertTrue(solution)
        self.assertEqual(solution.indicators[cost_ind.name], 77)
Пример #3
0
    def test_cumulative_cost(self):
        problem = ps.SchedulingProblem("CumulativeCost", horizon=5)
        t_1 = ps.FixedDurationTask("t1", duration=5)
        t_2 = ps.FixedDurationTask("t2", duration=5)
        t_3 = ps.FixedDurationTask("t3", duration=5)
        worker_1 = ps.CumulativeWorker("CumulWorker",
                                       size=3,
                                       cost=ps.ConstantCostPerPeriod(5))
        t_1.add_required_resource(worker_1)
        t_2.add_required_resource(worker_1)
        t_3.add_required_resource(worker_1)

        cost_ind = problem.add_indicator_resource_cost([worker_1])

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

        self.assertTrue(solution)
        self.assertEqual(solution.indicators[cost_ind.name], 25)
        solution = ps.SchedulingSolver(problem).solve()
        self.assertTrue(solution)
Пример #4
0
 def test_cost_assertion_fail(self) -> None:
     with self.assertRaises(ValueError):
         ps.ConstantCostPerPeriod(-4)
Пример #5
0
 def test_cost_basic(self) -> None:
     ps.SchedulingProblem("CostBasic", horizon=12)
     ress_cost = ps.ConstantCostPerPeriod(5)
     ps.Worker("Worker1", cost=ress_cost)