|
462 | 462 | StrategicProfile([OperationalProfile([5])]), |
463 | 463 | StrategicProfile([ScenarioProfile([5])]), |
464 | 464 | StrategicProfile([RepresentativeProfile([5])]), |
| 465 | + StrategicStochasticProfile([[OperationalProfile([5])]]), |
| 466 | + StrategicStochasticProfile([[ScenarioProfile([5])]]), |
| 467 | + StrategicStochasticProfile([[RepresentativeProfile([5])]]), |
465 | 468 | ] |
466 | 469 | for tp ∈ profiles |
467 | 470 | @test_throws AssertionError EMB.check_strategic_profile(tp, "") |
@@ -514,26 +517,24 @@ end |
514 | 517 | end |
515 | 518 |
|
516 | 519 | @testset "Checks - Nodes" begin |
517 | | - |
518 | 520 | # Resources used in the checks |
519 | 521 | NG = ResourceEmit("NG", 0.2) |
520 | 522 | Power = ResourceCarrier("Power", 0.0) |
521 | 523 | CO2 = ResourceEmit("CO2", 1.0) |
522 | 524 | aux = ResourceCarrier("aux", 0.0) |
523 | 525 |
|
524 | 526 | # Function for setting up the system for testing `Sink` and `Source` |
525 | | - function simple_graph(; |
| 527 | + function check_graph_src_snk(; |
526 | 528 | src_cap::TimeProfile = FixedProfile(10), |
527 | 529 | src_opex_var::TimeProfile = FixedProfile(10), |
528 | 530 | src_opex_fixed::TimeProfile = FixedProfile(0), |
529 | 531 | src_output::Dict = Dict(Power => 1), |
530 | 532 | snk_cap::TimeProfile = OperationalProfile([6, 8, 10, 6, 8]), |
531 | 533 | snk_pen::Dict = Dict(:surplus => FixedProfile(4), :deficit => FixedProfile(10)), |
532 | 534 | snk_input::Dict = Dict(Power => 1), |
| 535 | + T = TwoLevel(2, 2, SimpleTimes(5, 2); op_per_strat = 10), |
533 | 536 | ) |
534 | 537 | resources = [Power, CO2] |
535 | | - ops = SimpleTimes(5, 2) |
536 | | - T = TwoLevel(2, 2, ops; op_per_strat = 10) |
537 | 538 |
|
538 | 539 | source = |
539 | 540 | RefSource( |
@@ -566,39 +567,55 @@ end |
566 | 567 | # Sink used in the analysis |
567 | 568 | # Test that a wrong capacity is caught by the checks. |
568 | 569 | src_cap = FixedProfile(-4) |
569 | | - @test_throws AssertionError simple_graph(;src_cap) |
| 570 | + @test_throws AssertionError check_graph_src_snk(;src_cap) |
570 | 571 |
|
571 | 572 | # Test that a wrong output dictionary is caught by the checks. |
572 | 573 | src_output = Dict(Power => -1) |
573 | | - @test_throws AssertionError simple_graph(;src_output) |
| 574 | + @test_throws AssertionError check_graph_src_snk(;src_output) |
574 | 575 |
|
575 | 576 | # Test that a wrong fixed OPEX is caught by the checks. |
576 | 577 | src_opex_fixed = FixedProfile(-5) |
577 | | - @test_throws AssertionError simple_graph(;src_opex_fixed) |
| 578 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed) |
578 | 579 |
|
579 | | - # Test that a wrong profile for fixed OPEX is caught by the checks. |
| 580 | + # Test that a wrong profile for fixed OPEX is caught by the checks both with a |
| 581 | + # `TwoLevelTree` and `TwoLevel` time structure |
580 | 582 | # - check_fixed_opex(n::Node, 𝒯ᴵⁿᵛ, check_timeprofiles::Bool) |
581 | 583 | src_opex_fixed = StrategicProfile([1]) |
582 | | - @test_throws AssertionError simple_graph(;src_opex_fixed) |
| 584 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed) |
583 | 585 | src_opex_fixed = OperationalProfile([1]) |
584 | | - @test_throws AssertionError simple_graph(;src_opex_fixed) |
| 586 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed) |
| 587 | + src_opex_fixed = StrategicProfile([OperationalProfile([1]), OperationalProfile([1])]) |
| 588 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed) |
| 589 | + |
| 590 | + T = TwoLevelTree(2, [2], SimpleTimes(5, 1); op_per_strat = 10.) |
| 591 | + src_opex_fixed = StrategicProfile([1]) |
| 592 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed, T) |
| 593 | + src_opex_fixed = StrategicProfile([1, 2, 3]) |
| 594 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed, T) |
| 595 | + src_opex_fixed = OperationalProfile([1]) |
| 596 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed, T) |
| 597 | + src_opex_fixed = StrategicStochasticProfile([ |
| 598 | + [OperationalProfile([1])], |
| 599 | + [OperationalProfile([1]), OperationalProfile([1])], |
| 600 | + ]) |
| 601 | + @test_throws AssertionError check_graph_src_snk(; src_opex_fixed, T) |
585 | 602 | end |
586 | 603 |
|
587 | 604 | # Test that the fields of a Sink are correctly checked |
588 | 605 | # - check_node(n::Sink, 𝒯, modeltype::EnergyModel) |
589 | 606 | @testset "Sink" begin |
590 | 607 | # Test that an inconsistent Sink.penalty dictionaries is caught by the checks. |
591 | 608 | snk_pen = Dict(:surplus => FixedProfile(4), :def => FixedProfile(2)) |
592 | | - @test_throws AssertionError simple_graph(;snk_pen) |
| 609 | + @test_throws AssertionError check_graph_src_snk(;snk_pen) |
593 | 610 |
|
594 | 611 | # The penalties in this Sink node lead to an infeasible optimum. Test that the |
595 | 612 | # checks forbids it. |
596 | 613 | snk_pen = Dict(:surplus => FixedProfile(-4), :deficit => FixedProfile(2)) |
597 | | - @test_throws AssertionError simple_graph(;snk_pen) |
| 614 | + @test_throws AssertionError check_graph_src_snk(;snk_pen) |
598 | 615 |
|
599 | 616 | # Check that a wrong capacity in a sink is caught by the checks. |
600 | 617 | snk_cap = OperationalProfile(-[6, 8, 10, 6, 8]) |
601 | | - @test_throws AssertionError simple_graph(;snk_cap) |
| 618 | + @test_throws AssertionError check_graph_src_snk(;snk_cap) |
602 | 619 | end |
603 | 620 |
|
604 | 621 | # Function for setting up the system for testing a `NetworkNode` |
|
0 commit comments