Antares Simulator
Power System Simulator
parameters.h
1 /*
2 ** Copyright 2007-2025, RTE (https://www.rte-france.com)
3 ** See AUTHORS.txt
4 ** SPDX-License-Identifier: MPL-2.0
5 ** This file is part of Antares-Simulator,
6 ** Adequacy and Performance assessment for interconnected energy networks.
7 **
8 ** Antares_Simulator is free software: you can redistribute it and/or modify
9 ** it under the terms of the Mozilla Public Licence 2.0 as published by
10 ** the Mozilla Foundation, either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** Antares_Simulator is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** Mozilla Public Licence 2.0 for more details.
17 **
18 ** You should have received a copy of the Mozilla Public Licence 2.0
19 ** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20 */
21 #ifndef __ANTARES_LIBS_STUDY_PARAMETERS_H__
22 #define __ANTARES_LIBS_STUDY_PARAMETERS_H__
23 
24 #include <cassert>
25 #include <cstdlib>
26 #include <vector>
27 
28 #include <yuni/yuni.h>
29 #include <yuni/core/string.h>
30 
31 #include <antares/date/date.h>
32 #include <antares/inifile/inifile.h>
33 #include <antares/optimization-options/options.h>
34 #include <antares/study/UnfeasibleProblemBehavior.hpp>
35 #include <antares/writer/result_format.h>
36 #include "antares/antares/antares.h"
37 #include "antares/study/fwd.h"
38 
39 #include "parameters/adq-patch-params.h"
40 #include "variable-print-info.h"
41 #include "version.h"
42 
43 namespace Antares::Data
44 {
50 class Parameters final
51 {
52 public:
54 
55  bool economy() const;
58  bool adequacy() const;
60 
64  void resetPlaylist(uint nbOfYears);
65 
78  bool loadFromFile(const std::filesystem::path& filename, const StudyVersion& version);
79 
81  bool loadFromINI(const IniFile& ini, const StudyVersion& version);
82 
96  void prepareForSimulation(const StudyLoadOptions& options);
97 
104  bool saveToFile(const AnyString& filename) const;
105 
112  bool isTSGeneratedByPrepro(const TimeSeriesType ts) const;
113 
117  void reset();
121  void resetSeeds();
122 
126  void fixBadValues();
127 
128  void validateOptions(const StudyLoadOptions&);
129 
134  void fixGenRefreshForNTC();
135 
139  void resetYearsWeigth();
140 
146  std::vector<float> getYearsWeight() const;
147 
154  float getYearsWeightSum() const;
155 
162  void setYearWeight(uint year, float weight);
163 
164  // Do we create files in the input folder ?
165  bool haveToImport(int tsKind) const;
166 
168  void saveToINI(IniFile& ini) const;
169 
170 public:
172 
173  SimulationMode mode;
176 
178 
179  Yuni::String horizon;
182 
184 
185  uint nbYears;
190  DayOfTheWeek dayOfThe1stJanuary;
192  DayOfTheWeek firstWeekday;
194  MonthName firstMonthInYear;
196  bool leapYear;
198 
200 
201  bool yearByYear;
204  bool derated;
210  std::vector<bool> yearsFilter;
211 
216 
218  // Computed automatically from the number of MC years and the playlist
226 
228 
229  uint nbTimeSeriesLoad;
240 
242 
243 
252 
254 
255 
263 
265 
266 
275 
277 
278 
286 
292 
294 
298 
305  bool readonly;
306 
308  bool synthesis;
309 
312 
314 
316 
318  {
323 
324  struct Reserve
325  {
327  bool dayAhead;
329  bool strategic;
331  bool spinning;
333  bool primary;
334 
335  } reserve;
336 
337  struct Thermal
338  {
339  // Thermal cluster min stable power
340  bool minStablePower;
341 
343  bool minUPTime;
344  } thermal;
345 
347  mpsExportStatus exportMPS;
348 
351 
353  UnfeasibleProblemBehavior unfeasibleProblemBehavior;
354 
355  bool exportSolutions;
356  } include;
357 
359  {
360  enum class HydroPmax
361  {
362  Daily,
363  Hourly
364  };
365  HydroPmax hydroPmax = HydroPmax::Daily;
366  };
367 
368  Compatibility compatibility;
369 
370  // Shedding
371  struct
372  {
374  SheddingPolicy policy;
375  } shedding;
376 
377  struct
378  {
380  PowerFluctuations fluctuations;
381  } power;
382 
383  struct UCMode
384  {
386  UnitCommitmentMode ucMode;
387 
389  void addExcludedVariables(std::vector<std::string>&) const;
390  };
391 
392  UCMode unitCommitment;
393 
394  struct
395  {
397  NumberOfCoresMode ncMode;
398  } nbCores;
399 
401  {
403  RenewableGenerationModelling rgModelling;
404  void addExcludedVariables(std::vector<std::string>&) const;
405  RenewableGenerationModelling operator()() const;
406  void toAggregated();
407  void toClusters();
408  bool isAggregated() const;
409  bool isClusters() const;
410  };
411 
412  RenewableGeneration renewableGeneration;
413 
414  struct
415  {
417  HydroHeuristicPolicy hhPolicy;
418  } hydroHeuristicPolicy;
419 
420  struct
421  {
423  HydroPricingMode hpMode;
424  } hydroPricing;
425 
426  bool accurateShavePeaksIncludeShortTermStorage = false;
427 
429  GlobalTransmissionCapacities transmissionCapacities;
431  SimplexOptimization simplexOptimizationRange;
433 
434  AdequacyPatch::AdqPatchParams adqPatchParams;
435 
437 
438  RulesScenarioName activeRulesScenario;
441 
443 
444  // This variable is not stored within the study but only used by the solver
446  bool noOutput = false;
448 
449  bool hydroDebug;
450 
452  bool remixStorageDebug = false;
453 
455 
456  uint seed[seedMax];
459 
460  // Format of results. Currently, only single files or zip archive are supported
461  ResultFormat resultFormat = legacyFilesDirectories;
462 
463  // Naming constraints and variables in problems
464  bool namedProblems;
465 
466  // All options related to linear & quadratic optimization
468 
469 private:
470  void resetPlayedYears(uint nbOfYears);
471 
473  std::vector<float> yearsWeight;
474 
475 }; // class Parameters
476 
480 const char* SimulationModeToCString(SimulationMode mode);
481 
489 bool StringToSimulationMode(SimulationMode& mode, Yuni::CString<20, false> text);
490 
491 const char* CompatibilityHydroPmaxToCString(const Parameters::Compatibility::HydroPmax);
492 bool StringToCompatibilityHydroPmax(Parameters::Compatibility::HydroPmax&, const std::string& text);
493 
494 } // namespace Antares::Data
495 
496 #endif // __ANTARES_LIBS_STUDY_PARAMETERS_H__
Definition: variable-print-info.h:95
General data for a study.
Definition: parameters.h:51
bool readonly
Read-only mode.
Definition: parameters.h:305
PowerFluctuations fluctuations
Power fluctuations.
Definition: parameters.h:380
uint nbTimeSeriesLoad
Nb of timeSeries : Load.
Definition: parameters.h:230
bool leapYear
Leap year.
Definition: parameters.h:196
DayOfTheWeek firstWeekday
First day in the week.
Definition: parameters.h:192
std::vector< float > getYearsWeight() const
Get MC years weight dependending on playlist configuration.
Definition: parameters.cpp:1390
uint timeSeriesToArchive
TimeSeries to archive.
Definition: parameters.h:250
GlobalTransmissionCapacities transmissionCapacities
Transmission capacities.
Definition: parameters.h:429
uint exportTimeSeriesInInput
TimeSeries to Import.
Definition: parameters.h:273
void prepareForSimulation(const StudyLoadOptions &options)
Prepare all settings for a simulation.
Definition: parameters.cpp:1442
HydroHeuristicPolicy hhPolicy
Hydro heuristic policy.
Definition: parameters.h:417
bool saveToFile(const AnyString &filename) const
Save data to an ini file.
Definition: parameters.cpp:1943
bool noOutput
No output.
Definition: parameters.h:446
void fixBadValues()
Try to detect then fix any bad value.
Definition: parameters.cpp:1293
HydroPricingMode hpMode
Hydro Pricing Mode.
Definition: parameters.h:423
AllVariablesPrintInfo variablesPrintInfo
List of all output variables print info.
Definition: parameters.h:215
uint effectiveNbYears
The number of years that will be really performed.
Definition: parameters.h:219
uint nbTimeSeriesHydro
Nb of timeSeries : Hydro.
Definition: parameters.h:232
bool geographicTrimming
Definition: parameters.h:224
bool derated
Derated.
Definition: parameters.h:204
NumberOfCoresMode ncMode
Number of Cores Mode.
Definition: parameters.h:397
Yuni::String horizon
Horizon year, not used by the solver.
Definition: parameters.h:180
bool isTSGeneratedByPrepro(const TimeSeriesType ts) const
Get if a time-series must be generated by the preprocessor.
Definition: parameters.cpp:377
uint nbTimeSeriesThermal
Nb of timeSeries : Thermal.
Definition: parameters.h:236
Date::DayInterval simulationDays
Simulation days interval.
Definition: parameters.h:188
bool synthesis
Write the simulation synthesis into the output.
Definition: parameters.h:308
bool yearByYear
Export results each year.
Definition: parameters.h:202
RulesScenarioName activeRulesScenario
The current active rules for building scenarios (useful if building mode == custom)
Definition: parameters.h:439
void resetSeeds()
Reset to default all seeds.
Definition: parameters.cpp:248
SimplexOptimization simplexOptimizationRange
Simplex optimization range (day/week)
Definition: parameters.h:431
SimulationMode mode
Mode of the study (adequacy, economy...)
Definition: parameters.h:174
uint timeSeriesToGenerate
TimeSeries to generate.
Definition: parameters.h:261
bool loadFromFile(const std::filesystem::path &filename, const StudyVersion &version)
Load data from a file.
Definition: parameters.cpp:1926
uint nbTimeSeriesSolar
Nb of timeSeries : Solar.
Definition: parameters.h:238
void setYearWeight(uint year, float weight)
Define weight for a MC year.
Definition: parameters.cpp:1436
void fixGenRefreshForNTC()
Try to detect then fix TS generation/refresh parameters for NTC.
Definition: parameters.cpp:1277
void resetYearsWeigth()
Reset MC year weight to 1 for all years.
Definition: parameters.cpp:1384
void reset()
Reset to default all values in a structure for general data.
Definition: parameters.cpp:275
uint interModal
Inter-modal.
Definition: parameters.h:290
uint seed[seedMax]
Seeds.
Definition: parameters.h:457
bool thematicTrimming
Custom variable selection (each variable will be manually selected for print by the user)
Definition: parameters.h:213
MonthName firstMonthInYear
The first month of the simulation year.
Definition: parameters.h:194
DayOfTheWeek dayOfThe1stJanuary
Day of the 1st january.
Definition: parameters.h:190
void resetPlaylist(uint nbOfYears)
Reset the playlist (played years and associated years)
Definition: parameters.cpp:1688
uint timeSeriesAccuracyOnCorrelation
Accuracy on correlation.
Definition: parameters.h:311
bool storeTimeseriesNumbers
Store the sampled timeseries numbers.
Definition: parameters.h:296
std::vector< bool > yearsFilter
Flag to perform the calculations or not from the solver.
Definition: parameters.h:210
bool userPlaylist
Custom playlist (each year will be manually selected by the user)
Definition: parameters.h:208
bool useCustomScenario
Custom scenario.
Definition: parameters.h:206
bool remixStorageDebug
Used to create debug informations for both hydro and short term storages.
Definition: parameters.h:452
bool economy() const
Get if the simulation is in economy mode.
Definition: parameters.cpp:238
void saveToINI(IniFile &ini) const
Save the internal settings into an INI file.
Definition: parameters.cpp:1694
uint nbTimeSeriesWind
Nb of timeSeries : Wind.
Definition: parameters.h:234
float getYearsWeightSum() const
Get MC years weight sum dependending on playlist configuration.
Definition: parameters.cpp:1406
uint intraModal
TimeSeries where the draws are correlated.
Definition: parameters.h:285
SheddingPolicy policy
Shedding policy.
Definition: parameters.h:374
bool adequacy() const
Get if the simulation is in adequacy mode.
Definition: parameters.cpp:243
bool loadFromINI(const IniFile &ini, const StudyVersion &version)
Load data from an INI file.
Definition: parameters.cpp:1199
uint nbYears
Number of years to study.
Definition: parameters.h:186
Definition: load-options.h:34
Version of a study.
Definition: version.h:36
Data for an INI file.
Definition: inifile.h:34
Definition: adq-patch-params.h:114
Definition: parameters.h:359
bool dayAhead
Day ahead reserve.
Definition: parameters.h:327
bool strategic
Strategic reserve.
Definition: parameters.h:329
bool spinning
Spinning reserve.
Definition: parameters.h:331
bool primary
Primary reserve.
Definition: parameters.h:333
bool minUPTime
Thermal cluster Min U/D Time.
Definition: parameters.h:343
Definition: parameters.h:318
mpsExportStatus exportMPS
Flag to export mps files.
Definition: parameters.h:347
bool hurdleCosts
Hurdle costs.
Definition: parameters.h:322
UnfeasibleProblemBehavior unfeasibleProblemBehavior
Enum to define unfeasible problem behavior.
Definition: parameters.h:353
bool constraints
Include binding constraints.
Definition: parameters.h:320
bool exportStructure
a flag to export structure needed for Antares XPansion
Definition: parameters.h:350
RenewableGenerationModelling rgModelling
Renewable generation mode.
Definition: parameters.h:403
Definition: parameters.h:384
void addExcludedVariables(std::vector< std::string > &) const
Some variables rely on dual values & marginal costs.
Definition: parameters.cpp:2006
UnitCommitmentMode ucMode
Unit Commitment Mode.
Definition: parameters.h:386
Definition: date.h:164