@@ -332,18 +332,22 @@ def test_custom_type_variable_periodlength(test_mp, request):
332
332
npt .assert_allclose (obs , exp )
333
333
334
334
335
+ bound = 0.2
336
+ cumulative = False
337
+ years = [2020 , 2021 , 2022 , 2023 ]
338
+ tag = "yearly_" + str (bound ) + "_equal"
335
339
@pytest .mark .parametrize (
336
- "cumulative_bound, years" ,
340
+ "bound, cumulative, years, tag " ,
337
341
[
338
- (2.5 , [2020 , 2030 , 2040 , 2050 ]),
339
- (0.25 , [2020 , 2025 , 2030 , 2040 , 2050 ]),
340
- (0.50 , [2020 , 2030 , 2040 , 2050 ]),
341
- (0.50 , [2020 , 2025 , 2030 , 2040 , 2050 ]),
342
- (0.75 , [2020 , 2030 , 2040 , 2050 ]),
343
- (0.75 , [2020 , 2025 , 2030 , 2040 , 2050 ]),
342
+ (0.25 , True , [2020 , 2030 , 2040 , 2050 ], "0.25_equal" ),
343
+ (0.25 , True , [2020 , 2025 , 2030 , 2040 , 2050 ], "0.25_varying" ),
344
+ (0.50 , True , [2020 , 2030 , 2040 , 2050 ], "0.5_equal" ),
345
+ (0.50 , True , [2020 , 2025 , 2030 , 2040 , 2050 ], "0.5_varying" ),
346
+ (0.75 , True , [2020 , 2030 , 2040 , 2050 ], "0.75_equal" ),
347
+ (0.75 , True , [2020 , 2025 , 2030 , 2040 , 2050 ], "0.75_varying" ),
344
348
],
345
349
)
346
- def test_price_duality (test_mp , request , cumulative_bound , years ):
350
+ def test_price_duality (test_mp , request , bound , cumulative , years , tag ):
347
351
# set up a scenario for cumulative constraints
348
352
scen = Scenario (
349
353
test_mp ,
@@ -352,13 +356,15 @@ def test_price_duality(test_mp, request, cumulative_bound, years):
352
356
version = "new" ,
353
357
)
354
358
model_setup (scen , years , simple_tecs = False )
355
- scen .add_cat ("year" , "cumulative" , years )
356
- scen .add_par (
357
- "bound_emission" ,
358
- ["World" , "GHG" , "all" , "cumulative" ],
359
- cumulative_bound ,
360
- "tCO2" ,
361
- )
359
+ if cumulative :
360
+ scen .add_cat ("year" , "cumulative" , years )
361
+ scen .add_par (
362
+ "bound_emission" , ["World" , "ghg" , "all" , "cumulative" ], bound , "tCO2" ,
363
+ )
364
+ else :
365
+ for y in years :
366
+ scen .add_cat ("year" , y , y )
367
+ scen .add_par ("bound_emission" , ["World" , "ghg" , "all" , y ], bound , "tCO2" )
362
368
scen .commit ("initialize test scenario" )
363
369
scen .solve (quiet = True , ** solve_args )
364
370
0 commit comments