From b886c90b88a24c878f801ef981be9dfa934ce702 Mon Sep 17 00:00:00 2001 From: Ana Mileva Date: Fri, 29 Jul 2022 16:52:07 -0700 Subject: [PATCH] Support constraining final market volume --- .../markets/volume/1_base_volume.csv | 38 +- db/csvs_test_examples/scenarios copy.csv | 104 +++++ db/db_schema.sql | 2 + .../1/1/inputs/market_volume.tab | 10 +- .../1/2/inputs/market_volume.tab | 10 +- .../1/3/inputs/market_volume.tab | 10 +- .../2/1/inputs/market_volume.tab | 10 +- .../2/2/inputs/market_volume.tab | 10 +- .../2/3/inputs/market_volume.tab | 10 +- .../3/1/inputs/market_volume.tab | 10 +- .../3/2/inputs/market_volume.tab | 10 +- .../3/3/inputs/market_volume.tab | 10 +- .../test_markets/inputs/market_volume.tab | 6 +- gridpath/system/markets/volume.py | 67 ++- tests/system/markets/test_volume.py | 41 ++ tests/test_data/inputs/market_volume.tab | 386 +++++++++--------- 16 files changed, 469 insertions(+), 265 deletions(-) create mode 100644 db/csvs_test_examples/scenarios copy.csv diff --git a/db/csvs_test_examples/markets/volume/1_base_volume.csv b/db/csvs_test_examples/markets/volume/1_base_volume.csv index c05cfa684..f58838b9f 100644 --- a/db/csvs_test_examples/markets/volume/1_base_volume.csv +++ b/db/csvs_test_examples/markets/volume/1_base_volume.csv @@ -1,19 +1,19 @@ -market,stage_id,timepoint,max_market_sales,max_market_purchases -Market_Hub,1,20200101,10,5 -Market_Hub,1,20200102,5,10 -Market_Hub,1,20200201,10,5 -Market_Hub,1,20200202,5,10 -Market_Hub,1,20200301,10,5 -Market_Hub,1,20200302,5,10 -Market_Hub2,1,20200101,10,5 -Market_Hub2,1,20200102,5,10 -Market_Hub2,1,20200201,10,5 -Market_Hub2,1,20200202,5,10 -Market_Hub2,1,20200301,10,5 -Market_Hub2,1,20200302,5,10 -Market_Hub2,2,20200101,5,5 -Market_Hub2,2,20200102,2,2 -Market_Hub2,2,20200201,5,5 -Market_Hub2,2,20200202,2,2 -Market_Hub2,2,20200301,5,5 -Market_Hub2,2,20200302,2,2 \ No newline at end of file +market,stage_id,timepoint,max_market_sales,max_market_purchases,max_final_market_sales,max_final_market_purchases +Market_Hub,1,20200101,10,5,, +Market_Hub,1,20200102,5,10,, +Market_Hub,1,20200201,10,5,, +Market_Hub,1,20200202,5,10,, +Market_Hub,1,20200301,10,5,, +Market_Hub,1,20200302,5,10,, +Market_Hub2,1,20200101,10,5,, +Market_Hub2,1,20200102,5,10,, +Market_Hub2,1,20200201,10,5,, +Market_Hub2,1,20200202,5,10,, +Market_Hub2,1,20200301,10,5,, +Market_Hub2,1,20200302,5,10,, +Market_Hub2,2,20200101,5,5,, +Market_Hub2,2,20200102,2,2,, +Market_Hub2,2,20200201,5,5,, +Market_Hub2,2,20200202,2,2,, +Market_Hub2,2,20200301,5,5,, +Market_Hub2,2,20200302,2,2,, \ No newline at end of file diff --git a/db/csvs_test_examples/scenarios copy.csv b/db/csvs_test_examples/scenarios copy.csv new file mode 100644 index 000000000..d19b883b8 --- /dev/null +++ b/db/csvs_test_examples/scenarios copy.csv @@ -0,0 +1,104 @@ +optional_feature_or_subscenarios,test,test_w_storage,test_w_hydro,test_new_solar,test_new_binary_solar,test_new_build_storage,test_new_build_storage_cumulative_min_max,test_new_binary_build_storage,test_no_overgen_allowed,test_no_reserves,test_variable_gen_reserves,test_new_solar_carbon_cap,test_new_solar_carbon_tax,test_ramp_up_constraints,test_ramp_up_and_down_constraints,2horizons,2horizons_w_hydro,2horizons_w_hydro_and_nuclear_binary_availability,2horizons_w_hydro_w_balancing_types,2periods,2periods_gen_lin_econ_retirement,2periods_gen_bin_econ_retirement,2periods_new_build,2periods_new_build_2zones,2periods_new_build_2zones_singleBA,2periods_new_build_2zones_transmission,2periods_new_build_2zones_transmission_w_losses,2periods_new_build_2zones_transmission_w_losses_opp_dir,2periods_new_build_2zones_new_build_transmission,2periods_new_build_cumulative_min_max,2periods_new_build_rps,2periods_new_build_rps_variable_reserves,2periods_new_build_rps_variable_reserves_subhourly_adj,2periods_new_build_rps_w_rps_eligible_storage,2periods_new_build_rps_w_rps_ineligible_storage,2periods_new_build_simple_prm,test_new_solar_carbon_cap_2zones_dont_count_tx,test_new_solar_carbon_cap_2zones_tx,single_stage_prod_cost,multi_stage_prod_cost,multi_stage_prod_cost_w_hydro,single_stage_prod_cost_cycle_select,test_tx_simple,test_tx_dcopf,2periods_new_build_local_capacity,test_startup_shutdown_rates,test_no_fuels,test_variable_om_curves,test_aux_cons,2periods_new_build_rps_percent_target,single_stage_prod_cost_linked_subproblems,multi_stage_prod_cost_linked_subproblems,test_w_lf_down_percent_req,2periods_new_build_capgroups,test_markets,2periods_new_build_horizon_energy_target,2periods_new_build_period_and_horizon_energy_target,2periods_new_build_horizon_energy_target_halfyear,test_new_build_gen_var_stor_hyb,test_carbon_tax_allowance,test_min_max_build_trans,2periods_new_build_2zones_transmission_Tx1halfavail,2periods_new_build_2zones_transmission_Tx1halfavailmonthly,test_cheap_fuel_blend,test_new_solar_carbon_cap_2zones_tx_low_carbon_fuel_blend,test_cheap_fuel_blend_w_limit,test_new_solar_fuel_burn_limit,test_new_solar_fuel_burn_limit_relative,test_w_solver_options,test_carbon_tax_allowance_with_different_fuel_groups,test_performance_standard,test_tx_flow,test_new_solar_reserve_prj_contribution,test_new_solar_carbon_cap_2zones_tx_hydrogen_prod,test_new_solar_carbon_cap_2zones_tx_hydrogen_prod_new,test_new_solar_carbon_cap_dac,test_cap_factor_limits,multi_stage_prod_cost_w_markets,test_supplemental_firing,test_tx_capacity_groups,2periods_new_build_fin_lifetime +of_transmission,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,1,1,1,,1,,,,,,1,1,,1,1,,,,,1, +of_transmission_hurdle_rates,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +of_simultaneous_flow_limits,,,,,,,,,,,,,,,,,,,,,,,,,,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3,3,1,1,1,1,1,1,1,2,2,2,2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,1,1,4,5,5,4,1,1,6,7,1,1,1,6,8,9,1,6,1,6,6,6,3,1,6,6,6,1,1,1,1,1,1,1,1,1,1,10,10,1,1,5,1,6,6 +load_zone_scenario_id,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,1,2,2,1,1,1,1,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,1,2,1,1,1,1,1,2,4,1,2,2,1,1,1,1,2,1 +load_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,2,1,1,1,1,1,1,1,1,2,4,1,1,1,3,1,1,1,2,1,3,3,3,1,1,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2 +project_portfolio_scenario_id,1,2,3,4,5,6,6,7,1,1,1,4,4,1,1,1,3,3,3,1,8,9,10,11,11,12,12,12,12,10,13,13,13,14,14,10,15,15,1,1,3,1,16,16,10,17,1,1,1,13,1,1,1,10,1,13,13,13,18,4,12,12,12,1,15,1,4,4,1,4,15,16,4,19,20,21,1,1,1,12,10 +project_operational_chars_scenario_id,1,1,1,1,1,1,1,1,1,1,2,1,1,3,4,1,5,10,6,1,1,1,1,1,1,1,1,1,1,1,1,7,7,8,8,1,1,1,7,1,9,18,1,1,1,11,12,13,14,1,7,7,1,1,1,1,1,1,1,15,1,1,1,15,16,17,1,1,1,17,16,1,1,19,19,1,20,1,21,1,1 +project_availability_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +project_load_zone_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +project_elcc_chars_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_specified_capacity_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,3,3,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,3,3,1,4,4,1,1,1,1,1,1 +project_specified_fixed_cost_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +fuel_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1 +fuel_price_scenario_id,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +project_new_cost_scenario_id,,,,1,1,1,1,1,,,,1,1,,,,,,,,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,,,,,1,1,1,,,,,1,,,,1,,1,1,1,1,1,1,1,1,,1,,1,1,,1,1,1,1,1,1,1,,,,1,2 +project_new_potential_scenario_id,,,,1,,,1,,,,,2,2,,,,,,,,,,,,,,,,,1,,,,,,,2,2,,,,,2,2,,,,,,,,,,,,,,,,2,,,,,2,,2,2,,2,2,2,1,2,2,2,,,,, +project_new_binary_build_size_scenario_id,,,,,1,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_capacity_group_requirement_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_capacity_group_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,, +transmission_portfolio_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,2,,,,,,,,1,1,,,,,3,3,,,,,,,,,,,,,,,,,2,1,1,,1,,,,,,1,3,,1,1,,,,,4, +transmission_load_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,2,1,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,1,1,1,,1,,,,,,1,1,,1,1,,,,,1, +transmission_specified_capacity_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,1,1,1,,1,,,,,,1,1,,1,1,,,,,1, +transmission_availability_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,1,2,3,,1,,,,,,1,1,,1,1,,,,,1, +transmission_operational_chars_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,1,3,3,1,,,,,,,,1,1,,,,,1,2,,,,,,,,,,,,,,,,,1,1,1,,1,,,,,,1,1,,1,1,,,,,1, +transmission_hurdle_rate_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +transmission_new_cost_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,1, +transmission_new_potential_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,1, +transmission_flow_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,, +transmission_capacity_group_requirement_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1, +transmission_capacity_group_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1, +transmission_carbon_cap_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,1,1,,,,,,,,,,,,,,,,,,,,,1,,,,,,,1,,1,1,,,,,, +transmission_simultaneous_flow_limit_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +transmission_simultaneous_flow_limit_line_group_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +lf_reserves_up_scenario_id,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1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,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,,,1,1,1,1,1,1 +regulation_up_ba_scenario_id,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,3,3,3,3,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,1,1,1,1,1,1,1,1,1,1,,,1,1,1,1,3,1 +project_regulation_up_ba_scenario_id,1,1,1,1,1,1,1,1,1,,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,4,4,5,5,1,5,5,1,1,5,1,5,5,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,1,5,5,1,,,1,1,1,1,1,1 +regulation_down_scenario_id,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,,,1,1,1,1,1,1 +regulation_down_ba_scenario_id,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,3,3,3,3,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,1,1,1,1,1,1,1,1,1,1,,,1,1,1,1,3,1 +project_regulation_down_ba_scenario_id,1,1,1,1,1,1,1,1,1,,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,4,4,5,5,1,5,5,1,1,5,1,5,5,1,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,1,5,5,1,,,1,1,1,1,1,1 +frequency_response_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +frequency_response_ba_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_frequency_response_ba_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +spinning_reserves_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +spinning_reserves_ba_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_spinning_reserves_ba_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +period_energy_target_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,1,,,,,,,,,,,,,,,2,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,, +horizon_energy_target_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,3,,,,,,,,,,,,,,,,,,,,,,, +energy_target_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,1,,,,,,,,,,,,,,,1,,,,,,1,1,1,,,,,,,,,,,,,,,,,,,,,,, +project_energy_target_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,1,1,2,,,,,,,,,,,,,,,1,,,,,,1,1,1,,,,,,,,,,,,,,,,,,,,,,, +carbon_cap_target_scenario_id,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,,,,,1,,,,,,,1,,2,2,1,,,,, +carbon_cap_zone_scenario_id,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,,,,,1,,,,,,,1,,1,1,1,,,,, +project_carbon_cap_zone_scenario_id,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,,,,1,1,,,,,,,,,,,,,,,,,,,,,1,,,,,,,1,,1,1,1,,,,, +carbon_tax_scenario_id,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,1,,,,,,,,,,, +carbon_tax_zone_scenario_id,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,1,,,,,,,,,,, +project_carbon_tax_zone_scenario_id,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,1,,,,,,,,,,, +project_carbon_tax_allowance_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,1,,,,,,,,,,, +performance_standard_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,, +performance_standard_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,, +project_performance_standard_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,, +fuel_burn_limit_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,2,,,,,,3,3,,,,,, +fuel_burn_limit_ba_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,,,,,1,1,,,,,, +project_fuel_burn_limit_ba_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,1,,,,,,1,1,,,,,, +prm_requirement_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +prm_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_prm_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +prm_energy_only_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +elcc_surface_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +local_capacity_requirement_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +local_capacity_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_local_capacity_zone_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +project_local_capacity_chars_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +tuning_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +solver_options_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,, +market_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,2,,, +load_zone_market_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,2,,, +market_price_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,1,,, +market_volume_scenario_id,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,1,,, \ No newline at end of file diff --git a/db/db_schema.sql b/db/db_schema.sql index 7a9fa1d46..f6b95a5a1 100644 --- a/db/db_schema.sql +++ b/db/db_schema.sql @@ -692,6 +692,8 @@ stage_id INTEGER, timepoint INTEGER, max_market_sales FLOAT, max_market_purchases FLOAT, +max_final_market_sales FLOAT, +max_final_market_purchases FLOAT, PRIMARY KEY (market_volume_scenario_id, market, stage_id, timepoint), FOREIGN KEY (market_volume_scenario_id) REFERENCES subscenarios_market_volume (market_volume_scenario_id) diff --git a/examples/multi_stage_prod_cost_w_markets/1/1/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/1/1/inputs/market_volume.tab index 5b79bb62b..64ef20080 100644 --- a/examples/multi_stage_prod_cost_w_markets/1/1/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/1/1/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200101 10.0 5.0 -Market_Hub 20200102 5.0 10.0 -Market_Hub2 20200101 10.0 5.0 -Market_Hub2 20200102 5.0 10.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200101 10.0 5.0 . . +Market_Hub 20200102 5.0 10.0 . . +Market_Hub2 20200101 10.0 5.0 . . +Market_Hub2 20200102 5.0 10.0 . . diff --git a/examples/multi_stage_prod_cost_w_markets/1/2/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/1/2/inputs/market_volume.tab index c6893e4ef..c5dddf621 100644 --- a/examples/multi_stage_prod_cost_w_markets/1/2/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/1/2/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200101 . . -Market_Hub 20200102 . . -Market_Hub2 20200101 5.0 5.0 -Market_Hub2 20200102 2.0 2.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200101 . . . . +Market_Hub 20200102 . . . . +Market_Hub2 20200101 5.0 5.0 . . +Market_Hub2 20200102 2.0 2.0 . . diff --git a/examples/multi_stage_prod_cost_w_markets/1/3/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/1/3/inputs/market_volume.tab index 86eeb1a48..ed017409c 100644 --- a/examples/multi_stage_prod_cost_w_markets/1/3/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/1/3/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200101 . . -Market_Hub 20200102 . . -Market_Hub2 20200101 . . -Market_Hub2 20200102 . . +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200101 . . . . +Market_Hub 20200102 . . . . +Market_Hub2 20200101 . . . . +Market_Hub2 20200102 . . . . diff --git a/examples/multi_stage_prod_cost_w_markets/2/1/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/2/1/inputs/market_volume.tab index e8cf5dca0..3321fccb3 100644 --- a/examples/multi_stage_prod_cost_w_markets/2/1/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/2/1/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200201 10.0 5.0 -Market_Hub 20200202 5.0 10.0 -Market_Hub2 20200201 10.0 5.0 -Market_Hub2 20200202 5.0 10.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200201 10.0 5.0 . . +Market_Hub 20200202 5.0 10.0 . . +Market_Hub2 20200201 10.0 5.0 . . +Market_Hub2 20200202 5.0 10.0 . . diff --git a/examples/multi_stage_prod_cost_w_markets/2/2/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/2/2/inputs/market_volume.tab index a86effe08..40aefc83f 100644 --- a/examples/multi_stage_prod_cost_w_markets/2/2/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/2/2/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200201 . . -Market_Hub 20200202 . . -Market_Hub2 20200201 5.0 5.0 -Market_Hub2 20200202 2.0 2.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200201 . . . . +Market_Hub 20200202 . . . . +Market_Hub2 20200201 5.0 5.0 . . +Market_Hub2 20200202 2.0 2.0 . . diff --git a/examples/multi_stage_prod_cost_w_markets/2/3/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/2/3/inputs/market_volume.tab index 7d386a736..108901761 100644 --- a/examples/multi_stage_prod_cost_w_markets/2/3/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/2/3/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200201 . . -Market_Hub 20200202 . . -Market_Hub2 20200201 . . -Market_Hub2 20200202 . . +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200201 . . . . +Market_Hub 20200202 . . . . +Market_Hub2 20200201 . . . . +Market_Hub2 20200202 . . . . diff --git a/examples/multi_stage_prod_cost_w_markets/3/1/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/3/1/inputs/market_volume.tab index bfc9ed4a2..453dd81a2 100644 --- a/examples/multi_stage_prod_cost_w_markets/3/1/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/3/1/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200301 10.0 5.0 -Market_Hub 20200302 5.0 10.0 -Market_Hub2 20200301 10.0 5.0 -Market_Hub2 20200302 5.0 10.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200301 10.0 5.0 . . +Market_Hub 20200302 5.0 10.0 . . +Market_Hub2 20200301 10.0 5.0 . . +Market_Hub2 20200302 5.0 10.0 . . diff --git a/examples/multi_stage_prod_cost_w_markets/3/2/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/3/2/inputs/market_volume.tab index 5888aacc6..36818e458 100644 --- a/examples/multi_stage_prod_cost_w_markets/3/2/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/3/2/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200301 . . -Market_Hub 20200302 . . -Market_Hub2 20200301 5.0 5.0 -Market_Hub2 20200302 2.0 2.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200301 . . . . +Market_Hub 20200302 . . . . +Market_Hub2 20200301 5.0 5.0 . . +Market_Hub2 20200302 2.0 2.0 . . diff --git a/examples/multi_stage_prod_cost_w_markets/3/3/inputs/market_volume.tab b/examples/multi_stage_prod_cost_w_markets/3/3/inputs/market_volume.tab index 426121617..ee41a43c3 100644 --- a/examples/multi_stage_prod_cost_w_markets/3/3/inputs/market_volume.tab +++ b/examples/multi_stage_prod_cost_w_markets/3/3/inputs/market_volume.tab @@ -1,5 +1,5 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200301 . . -Market_Hub 20200302 . . -Market_Hub2 20200301 . . -Market_Hub2 20200302 . . +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200301 . . . . +Market_Hub 20200302 . . . . +Market_Hub2 20200301 . . . . +Market_Hub2 20200302 . . . . diff --git a/examples/test_markets/inputs/market_volume.tab b/examples/test_markets/inputs/market_volume.tab index c8f8694ed..42cb26169 100644 --- a/examples/test_markets/inputs/market_volume.tab +++ b/examples/test_markets/inputs/market_volume.tab @@ -1,3 +1,3 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub 20200101 10.0 5.0 -Market_Hub 20200102 5.0 10.0 +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub 20200101 10.0 5.0 . . +Market_Hub 20200102 5.0 10.0 . . diff --git a/gridpath/system/markets/volume.py b/gridpath/system/markets/volume.py index 6c86823ad..e0fbbed62 100644 --- a/gridpath/system/markets/volume.py +++ b/gridpath/system/markets/volume.py @@ -22,8 +22,9 @@ def add_model_components(m, d, scenario_directory, subproblem, stage): """ """ m.max_market_sales = Param(m.MARKETS, m.TMPS, default=Infinity) - m.max_market_purchases = Param(m.MARKETS, m.TMPS, default=Infinity) + m.max_final_market_sales = Param(m.MARKETS, m.TMPS, default=Infinity) + m.max_final_market_purchases = Param(m.MARKETS, m.TMPS, default=Infinity) def total_market_sales_rule(mod, market, tmp): return sum( @@ -45,6 +46,29 @@ def total_market_purchases_rule(mod, market, tmp): m.MARKETS, m.TMPS, rule=total_market_purchases_rule ) + def total_net_market_sales_rule(mod, market, tmp): + return sum( + mod.Final_Sell_Power_Position[lz, mrkt, tmp] + for (lz, mrkt) in mod.LZ_MARKETS + if mrkt == market + ) + + m.Total_Net_Market_Sales = Expression( + m.MARKETS, m.TMPS, rule=total_net_market_sales_rule + ) + + def total_net_market_purchases_rule(mod, market, tmp): + return sum( + mod.Final_Buy_Power_Position[lz, mrkt, tmp] + for (lz, mrkt) in mod.LZ_MARKETS + if mrkt == market + ) + + m.Total_Net_Market_Purchases = Expression( + m.MARKETS, m.TMPS, rule=total_net_market_purchases_rule + ) + + # Constraints def max_market_sales_rule(mod, hub, tmp): return mod.Total_Market_Sales[hub, tmp] <= mod.max_market_sales[hub, tmp] @@ -61,6 +85,25 @@ def max_market_purchases_rule(mod, hub, tmp): m.MARKETS, m.TMPS, rule=max_market_purchases_rule ) + def max_final_market_sales_rule(mod, hub, tmp): + return ( + mod.Total_Net_Market_Sales[hub, tmp] <= mod.max_final_market_sales[hub, tmp] + ) + + m.Max_Net_Market_Sales_Constraint = Constraint( + m.MARKETS, m.TMPS, rule=max_final_market_sales_rule + ) + + def max_final_market_purchases_rule(mod, hub, tmp): + return ( + mod.Total_Net_Market_Purchases[hub, tmp] + <= mod.max_final_market_purchases[hub, tmp] + ) + + m.Max_Net_Market_Purchases_Constraint = Constraint( + m.MARKETS, m.TMPS, rule=max_final_market_purchases_rule + ) + def load_model_data(m, d, data_portal, scenario_directory, subproblem, stage): data_portal.load( @@ -71,7 +114,12 @@ def load_model_data(m, d, data_portal, scenario_directory, subproblem, stage): "inputs", "market_volume.tab", ), - param=(m.max_market_sales, m.max_market_purchases), + param=( + m.max_market_sales, + m.max_market_purchases, + m.max_final_market_sales, + m.max_final_market_purchases, + ), ) @@ -92,7 +140,8 @@ def get_inputs_from_database(scenario_id, subscenarios, subproblem, stage, conn) # market_scenario_id market_limits = c.execute( """ - SELECT market, timepoint, max_market_sales, max_market_purchases + SELECT market, timepoint, max_market_sales, max_market_purchases, + max_final_market_sales, max_final_market_purchases -- Get prices for included markets only FROM ( SELECT market @@ -107,7 +156,8 @@ def get_inputs_from_database(scenario_id, subscenarios, subproblem, stage, conn) AND stage_id = ? ) as tmp_tbl LEFT OUTER JOIN ( - SELECT market, stage_id, timepoint, max_market_sales, max_market_purchases + SELECT market, stage_id, timepoint, max_market_sales, max_market_purchases, + max_final_market_sales, max_final_market_purchases FROM inputs_market_volume WHERE market_volume_scenario_id = ? ) as price_tbl @@ -158,7 +208,14 @@ def write_model_inputs( writer = csv.writer(f, delimiter="\t", lineterminator="\n") writer.writerow( - ["market", "timepoint", "max_market_sales", "max_market_purchases"] + [ + "market", + "timepoint", + "max_market_sales", + "max_market_purchases", + "max_final_market_sales", + "max_final_market_purchases", + ] ) for row in market_limits: replace_nulls = ["." if i is None else i for i in row] diff --git a/tests/system/markets/test_volume.py b/tests/system/markets/test_volume.py index 9c43a5c2e..2abc39173 100644 --- a/tests/system/markets/test_volume.py +++ b/tests/system/markets/test_volume.py @@ -140,6 +140,47 @@ def test_initialized_components(self): ) self.assertDictEqual(expected_max_purchases, actual_max_purchases) + # Param: max_final_market_sales + expected_max_final_sales = OrderedDict( + sorted( + market_volume_df.set_index(["market", "timepoint"]) + .to_dict()["max_final_market_sales"] + .items() + ) + ) + for key in expected_max_final_sales.keys(): + expected_max_final_sales[key] = float("inf") + + actual_max_final_sales = OrderedDict( + sorted( + { + (mrkt, tmp): instance.max_final_market_sales[mrkt, tmp] + for mrkt in instance.MARKETS + for tmp in instance.TMPS + }.items() + ) + ) + self.assertDictEqual(expected_max_final_sales, actual_max_final_sales) + + # Param: max_final_market_purchases + expected_max_final_purchases = OrderedDict( + sorted( + market_volume_df.set_index(["market", "timepoint"]) + .to_dict()["max_final_market_purchases"] + .items() + ) + ) + actual_max_final_purchases = OrderedDict( + sorted( + { + (mrkt, tmp): instance.max_final_market_purchases[mrkt, tmp] + for mrkt in instance.MARKETS + for tmp in instance.TMPS + }.items() + ) + ) + self.assertDictEqual(expected_max_final_purchases, actual_max_final_purchases) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_data/inputs/market_volume.tab b/tests/test_data/inputs/market_volume.tab index 438655dee..3c1ea083f 100644 --- a/tests/test_data/inputs/market_volume.tab +++ b/tests/test_data/inputs/market_volume.tab @@ -1,193 +1,193 @@ -market timepoint max_market_sales max_market_purchases -Market_Hub_1 20200101 10 5 -Market_Hub_1 20200102 10 5 -Market_Hub_1 20200103 10 5 -Market_Hub_1 20200104 10 5 -Market_Hub_1 20200105 10 5 -Market_Hub_1 20200106 10 5 -Market_Hub_1 20200107 10 5 -Market_Hub_1 20200108 10 5 -Market_Hub_1 20200109 10 5 -Market_Hub_1 20200110 10 5 -Market_Hub_1 20200111 10 5 -Market_Hub_1 20200112 10 5 -Market_Hub_1 20200113 10 5 -Market_Hub_1 20200114 10 5 -Market_Hub_1 20200115 10 5 -Market_Hub_1 20200116 10 5 -Market_Hub_1 20200117 10 5 -Market_Hub_1 20200118 10 5 -Market_Hub_1 20200119 10 5 -Market_Hub_1 20200120 10 5 -Market_Hub_1 20200121 10 5 -Market_Hub_1 20200122 10 5 -Market_Hub_1 20200123 10 5 -Market_Hub_1 20200124 10 5 -Market_Hub_1 20200201 10 5 -Market_Hub_1 20200202 10 5 -Market_Hub_1 20200203 10 5 -Market_Hub_1 20200204 10 5 -Market_Hub_1 20200205 10 5 -Market_Hub_1 20200206 10 5 -Market_Hub_1 20200207 10 5 -Market_Hub_1 20200208 10 5 -Market_Hub_1 20200209 10 5 -Market_Hub_1 20200210 10 5 -Market_Hub_1 20200211 10 5 -Market_Hub_1 20200212 10 5 -Market_Hub_1 20200213 10 5 -Market_Hub_1 20200214 10 5 -Market_Hub_1 20200215 10 5 -Market_Hub_1 20200216 10 5 -Market_Hub_1 20200217 10 5 -Market_Hub_1 20200218 10 5 -Market_Hub_1 20200219 10 5 -Market_Hub_1 20200220 10 5 -Market_Hub_1 20200221 10 5 -Market_Hub_1 20200222 10 5 -Market_Hub_1 20200223 10 5 -Market_Hub_1 20200224 10 5 -Market_Hub_1 20300101 10 5 -Market_Hub_1 20300102 10 5 -Market_Hub_1 20300103 10 5 -Market_Hub_1 20300104 10 5 -Market_Hub_1 20300105 10 5 -Market_Hub_1 20300106 10 5 -Market_Hub_1 20300107 10 5 -Market_Hub_1 20300108 10 5 -Market_Hub_1 20300109 10 5 -Market_Hub_1 20300110 10 5 -Market_Hub_1 20300111 10 5 -Market_Hub_1 20300112 10 5 -Market_Hub_1 20300113 10 5 -Market_Hub_1 20300114 10 5 -Market_Hub_1 20300115 10 5 -Market_Hub_1 20300116 10 5 -Market_Hub_1 20300117 10 5 -Market_Hub_1 20300118 10 5 -Market_Hub_1 20300119 10 5 -Market_Hub_1 20300120 10 5 -Market_Hub_1 20300121 10 5 -Market_Hub_1 20300122 10 5 -Market_Hub_1 20300123 10 5 -Market_Hub_1 20300124 10 5 -Market_Hub_1 20300201 10 5 -Market_Hub_1 20300202 10 5 -Market_Hub_1 20300203 10 5 -Market_Hub_1 20300204 10 5 -Market_Hub_1 20300205 10 5 -Market_Hub_1 20300206 10 5 -Market_Hub_1 20300207 10 5 -Market_Hub_1 20300208 10 5 -Market_Hub_1 20300209 10 5 -Market_Hub_1 20300210 10 5 -Market_Hub_1 20300211 10 5 -Market_Hub_1 20300212 10 5 -Market_Hub_1 20300213 10 5 -Market_Hub_1 20300214 10 5 -Market_Hub_1 20300215 10 5 -Market_Hub_1 20300216 10 5 -Market_Hub_1 20300217 10 5 -Market_Hub_1 20300218 10 5 -Market_Hub_1 20300219 10 5 -Market_Hub_1 20300220 10 5 -Market_Hub_1 20300221 10 5 -Market_Hub_1 20300222 10 5 -Market_Hub_1 20300223 10 5 -Market_Hub_1 20300224 10 5 -Market_Hub_2 20200101 10 5 -Market_Hub_2 20200102 10 5 -Market_Hub_2 20200103 10 5 -Market_Hub_2 20200104 10 5 -Market_Hub_2 20200105 10 5 -Market_Hub_2 20200106 10 5 -Market_Hub_2 20200107 10 5 -Market_Hub_2 20200108 10 5 -Market_Hub_2 20200109 10 5 -Market_Hub_2 20200110 10 5 -Market_Hub_2 20200111 10 5 -Market_Hub_2 20200112 10 5 -Market_Hub_2 20200113 10 5 -Market_Hub_2 20200114 10 5 -Market_Hub_2 20200115 10 5 -Market_Hub_2 20200116 10 5 -Market_Hub_2 20200117 10 5 -Market_Hub_2 20200118 10 5 -Market_Hub_2 20200119 10 5 -Market_Hub_2 20200120 10 5 -Market_Hub_2 20200121 10 5 -Market_Hub_2 20200122 10 5 -Market_Hub_2 20200123 10 5 -Market_Hub_2 20200124 10 5 -Market_Hub_2 20200201 10 5 -Market_Hub_2 20200202 10 5 -Market_Hub_2 20200203 10 5 -Market_Hub_2 20200204 10 5 -Market_Hub_2 20200205 10 5 -Market_Hub_2 20200206 10 5 -Market_Hub_2 20200207 10 5 -Market_Hub_2 20200208 10 5 -Market_Hub_2 20200209 10 5 -Market_Hub_2 20200210 10 5 -Market_Hub_2 20200211 10 5 -Market_Hub_2 20200212 10 5 -Market_Hub_2 20200213 10 5 -Market_Hub_2 20200214 10 5 -Market_Hub_2 20200215 10 5 -Market_Hub_2 20200216 10 5 -Market_Hub_2 20200217 10 5 -Market_Hub_2 20200218 10 5 -Market_Hub_2 20200219 10 5 -Market_Hub_2 20200220 10 5 -Market_Hub_2 20200221 10 5 -Market_Hub_2 20200222 10 5 -Market_Hub_2 20200223 10 5 -Market_Hub_2 20200224 10 5 -Market_Hub_2 20300101 10 5 -Market_Hub_2 20300102 10 5 -Market_Hub_2 20300103 10 5 -Market_Hub_2 20300104 10 5 -Market_Hub_2 20300105 10 5 -Market_Hub_2 20300106 10 5 -Market_Hub_2 20300107 10 5 -Market_Hub_2 20300108 10 5 -Market_Hub_2 20300109 10 5 -Market_Hub_2 20300110 10 5 -Market_Hub_2 20300111 10 5 -Market_Hub_2 20300112 10 5 -Market_Hub_2 20300113 10 5 -Market_Hub_2 20300114 10 5 -Market_Hub_2 20300115 10 5 -Market_Hub_2 20300116 10 5 -Market_Hub_2 20300117 10 5 -Market_Hub_2 20300118 10 5 -Market_Hub_2 20300119 10 5 -Market_Hub_2 20300120 10 5 -Market_Hub_2 20300121 10 5 -Market_Hub_2 20300122 10 5 -Market_Hub_2 20300123 10 5 -Market_Hub_2 20300124 10 5 -Market_Hub_2 20300201 10 5 -Market_Hub_2 20300202 10 5 -Market_Hub_2 20300203 10 5 -Market_Hub_2 20300204 10 5 -Market_Hub_2 20300205 10 5 -Market_Hub_2 20300206 10 5 -Market_Hub_2 20300207 10 5 -Market_Hub_2 20300208 10 5 -Market_Hub_2 20300209 10 5 -Market_Hub_2 20300210 10 5 -Market_Hub_2 20300211 10 5 -Market_Hub_2 20300212 10 5 -Market_Hub_2 20300213 10 5 -Market_Hub_2 20300214 10 5 -Market_Hub_2 20300215 10 5 -Market_Hub_2 20300216 10 5 -Market_Hub_2 20300217 10 5 -Market_Hub_2 20300218 10 5 -Market_Hub_2 20300219 10 5 -Market_Hub_2 20300220 10 5 -Market_Hub_2 20300221 10 5 -Market_Hub_2 20300222 10 5 -Market_Hub_2 20300223 10 5 -Market_Hub_2 20300224 10 5 \ No newline at end of file +market timepoint max_market_sales max_market_purchases max_final_market_sales max_final_market_purchases +Market_Hub_1 20200101 10 5 . 20 +Market_Hub_1 20200102 10 5 . 20 +Market_Hub_1 20200103 10 5 . 20 +Market_Hub_1 20200104 10 5 . 20 +Market_Hub_1 20200105 10 5 . 20 +Market_Hub_1 20200106 10 5 . 20 +Market_Hub_1 20200107 10 5 . 20 +Market_Hub_1 20200108 10 5 . 20 +Market_Hub_1 20200109 10 5 . 20 +Market_Hub_1 20200110 10 5 . 20 +Market_Hub_1 20200111 10 5 . 20 +Market_Hub_1 20200112 10 5 . 20 +Market_Hub_1 20200113 10 5 . 20 +Market_Hub_1 20200114 10 5 . 20 +Market_Hub_1 20200115 10 5 . 20 +Market_Hub_1 20200116 10 5 . 20 +Market_Hub_1 20200117 10 5 . 20 +Market_Hub_1 20200118 10 5 . 20 +Market_Hub_1 20200119 10 5 . 20 +Market_Hub_1 20200120 10 5 . 20 +Market_Hub_1 20200121 10 5 . 20 +Market_Hub_1 20200122 10 5 . 20 +Market_Hub_1 20200123 10 5 . 20 +Market_Hub_1 20200124 10 5 . 20 +Market_Hub_1 20200201 10 5 . 20 +Market_Hub_1 20200202 10 5 . 20 +Market_Hub_1 20200203 10 5 . 20 +Market_Hub_1 20200204 10 5 . 20 +Market_Hub_1 20200205 10 5 . 20 +Market_Hub_1 20200206 10 5 . 20 +Market_Hub_1 20200207 10 5 . 20 +Market_Hub_1 20200208 10 5 . 20 +Market_Hub_1 20200209 10 5 . 20 +Market_Hub_1 20200210 10 5 . 20 +Market_Hub_1 20200211 10 5 . 20 +Market_Hub_1 20200212 10 5 . 20 +Market_Hub_1 20200213 10 5 . 20 +Market_Hub_1 20200214 10 5 . 20 +Market_Hub_1 20200215 10 5 . 20 +Market_Hub_1 20200216 10 5 . 20 +Market_Hub_1 20200217 10 5 . 20 +Market_Hub_1 20200218 10 5 . 20 +Market_Hub_1 20200219 10 5 . 20 +Market_Hub_1 20200220 10 5 . 20 +Market_Hub_1 20200221 10 5 . 20 +Market_Hub_1 20200222 10 5 . 20 +Market_Hub_1 20200223 10 5 . 20 +Market_Hub_1 20200224 10 5 . 20 +Market_Hub_1 20300101 10 5 . 20 +Market_Hub_1 20300102 10 5 . 20 +Market_Hub_1 20300103 10 5 . 20 +Market_Hub_1 20300104 10 5 . 20 +Market_Hub_1 20300105 10 5 . 20 +Market_Hub_1 20300106 10 5 . 20 +Market_Hub_1 20300107 10 5 . 20 +Market_Hub_1 20300108 10 5 . 20 +Market_Hub_1 20300109 10 5 . 20 +Market_Hub_1 20300110 10 5 . 20 +Market_Hub_1 20300111 10 5 . 20 +Market_Hub_1 20300112 10 5 . 20 +Market_Hub_1 20300113 10 5 . 20 +Market_Hub_1 20300114 10 5 . 20 +Market_Hub_1 20300115 10 5 . 20 +Market_Hub_1 20300116 10 5 . 20 +Market_Hub_1 20300117 10 5 . 20 +Market_Hub_1 20300118 10 5 . 20 +Market_Hub_1 20300119 10 5 . 20 +Market_Hub_1 20300120 10 5 . 20 +Market_Hub_1 20300121 10 5 . 20 +Market_Hub_1 20300122 10 5 . 20 +Market_Hub_1 20300123 10 5 . 20 +Market_Hub_1 20300124 10 5 . 20 +Market_Hub_1 20300201 10 5 . 20 +Market_Hub_1 20300202 10 5 . 20 +Market_Hub_1 20300203 10 5 . 20 +Market_Hub_1 20300204 10 5 . 20 +Market_Hub_1 20300205 10 5 . 20 +Market_Hub_1 20300206 10 5 . 20 +Market_Hub_1 20300207 10 5 . 20 +Market_Hub_1 20300208 10 5 . 20 +Market_Hub_1 20300209 10 5 . 20 +Market_Hub_1 20300210 10 5 . 20 +Market_Hub_1 20300211 10 5 . 20 +Market_Hub_1 20300212 10 5 . 20 +Market_Hub_1 20300213 10 5 . 20 +Market_Hub_1 20300214 10 5 . 20 +Market_Hub_1 20300215 10 5 . 20 +Market_Hub_1 20300216 10 5 . 20 +Market_Hub_1 20300217 10 5 . 20 +Market_Hub_1 20300218 10 5 . 20 +Market_Hub_1 20300219 10 5 . 20 +Market_Hub_1 20300220 10 5 . 20 +Market_Hub_1 20300221 10 5 . 20 +Market_Hub_1 20300222 10 5 . 20 +Market_Hub_1 20300223 10 5 . 20 +Market_Hub_1 20300224 10 5 . 20 +Market_Hub_2 20200101 10 5 . 20 +Market_Hub_2 20200102 10 5 . 20 +Market_Hub_2 20200103 10 5 . 20 +Market_Hub_2 20200104 10 5 . 20 +Market_Hub_2 20200105 10 5 . 20 +Market_Hub_2 20200106 10 5 . 20 +Market_Hub_2 20200107 10 5 . 20 +Market_Hub_2 20200108 10 5 . 20 +Market_Hub_2 20200109 10 5 . 20 +Market_Hub_2 20200110 10 5 . 20 +Market_Hub_2 20200111 10 5 . 20 +Market_Hub_2 20200112 10 5 . 20 +Market_Hub_2 20200113 10 5 . 20 +Market_Hub_2 20200114 10 5 . 20 +Market_Hub_2 20200115 10 5 . 20 +Market_Hub_2 20200116 10 5 . 20 +Market_Hub_2 20200117 10 5 . 20 +Market_Hub_2 20200118 10 5 . 20 +Market_Hub_2 20200119 10 5 . 20 +Market_Hub_2 20200120 10 5 . 20 +Market_Hub_2 20200121 10 5 . 20 +Market_Hub_2 20200122 10 5 . 20 +Market_Hub_2 20200123 10 5 . 20 +Market_Hub_2 20200124 10 5 . 20 +Market_Hub_2 20200201 10 5 . 20 +Market_Hub_2 20200202 10 5 . 20 +Market_Hub_2 20200203 10 5 . 20 +Market_Hub_2 20200204 10 5 . 20 +Market_Hub_2 20200205 10 5 . 20 +Market_Hub_2 20200206 10 5 . 20 +Market_Hub_2 20200207 10 5 . 20 +Market_Hub_2 20200208 10 5 . 20 +Market_Hub_2 20200209 10 5 . 20 +Market_Hub_2 20200210 10 5 . 20 +Market_Hub_2 20200211 10 5 . 20 +Market_Hub_2 20200212 10 5 . 20 +Market_Hub_2 20200213 10 5 . 20 +Market_Hub_2 20200214 10 5 . 20 +Market_Hub_2 20200215 10 5 . 20 +Market_Hub_2 20200216 10 5 . 20 +Market_Hub_2 20200217 10 5 . 20 +Market_Hub_2 20200218 10 5 . 20 +Market_Hub_2 20200219 10 5 . 20 +Market_Hub_2 20200220 10 5 . 20 +Market_Hub_2 20200221 10 5 . 20 +Market_Hub_2 20200222 10 5 . 20 +Market_Hub_2 20200223 10 5 . 20 +Market_Hub_2 20200224 10 5 . 20 +Market_Hub_2 20300101 10 5 . 20 +Market_Hub_2 20300102 10 5 . 20 +Market_Hub_2 20300103 10 5 . 20 +Market_Hub_2 20300104 10 5 . 20 +Market_Hub_2 20300105 10 5 . 20 +Market_Hub_2 20300106 10 5 . 20 +Market_Hub_2 20300107 10 5 . 20 +Market_Hub_2 20300108 10 5 . 20 +Market_Hub_2 20300109 10 5 . 20 +Market_Hub_2 20300110 10 5 . 20 +Market_Hub_2 20300111 10 5 . 20 +Market_Hub_2 20300112 10 5 . 20 +Market_Hub_2 20300113 10 5 . 20 +Market_Hub_2 20300114 10 5 . 20 +Market_Hub_2 20300115 10 5 . 20 +Market_Hub_2 20300116 10 5 . 20 +Market_Hub_2 20300117 10 5 . 20 +Market_Hub_2 20300118 10 5 . 20 +Market_Hub_2 20300119 10 5 . 20 +Market_Hub_2 20300120 10 5 . 20 +Market_Hub_2 20300121 10 5 . 20 +Market_Hub_2 20300122 10 5 . 20 +Market_Hub_2 20300123 10 5 . 20 +Market_Hub_2 20300124 10 5 . 20 +Market_Hub_2 20300201 10 5 . 20 +Market_Hub_2 20300202 10 5 . 20 +Market_Hub_2 20300203 10 5 . 20 +Market_Hub_2 20300204 10 5 . 20 +Market_Hub_2 20300205 10 5 . 20 +Market_Hub_2 20300206 10 5 . 20 +Market_Hub_2 20300207 10 5 . 20 +Market_Hub_2 20300208 10 5 . 20 +Market_Hub_2 20300209 10 5 . 20 +Market_Hub_2 20300210 10 5 . 20 +Market_Hub_2 20300211 10 5 . 20 +Market_Hub_2 20300212 10 5 . 20 +Market_Hub_2 20300213 10 5 . 20 +Market_Hub_2 20300214 10 5 . 20 +Market_Hub_2 20300215 10 5 . 20 +Market_Hub_2 20300216 10 5 . 20 +Market_Hub_2 20300217 10 5 . 20 +Market_Hub_2 20300218 10 5 . 20 +Market_Hub_2 20300219 10 5 . 20 +Market_Hub_2 20300220 10 5 . 20 +Market_Hub_2 20300221 10 5 . 20 +Market_Hub_2 20300222 10 5 . 20 +Market_Hub_2 20300223 10 5 . 20 +Market_Hub_2 20300224 10 5 . 20 \ No newline at end of file