Skip to content

Commit

Permalink
Merge branch 'develop' into fix/logs-accurate-remix-hydro
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 authored Feb 20, 2025
2 parents ab57685 + 484360b commit 8ccec91
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 125 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ jobs:
continue-on-error: true
run: |
cd $GITHUB_WORKSPACE/_build
ctest -C Release --output-on-failure -L "unit"
ctest -C Release --output-on-failure -L "unit|end-to-end"
- name: Run unfeasibility-related tests
continue-on-error: true
run: |
cd _build
ctest -C Release --output-on-failure -R "^unfeasible$"
- name: Run short-tests
continue-on-error: true
Expand All @@ -154,31 +160,45 @@ jobs:
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v860
os: ${{ env.os }}
os: ${{ matrix.os }}

- name: Run tests introduced in 8.7.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v870
os: ${{ env.os }}
os: ${{ matrix.os }}

- name: Run tests introduced in 9.1.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v910
os: ${{ env.os }}
os: ${{ matrix.os }}

- name: Run tests introduced in 9.2.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v920
os: ${{ env.os }}
os: ${{ matrix.os }}

- name: Run named mps tests
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-named-mps
os: ${{ matrix.os }}
variant: "named-mps"

- name: Run cucumber on modeler
uses: ./.github/workflows/cucumber-tests
with:
feature: "features/modeler-features"

- name: Collect coverage into one XML report
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/solver/04-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ _**This section is under construction**_
- **Default value:** `false`
- **Usage:** set to `true` to activate writing the raw optimization results, that is
- For each variable, optimal values (saved in output/output-name/optimal-values-y-w--optim-nb-z.txt) and reduced costs (saved in output/output-name/reduced-costs-y-w--optim-nb-z.txt)
- each constraint, the marginal cost is saved in output/output-name/marinal-costs-y-w--optim-nb-z.txt
- each constraint, the marginal cost is saved in output/output-name/marginal-costs-y-w--optim-nb-z.txt
where y is the year number (starting from 1), w is the week number (starting from 1) and z is the optimization index (1 or 2).

This is an advanced option intended to help developers and advanced users better understand their simulation results.
Expand Down
31 changes: 18 additions & 13 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,24 @@ sonar.exclusions=src/ext/**,\
src/expressions/antlr-interface/**

sonar.coverage.exclusions=src/ext/**,\
src/tests/**,\
src/analyzer/**,\
src/distrib/**,\
src/tools/**,\
src/ui/**,\
src/libs/fswalker/**,\
src/libs/antares/cleaner/**,\
src/libs/antares/jit/**,\
src/libs/antares/sys/**,\
src/libs/antares/path/**,\
src/libs/antares/locator/**,\
src/libs/antares/correlation/**,\
src/libs/antares/antlr-interface/**
src/tests/**,\
src/analyzer/**,\
src/distrib/**,\
src/tools/**,\
src/ui/**,\
src/solver/constraints-builder/**,\
src/libs/fswalker/**,\
src/libs/antares/study/cleaner/**,\
src/libs/antares/study/finder/**,\
src/libs/antares/jit/**,\
src/libs/antares/sys/**,\
src/libs/antares/paths/**,\
src/libs/antares/locator/**,\
src/libs/antares/correlation/**,\
src/libs/antares/antlr-interface/**,\
src/libs/antares/study/ui-runtimeinfos.cpp,\
src/libs/antares/study/include/antares/study/ui-runtimeinfos.h,\
src/libs/antares/study/area/ui.cpp

sonar.coverageReportPaths=coverage.xml
sonar.cfamily.threads=4
103 changes: 0 additions & 103 deletions src/libs/antares/date/date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,109 +360,6 @@ bool StringToDayOfTheWeek(DayOfTheWeek& v, const AnyString& text)
return false;
}

bool Calendar::saveToCSVFile(const AnyString& filename) const
{
IO::File::Stream file;
if (file.openRW(filename))
{
struct
{
String::Vector hours;
String::Vector days;
String::Vector weeks;
String::Vector months;
} report;

report.hours.push_back("HOURS\t\t\t\t");
report.hours.push_back("");
report.days.push_back("DAYS\t\t\t\t\t");
report.days.push_back("");
report.weeks.push_back("WEEKS");
report.weeks.push_back("");
report.months.push_back("MONTHSi\t\t\t\t\t");
report.months.push_back("");

String line;

line.clear() << "weekday\tday year\tday month\tmonth\tweek";
report.hours.push_back(line);

for (uint h = 0; h != maxHoursInYear; ++h)
{
auto& hour = hours[h];
line.clear();
line << (uint)hour.weekday << '\t';
line << hour.dayYear << '\t';
line << hour.dayMonth << '\t';
line << hour.month << '\t';
line << hour.week;
report.hours.push_back(line);
}

line.clear() << "weekday\thour begin\thour end\tmonth\tday month\tweek";
report.days.push_back(line);

for (uint h = 0; h != maxDaysInYear; ++h)
{
auto& day = days[h];
line.clear();
line << (uint)day.weekday << '\t';
line << day.hours.first << '\t';
line << day.hours.end << '\t';
line << day.month << '\t';
line << day.dayMonth << '\t';
line << day.week;
report.days.push_back(line);
}

line.clear() << "week";
report.days.push_back(line);

for (uint h = 0; h != maxDaysInYear; ++h)
{
line.clear();
report.days.push_back(line);
}

line.clear() << "hour begin\thour end\tdays\tday uear begin\tday year end\tfirst weekday";
report.months.push_back(line);

for (uint m = 0; m != MONTHS_PER_YEAR; ++m)
{
auto& month = months[m];
line.clear();
line << month.hours.first << '\t';
line << month.hours.end << '\t';
line << month.days << '\t';
line << month.daysYear.first << '\t';
line << month.daysYear.end << '\t';
line << (uint)month.firstWeekday;

report.months.push_back(line);
}

for (uint i = 0; i < report.hours.size(); ++i)
{
file << report.hours[i] << '\t';
if (i < report.days.size())
{
file << report.days[i] << '\t';
}
if (i < report.weeks.size())
{
file << report.weeks[i] << '\t';
}
if (i < report.months.size())
{
file << report.months[i] << '\t';
}
file << '\n';
}
return true;
}
return false;
}

Calendar::Calendar()
{
settings_.weekday1rstJanuary = monday;
Expand Down
4 changes: 4 additions & 0 deletions src/libs/antares/resources/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace Antares
{
namespace Resources
{
// TODO VP: delete with GUI
bool FindFile(Yuni::String& out, const AnyString& filename)
{
if (not filename.empty())
Expand All @@ -67,11 +68,13 @@ bool FindFile(Yuni::String& out, const AnyString& filename)
return false;
}

// TODO VP: delete with GUI
void GetRootFolder(Yuni::String& out)
{
out = RootFolder;
}

// TODO VP: delete with GUI
bool FindExampleFolder(Yuni::String& folder)
{
// Temporary string
Expand Down Expand Up @@ -184,6 +187,7 @@ void Initialize(int argc, const char** argv, bool initializeSearchPath)
}
}

// TODO VP: delete with GUI
bool FindFirstOf(String& out, const char* const* const list)
{
String tmp;
Expand Down
6 changes: 3 additions & 3 deletions src/libs/antares/study/include/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Parameters final
*/
bool loadFromFile(const std::filesystem::path& filename, const StudyVersion& version);

//! Load data from an INI file
bool loadFromINI(const IniFile& ini, const StudyVersion& version);

/*!
** \brief Prepare all settings for a simulation
**
Expand Down Expand Up @@ -507,9 +510,6 @@ class Parameters final
Antares::Solver::Optimization::OptimizationOptions optOptions;

private:
//! Load data from an INI file
bool loadFromINI(const IniFile& ini, const StudyVersion& version);

void resetPlayedYears(uint nbOfYears);

//! MC year weight for MC synthesis
Expand Down
1 change: 1 addition & 0 deletions src/libs/antares/study/parts/thermal/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ uint ThermalCluster::groupId() const
return groupID;
}

// TODO VP: delete with GUI
void Data::ThermalCluster::copyFrom(const ThermalCluster& cluster)
{
// Note: In this method, only the data can be copied (and not the name or
Expand Down
9 changes: 9 additions & 0 deletions src/tests/end-to-end/simple_study/simple-study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,13 @@ BOOST_FIXTURE_TEST_CASE(scenario_builder, HydroMaxPowerStudy)
tt::tolerance(0.1));
}

BOOST_FIXTURE_TEST_CASE(saving_study, HydroMaxPowerStudy)
{
auto enabledCluster = std::make_shared<ThermalCluster>(area);
enabledCluster->setName("Cluster1");
enabledCluster->enabled = true;
area->thermal.list.addToCompleteList(enabledCluster);

BOOST_CHECK(study->saveToFolder(std::filesystem::temp_directory_path().string()));
}
BOOST_AUTO_TEST_SUITE_END()
20 changes: 20 additions & 0 deletions src/tests/src/libs/antares/study/parameters/parameters-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ BOOST_FIXTURE_TEST_CASE(hydroPmax, Fixture)
BOOST_CHECK(!StringToCompatibilityHydroPmax(p.compatibility.hydroPmax, "abc"));
}

BOOST_AUTO_TEST_CASE(saveLoadGeneralData)
{
IniFile ini;
Parameters parameters;
parameters.reset();
parameters.timeSeriesToGenerate = timeSeriesLoad | timeSeriesHydro | timeSeriesWind
| timeSeriesThermal | timeSeriesSolar | timeSeriesRenewable;

parameters.timeSeriesToRefresh = parameters.timeSeriesToGenerate;
parameters.resultFormat = zipArchive;

parameters.saveToINI(ini);

Parameters loaded;
loaded.loadFromINI(ini, StudyVersion::latest());
BOOST_CHECK_EQUAL(parameters.timeSeriesToGenerate, loaded.timeSeriesToGenerate);
BOOST_CHECK_EQUAL(parameters.timeSeriesToRefresh, loaded.timeSeriesToRefresh);
BOOST_CHECK_EQUAL(parameters.resultFormat, loaded.resultFormat);
}

BOOST_AUTO_TEST_SUITE_END()

void Fixture::writeInvalidFile()
Expand Down

0 comments on commit 8ccec91

Please sign in to comment.