Skip to content

Commit

Permalink
Merge branch 'main' into refactor/create_user_class_for_thermal
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle authored Feb 11, 2025
2 parents 06ff10d + 21fea1a commit 4e91640
Show file tree
Hide file tree
Showing 18 changed files with 633 additions and 247 deletions.
13 changes: 13 additions & 0 deletions src/antares/craft/model/settings/adequacy_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ class PriceTakingOrder(Enum):

@dataclass
class AdequacyPatchParameters:
include_adq_patch: bool = False
set_to_null_ntc_from_physical_out_to_physical_in_for_first_step: bool = True
set_to_null_ntc_between_physical_out_for_first_step: bool = True
price_taking_order: PriceTakingOrder = PriceTakingOrder.DENS
include_hurdle_cost_csr: bool = False
check_csr_cost_function: bool = False
threshold_initiate_curtailment_sharing_rule: int = 0
threshold_display_local_matching_rule_violations: int = 0
threshold_csr_variable_bounds_relaxation: int = 3


@dataclass
class AdequacyPatchParametersUpdate:
include_adq_patch: Optional[bool] = None
set_to_null_ntc_from_physical_out_to_physical_in_for_first_step: Optional[bool] = None
set_to_null_ntc_between_physical_out_for_first_step: Optional[bool] = None
Expand Down
28 changes: 26 additions & 2 deletions src/antares/craft/model/settings/advanced_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
from dataclasses import dataclass
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional

Expand Down Expand Up @@ -63,6 +63,30 @@ class RenewableGenerationModeling(Enum):

@dataclass
class AdvancedParameters:
initial_reservoir_levels: InitialReservoirLevel = InitialReservoirLevel.COLD_START
hydro_heuristic_policy: HydroHeuristicPolicy = HydroHeuristicPolicy.ACCOMMODATE_RULES_CURVES
hydro_pricing_mode: HydroPricingMode = HydroPricingMode.FAST
power_fluctuations: PowerFluctuation = PowerFluctuation.FREE_MODULATIONS
shedding_policy: SheddingPolicy = SheddingPolicy.SHAVE_PEAKS
unit_commitment_mode: UnitCommitmentMode = UnitCommitmentMode.FAST
number_of_cores_mode: SimulationCore = SimulationCore.MEDIUM
renewable_generation_modelling: RenewableGenerationModeling = RenewableGenerationModeling.CLUSTERS
accuracy_on_correlation: set[OutputChoices] = field(default_factory=set)


@dataclass
class SeedParameters:
seed_tsgen_thermal: int = 3005489
seed_tsnumbers: int = 5005489
seed_unsupplied_energy_costs: int = 6005489
seed_spilled_energy_costs: int = 7005489
seed_thermal_costs: int = 8005489
seed_hydro_costs: int = 9005489
seed_initial_reservoir_levels: int = 10005489


@dataclass
class AdvancedParametersUpdate:
initial_reservoir_levels: Optional[InitialReservoirLevel] = None
hydro_heuristic_policy: Optional[HydroHeuristicPolicy] = None
hydro_pricing_mode: Optional[HydroPricingMode] = None
Expand All @@ -75,7 +99,7 @@ class AdvancedParameters:


@dataclass
class SeedParameters:
class SeedParametersUpdate:
seed_tsgen_thermal: Optional[int] = None
seed_tsnumbers: Optional[int] = None
seed_unsupplied_energy_costs: Optional[int] = None
Expand Down
21 changes: 21 additions & 0 deletions src/antares/craft/model/settings/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ class OutputFormat(EnumIgnoreCase):

@dataclass
class GeneralParameters:
mode: Mode = Mode.ECONOMY
horizon: str = ""
nb_years: int = 1
simulation_start: int = 1
simulation_end: int = 365
january_first: WeekDay = WeekDay.MONDAY
first_month_in_year: Month = Month.JANUARY
first_week_day: WeekDay = WeekDay.MONDAY
leap_year: bool = False
year_by_year: bool = False
simulation_synthesis: bool = True
building_mode: BuildingMode = BuildingMode.AUTOMATIC
user_playlist: bool = False
thematic_trimming: bool = False
geographic_trimming: bool = False
store_new_set: bool = False
nb_timeseries_thermal: int = 1


@dataclass
class GeneralParametersUpdate:
mode: Optional[Mode] = None
horizon: Optional[str] = None
nb_years: Optional[int] = None
Expand Down
21 changes: 19 additions & 2 deletions src/antares/craft/model/settings/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,31 @@ class SimplexOptimizationRange(Enum):


class ExportMPS(Enum):
NONE = "none"
TRUE = "True"
FALSE = "False"
OPTIM1 = "optim1"
OPTIM2 = "optim2"
BOTH_OPTIMS = "both-optims"


@dataclass
class OptimizationParameters:
simplex_range: SimplexOptimizationRange = SimplexOptimizationRange.WEEK
transmission_capacities: OptimizationTransmissionCapacities = OptimizationTransmissionCapacities.LOCAL_VALUES
include_constraints: bool = True
include_hurdlecosts: bool = True
include_tc_minstablepower: bool = True
include_tc_min_ud_time: bool = True
include_dayahead: bool = True
include_strategicreserve: bool = True
include_spinningreserve: bool = True
include_primaryreserve: bool = True
include_exportmps: ExportMPS = ExportMPS.FALSE
include_exportstructure: bool = False
include_unfeasible_problem_behavior: UnfeasibleProblemBehavior = UnfeasibleProblemBehavior.ERROR_VERBOSE


@dataclass
class OptimizationParametersUpdate:
simplex_range: Optional[SimplexOptimizationRange] = None
transmission_capacities: Optional[OptimizationTransmissionCapacities] = None
include_constraints: Optional[bool] = None
Expand Down
4 changes: 2 additions & 2 deletions src/antares/craft/model/settings/playlist_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

@dataclass
class PlaylistParameters:
status: bool = True
weight: float = 1.0
status: bool
weight: float
94 changes: 81 additions & 13 deletions src/antares/craft/model/settings/study_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,91 @@
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
from dataclasses import dataclass
from dataclasses import asdict, dataclass, field
from typing import Optional

from antares.craft.model.settings.adequacy_patch import AdequacyPatchParameters
from antares.craft.model.settings.advanced_parameters import AdvancedParameters, SeedParameters
from antares.craft.model.settings.general import GeneralParameters
from antares.craft.model.settings.optimization import OptimizationParameters
from antares.craft.model.settings.adequacy_patch import AdequacyPatchParameters, AdequacyPatchParametersUpdate
from antares.craft.model.settings.advanced_parameters import (
AdvancedParameters,
AdvancedParametersUpdate,
SeedParameters,
SeedParametersUpdate,
)
from antares.craft.model.settings.general import GeneralParameters, GeneralParametersUpdate
from antares.craft.model.settings.optimization import OptimizationParameters, OptimizationParametersUpdate
from antares.craft.model.settings.playlist_parameters import PlaylistParameters
from antares.craft.model.settings.thematic_trimming import ThematicTrimmingParameters
from antares.craft.model.settings.thematic_trimming import ThematicTrimmingParameters, ThematicTrimmingParametersUpdate


@dataclass
class StudySettings:
general_parameters: Optional[GeneralParameters] = None
optimization_parameters: Optional[OptimizationParameters] = None
advanced_parameters: Optional[AdvancedParameters] = None
seed_parameters: Optional[SeedParameters] = None
adequacy_patch_parameters: Optional[AdequacyPatchParameters] = None
class StudySettingsUpdate:
general_parameters: Optional[GeneralParametersUpdate] = None
optimization_parameters: Optional[OptimizationParametersUpdate] = None
advanced_parameters: Optional[AdvancedParametersUpdate] = None
seed_parameters: Optional[SeedParametersUpdate] = None
adequacy_patch_parameters: Optional[AdequacyPatchParametersUpdate] = None
thematic_trimming_parameters: Optional[ThematicTrimmingParametersUpdate] = None
playlist_parameters: Optional[dict[int, PlaylistParameters]] = None
thematic_trimming_parameters: Optional[ThematicTrimmingParameters] = None


@dataclass
class StudySettings:
general_parameters: GeneralParameters = field(default_factory=GeneralParameters)
optimization_parameters: OptimizationParameters = field(default_factory=OptimizationParameters)
advanced_parameters: AdvancedParameters = field(default_factory=AdvancedParameters)
seed_parameters: SeedParameters = field(default_factory=SeedParameters)
adequacy_patch_parameters: AdequacyPatchParameters = field(default_factory=AdequacyPatchParameters)
thematic_trimming_parameters: ThematicTrimmingParameters = field(default_factory=ThematicTrimmingParameters)
playlist_parameters: dict[int, PlaylistParameters] = field(default_factory=dict)

def from_update_settings(self, update_settings: StudySettingsUpdate) -> "StudySettings":
current_settings = asdict(self)
for key, values in asdict(update_settings).items():
if values is not None:
for inner_key, inner_value in values.items():
if inner_value is not None:
current_settings[key][inner_key] = inner_value

general_parameters = GeneralParameters(**current_settings["general_parameters"])
optimization_parameters = OptimizationParameters(**current_settings["optimization_parameters"])
advanced_parameters = AdvancedParameters(**current_settings["advanced_parameters"])
seed_parameters = SeedParameters(**current_settings["seed_parameters"])
adequacy_patch_parameters = AdequacyPatchParameters(**current_settings["adequacy_patch_parameters"])
thematic_trimming_parameters = ThematicTrimmingParameters(**current_settings["thematic_trimming_parameters"])
playlist_parameters: dict[int, PlaylistParameters] = {}
for year in current_settings["playlist_parameters"]:
playlist_parameters[year] = PlaylistParameters(**current_settings["playlist_parameters"][year])

return StudySettings(
general_parameters,
optimization_parameters,
advanced_parameters,
seed_parameters,
adequacy_patch_parameters,
thematic_trimming_parameters,
playlist_parameters,
)

def to_update_settings(self) -> StudySettingsUpdate:
current_settings = asdict(self)
general_parameters = GeneralParametersUpdate(**current_settings["general_parameters"])
optimization_parameters = OptimizationParametersUpdate(**current_settings["optimization_parameters"])
advanced_parameters = AdvancedParametersUpdate(**current_settings["advanced_parameters"])
seed_parameters = SeedParametersUpdate(**current_settings["seed_parameters"])
adequacy_patch_parameters = AdequacyPatchParametersUpdate(**current_settings["adequacy_patch_parameters"])
thematic_trimming_parameters = ThematicTrimmingParametersUpdate(
**current_settings["thematic_trimming_parameters"]
)
playlist_parameters: dict[int, PlaylistParameters] = {}
for year in current_settings["playlist_parameters"]:
playlist_parameters[year] = PlaylistParameters(**current_settings["playlist_parameters"][year])

return StudySettingsUpdate(
general_parameters,
optimization_parameters,
advanced_parameters,
seed_parameters,
adequacy_patch_parameters,
thematic_trimming_parameters,
playlist_parameters,
)
98 changes: 98 additions & 0 deletions src/antares/craft/model/settings/thematic_trimming.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,104 @@

@dataclass
class ThematicTrimmingParameters:
ov_cost: bool = False
op_cost: bool = False
mrg_price: bool = False
co2_emis: bool = False
dtg_by_plant: bool = False
balance: bool = False
row_bal: bool = False
psp: bool = False
misc_ndg: bool = False
load: bool = False
h_ror: bool = False
wind: bool = False
solar: bool = False
nuclear: bool = False
lignite: bool = False
coal: bool = False
gas: bool = False
oil: bool = False
mix_fuel: bool = False
misc_dtg: bool = False
h_stor: bool = False
h_pump: bool = False
h_lev: bool = False
h_infl: bool = False
h_ovfl: bool = False
h_val: bool = False
h_cost: bool = False
unsp_enrg: bool = False
spil_enrg: bool = False
lold: bool = False
lolp: bool = False
avl_dtg: bool = False
dtg_mrg: bool = False
max_mrg: bool = False
np_cost: bool = False
np_cost_by_plant: bool = False
nodu: bool = False
nodu_by_plant: bool = False
flow_lin: bool = False
ucap_lin: bool = False
loop_flow: bool = False
flow_quad: bool = False
cong_fee_alg: bool = False
cong_fee_abs: bool = False
marg_cost: bool = False
cong_prob_plus: bool = False
cong_prob_minus: bool = False
hurdle_cost: bool = False
res_generation_by_plant: bool = False
misc_dtg_2: bool = False
misc_dtg_3: bool = False
misc_dtg_4: bool = False
wind_offshore: bool = False
wind_onshore: bool = False
solar_concrt: bool = False
solar_pv: bool = False
solar_rooft: bool = False
renw_1: bool = False
renw_2: bool = False
renw_3: bool = False
renw_4: bool = False
dens: bool = False
profit_by_plant: bool = False
sts_inj_by_plant: bool = False
sts_withdrawal_by_plant: bool = False
sts_lvl_by_plant: bool = False
psp_open_injection: bool = False
psp_open_withdrawal: bool = False
psp_open_level: bool = False
psp_closed_injection: bool = False
psp_closed_withdrawal: bool = False
psp_closed_level: bool = False
pondage_injection: bool = False
pondage_withdrawal: bool = False
pondage_level: bool = False
battery_injection: bool = False
battery_withdrawal: bool = False
battery_level: bool = False
other1_injection: bool = False
other1_withdrawal: bool = False
other1_level: bool = False
other2_injection: bool = False
other2_withdrawal: bool = False
other2_level: bool = False
other3_injection: bool = False
other3_withdrawal: bool = False
other3_level: bool = False
other4_injection: bool = False
other4_withdrawal: bool = False
other4_level: bool = False
other5_injection: bool = False
other5_withdrawal: bool = False
other5_level: bool = False
sts_cashflow_by_cluster: bool = False


@dataclass
class ThematicTrimmingParametersUpdate:
ov_cost: Optional[bool] = None
op_cost: Optional[bool] = None
mrg_price: Optional[bool] = None
Expand Down
Loading

0 comments on commit 4e91640

Please sign in to comment.