Ejemplo n.º 1
0
def test_prioritize_cost_per_duration() -> None:
    projects = ["A", "B", "C", "D"]
    value = [100.0, 20.0, 100.0, 10.0]
    cost = [10.0, 10.0, 10.0, 10.0]
    duration = [10.0, 10.0, 50.0, 10.0]
    multiplied_cost = [100.0, 100.0, 500.0, 100.0]
    unit_duration = [1.0, 1.0, 1.0, 1.0]
    risk = [3.0, 3.0, 3.0, 3.0]
    pick = [False, False, False, False]
    alternatives: list[tuple[str, ...]] = [(), (), (), ()]
    max_cost = 200.0
    assert (prioritize(
        projects,
        value,
        cost,
        duration,
        risk,
        pick,
        alternatives,
        max_cost,
        cost_per_duration=True,
    ) == prioritize(
        projects,
        value,
        multiplied_cost,
        unit_duration,
        risk,
        pick,
        alternatives,
        max_cost,
        cost_per_duration=False,
    ) == ["A", "B"])
Ejemplo n.º 2
0
def test_prioritize_picks_over_budget() -> None:
    projects = ["A", "B", "C", "D"]
    value = [10.0, 10.0, 20.0, 10.0]
    cost = [10.0, 10.0, 10.0, 10.0]
    duration = [10.0, 10.0, 10.0, 10.0]
    risk = [3.0, 3.0, 3.0, 3.0]
    pick = [False, True, False, True]
    alternatives: list[tuple[str, ...]] = [(), (), (), ()]
    max_cost = 19.0
    with pytest.raises(ValueError):
        prioritize(
            projects,
            value,
            cost,
            duration,
            risk,
            pick,
            alternatives,
            max_cost,
            cost_per_duration=False,
        )
Ejemplo n.º 3
0
def test_prioritize_with_alternatives() -> None:
    projects = ["A", "B", "C", "D"]
    value = [10.0, 30.0, 11.0, 20.0]
    cost = [10.0, 10.0, 10.0, 10.0]
    duration = [10.0, 10.0, 10.0, 10.0]
    risk = [3.0, 3.0, 3.0, 3.0]
    pick = [False, False, False, False]
    alternatives: list[tuple[str, ...]] = [(), ("D", ), (), ("B", )]
    max_cost = 20.0
    assert (prioritize(
        projects,
        value,
        cost,
        duration,
        risk,
        pick,
        alternatives,
        max_cost,
        cost_per_duration=False,
    ) == ["B", "C"])