Skip to content

Commit

Permalink
Merge branch 'develop' into feature/resize
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 authored Jun 25, 2024
2 parents a728e85 + b6d8240 commit 2e05cb5
Show file tree
Hide file tree
Showing 99 changed files with 2,300 additions and 1,679 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ jobs:
os: ${{ env.os }}
variant: "parallel"

- name: Run tests for time series generator tool
if: ${{ env.RUN_SIMPLE_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{steps.simtest-version.outputs.prop}}
batch-name: ts-generator
os: ${{ env.os }}
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/windows-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ jobs:
os: ${{ env.test-platform }}
variant: "parallel"

- name: Run tests for time series generator tool
if: ${{ env.RUN_SIMPLE_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{steps.simtest-version.outputs.prop}}
batch-name: ts-generator
os: ${{ env.test-platform }}
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
Expand Down Expand Up @@ -304,7 +313,7 @@ jobs:
run: |
cd _build
cpack -G ZIP
- name: Installer upload
uses: actions/upload-artifact@v4
with:
Expand Down
25 changes: 25 additions & 0 deletions docs/user-guide/04-migration-guides.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Migration guides
This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts.

## v9.2.0
### (TS-generator only) TS generation for link capacities
In files input/links/<link1>/properties.ini, add the following properties
- tsgen_direct_XXX,
- tsgen_indirect_XXX
with XXX in
- unitcount (unsigned int, default 1)
- nominalcapacity (float)
- law.planned (string "uniform"/"geometric")
- law.forced (same)
- volatility.planned (double in [0,1])
- volatility.forced (same)

- "prepro" timeseries => input/links/<link 1>/prepro/<link 2>_{direct, indirect}.txt, 365x6 values, respectively "forced outage duration", "planned outage duration", "forced outage rate", "planned outage rate", "minimum of groups in maintenance", "maximum of groups in maintenance".
- "modulation" timeseries => input/links/<link 1>/prepro/<link 2>_mod_{direct, indirect}.txt, 8760x1 values each in [0, 1]
- number of TS to generate => generaldata.ini/General/nbtimeserieslinks (unsigned int, default value 1)



## v9.1.0
### Input
#### Hydro Maximum Generation/Pumping Power
Expand Down Expand Up @@ -109,6 +129,10 @@ For each thermal cluster, in existing file **input/thermal/clusters/&lt;area&gt;

For each thermal cluster, new files added **input/thermal/series/&lt;area&gt;/&lt;cluster&gt;/CO2Cost.txt** and **input/thermal/series/&lt;area&gt;/&lt;cluster&gt;/fuelCost.txt**. **fuelCost.txt** and **CO2Cost.txt** must either have one column, or the same number of columns as existing file **series.txt** (availability). The number of rows for these new matrices is 8760.

#### Hydro Final Reservoir Level
In the existing file **settings/scenariobuilder.dat**, under **&lt;ruleset&gt;** section following properties added (if final reservoir level specified, different from `init`):
* **hfl,&lt;area&gt;,&lt;year&gt; = &lt;hfl-value&gt;**

### Output
#### Scenarized RHS for binding constraints
Add directory **bindingconstraints** to output directory **ts-numbers**. For every binding constraint group, add a file **ts-numbers/bindingconstraints/&lt;group&gt;.txt** containing the TS numbers used for that group.
Expand Down Expand Up @@ -166,6 +190,7 @@ In file **settings/generaldata.ini**, in section `adequacy patch`, add propertie
* `price-taking-order` [string] can take values `DENS` (default value) and `Load`.
* `include-hurdle-cost-csr` [bool]. Default value = `false`
* `check-csr-cost-function` [bool]. Default value = `false`
* `recompute-dtg-mrg` [bool]. Default value = `false`
* `threshold-initiate-curtailment-sharing-rule` [double]. Default value = `0.0`
* `threshold-display-local-matching-rule-violations` [double]. Default value = `0.0`
* `threshold-csr-variable-bounds-relaxation` [int]. Default value = `3`
Expand Down
3 changes: 1 addition & 2 deletions docs/user-guide/solver/04-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ _**This section is under construction**_
These parameters are listed under the `[other preferences]` section in the `.ini` file.

---
#### initial-reservoir-levels
[//]: # (TODO: complete the usage paragraph)
#### initial-reservoir-levels (DEPRECATED since 9.2: cold start is default behavior)
- **Expected value:** one of the following (case-insensitive):
- `cold start`
- `hot start`
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/solver/06-hydro-heuristics.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,6 @@ $$V_t^- + S_t \geq \underline{S_t}$$

$$Y - V_t^- \geq 0$$

[^monthly_allocation]: In the first equation, $S_{t-1}$ is either the initial stock $S_0$ or the final stock of the previous year (hydro hot start)
[^monthly_allocation]: In the first equation, $S_{t-1}$ is equal to initial stock $S_0$

[^daily_allocation]: In the first equation, $S_{t-1}$ is either the initial stock used in M or the final stock of the previous month ($D(m-1)$)
6 changes: 3 additions & 3 deletions docs/user-guide/solver/09-appendix.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ With `..._MPS` options, the full expression of the faulty problem(s) is printed
thus allowing further analysis of the infeasibility issue.


## Details on the "initial-reservoir-levels" parameter
[//]: # (TODO: update this paragraph)
_**This section is under construction**_
## Details on the "initial-reservoir-levels" parameter (DEPRECATED since 9.2)

### version 9.2: The reservoir level is now always determined with cold start behavior.

This parameter can take the two values "cold start" or "hot start". [default: cold start]. Simulations results may in some circumstances be heavily impacted by this setting, hence proper attention should be paid to its meaning before considering changing the default value.

Expand Down
2 changes: 1 addition & 1 deletion simtest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v9.1.0-rc5"
"version": "v9.2.0a"
}
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(ANTARES_VERSION_HI 9)
set(ANTARES_VERSION_LO 1)
set(ANTARES_VERSION_REVISION 0)


# Beta release
set(ANTARES_BETA 0)
set(ANTARES_RC 0)
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/common-settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (NOT WIN32)
set(COMMON_GCC_FLAGS "${COMMON_GCC_FLAGS} -Werror=return-type")
endif()
set(COMMON_MSVC_FLAGS "/W3 /MP4")
set(COMMON_MSVC_FLAGS "${COMMON_MSVC_FLAGS} /we4715 /we4716 /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR") #adding no return or no return for all code paths as errors
set(COMMON_MSVC_FLAGS "${COMMON_MSVC_FLAGS} /we4715 /we4716") #adding no return or no return for all code paths as errors
set(ADDITIONAL_C_FLAGS " -Wconversion -Wmissing-prototypes -Wstrict-prototypes")
set(ADDITIONAL_C_FLAGS "${ADDITIONAL_C_FLAGS} -Wmissing-noreturn -Wpacked -Wredundant-decls -Wbad-function-cast -W -Wcast-align -Wcast-qual -Wsign-compare -fno-exceptions -Wdeclaration-after-statement")

Expand Down
12 changes: 8 additions & 4 deletions src/libs/antares/inifile/inifile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ void IniFile::Section::saveToStream(std::ostream& stream_out, uint64_t& written)
stream_out << '[' << name << "]\n";
written += 4 /* []\n\n */ + name.size();

each([&](const IniFile::Property& p) { p.saveToStream(stream_out, written); });
each([&stream_out, &written](const IniFile::Property& p) {
p.saveToStream(stream_out, written);
});

stream_out << '\n';
}
Expand Down Expand Up @@ -168,9 +170,9 @@ static std::string getSectionName(const std::string& line)
return splitLine[1];
}

static bool isProperty(const std::string& line)
static bool isProperty(std::string_view line)
{
return std::ranges::count(line.begin(), line.end(), '=') == 1;
return std::ranges::count(line, '=') == 1;
}

static IniFile::Property getProperty(std::string line)
Expand Down Expand Up @@ -264,7 +266,9 @@ bool IniFile::open(const fs::path& filename, bool warnings)

void IniFile::saveToStream(std::ostream& stream_out, uint64_t& written) const
{
each([&](const IniFile::Section& s) {s.saveToStream(stream_out, written); });
each([&stream_out, &written](const IniFile::Section& s) {
s.saveToStream(stream_out, written);
});

if (written != 0)
{
Expand Down
2 changes: 2 additions & 0 deletions src/libs/antares/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ set(SRC_STUDY_PART_HYDRO
include/antares/study/parts/hydro/allocation.h
include/antares/study/parts/hydro/allocation.hxx
parts/hydro/allocation.cpp
include/antares/study/parts/hydro/finalLevelValidator.h
parts/hydro/finalLevelValidator.cpp
include/antares/study/parts/hydro/hydromaxtimeseriesreader.h
parts/hydro/hydromaxtimeseriesreader.cpp
)
Expand Down
12 changes: 4 additions & 8 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,20 @@ void Area::internalInitialize()

Area::Area():
reserves(fhrMax, HOURS_PER_YEAR),
miscGen(fhhMax, HOURS_PER_YEAR)
miscGen(fhhMax, HOURS_PER_YEAR),
hydro(*this)
{
internalInitialize();
}

Area::Area(const AnyString& name):
reserves(fhrMax, HOURS_PER_YEAR),
miscGen(fhhMax, HOURS_PER_YEAR)
Area::Area(const AnyString& name) : Area()
{
internalInitialize();
this->name = name;
this->id = Antares::transformNameIntoID(this->name);
}

Area::Area(const AnyString& name, const AnyString& id):

reserves(fhrMax, HOURS_PER_YEAR),
miscGen(fhhMax, HOURS_PER_YEAR)
Area::Area(const AnyString& name, const AnyString& id) : Area()
{
internalInitialize();
this->name = name;
Expand Down
106 changes: 104 additions & 2 deletions src/libs/antares/study/area/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

#include "antares/study/area/links.h"

#include <filesystem>
#include <limits>

#include <boost/algorithm/string/case_conv.hpp>

#include <yuni/yuni.h>

#include <antares/exception/LoadingError.hpp>
Expand Down Expand Up @@ -134,6 +137,58 @@ bool AreaLink::linkLoadTimeSeries_for_version_820_and_later(const AnyString& fol
return success;
}

// This function is "lazy", it only loads files if they exist
// and set a `valid` flag
bool AreaLink::loadTSGenTimeSeries(const fs::path& folder)
{
const std::string idprepro = std::string(from->id) + "/" + std::string(with->id);
tsGeneration.prepro =
std::make_unique<Data::PreproAvailability>(idprepro, tsGeneration.unitCount);

bool anyFileWasLoaded = false;

// file name without suffix, .txt for general infos and mod_direct/indirect.txt
fs::path preproFile = folder / "prepro" / with->id.c_str();

// Prepro
fs::path filepath = preproFile;
filepath += ".txt";
if (fs::exists(filepath))
{
anyFileWasLoaded = true;
tsGeneration.valid = tsGeneration.prepro->data.loadFromCSVFile(
filepath.string(),
Antares::Data::PreproAvailability::preproAvailabilityMax,
DAYS_PER_YEAR)
&& tsGeneration.prepro->validate();
}

// Modulation
filepath = preproFile;
filepath += "_mod_direct.txt";
if (fs::exists(filepath))
{
anyFileWasLoaded = true;
tsGeneration.valid &= tsGeneration.modulationCapacityDirect
.loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR);
}

filepath = preproFile;
filepath += "_mod_indirect.txt";
if (fs::exists(filepath))
{
anyFileWasLoaded = true;
tsGeneration.valid &= tsGeneration.modulationCapacityIndirect
.loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR);
}

if (anyFileWasLoaded)
{
return tsGeneration.valid;
}
return true;
}

bool AreaLink::isLinkPhysical() const
{
// All link types are physical, except arVirt
Expand Down Expand Up @@ -448,13 +503,55 @@ bool handleKey(Data::AreaLink& link, const String& key, const String& value)
link.filterYearByYear = stringIntoDatePrecision(value);
return true;
}
return false;
}

bool handleTSGenKey(Data::LinkTsGeneration& out,
const std::string& key,
const String& value)
{

if (key == "unitcount")
{
return value.to<uint>(out.unitCount);
}

if (key == "nominalcapacity")
{
return value.to<double>(out.nominalCapacity);
}

if (key == "law.planned")
{
return value.to(out.plannedLaw);
}

if (key == "law.forced")
{
return value.to(out.forcedLaw);
}

if (key == "volatility.planned")
{
return value.to(out.plannedVolatility);
}

if (key == "volatility.forced")
{
return value.to(out.forcedVolatility);
}

if (key == "force-no-generation")
{
return value.to<bool>(out.forceNoGeneration);
}

return false;
}

bool AreaLinksInternalLoadFromProperty(AreaLink& link, const String& key, const String& value)
{
return handleKey(link, key, value);
return handleKey(link, key, value) || handleTSGenKey(link.tsGeneration, key, value);
}

[[noreturn]] void logLinkDataCheckError(const AreaLink& link, const String& msg, int hour)
Expand All @@ -475,7 +572,7 @@ bool AreaLinksInternalLoadFromProperty(AreaLink& link, const String& key, const
}
} // anonymous namespace

bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::path& folder)
bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::path& folder, bool loadTSGen)
{
// Assert
assert(area);
Expand Down Expand Up @@ -601,6 +698,11 @@ bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::pa
}
}

if (loadTSGen)
{
ret = link.loadTSGenTimeSeries(folder) && ret;
}

// From the solver only
if (study.usedByTheSolver)
{
Expand Down
Loading

0 comments on commit 2e05cb5

Please sign in to comment.