Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/develop' into feature/ne…
Browse files Browse the repository at this point in the history
…w-hydro-remix
  • Loading branch information
guilpier-code committed Jan 7, 2025
2 parents 237940e + 4a30c44 commit 47af157
Show file tree
Hide file tree
Showing 154 changed files with 5,487 additions and 1,650 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ jobs:
cd _build
ctest -C Release --output-on-failure -L "unit|end-to-end"
- name: Upload logs for failed tests
if: ${{ failure() }}
uses: actions/upload-artifact@v4
Expand All @@ -195,6 +196,23 @@ jobs:
variant: "milp-cbc"
os: ${{ env.os }}

- name: Run tests on adequacy patch (CSR)
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: adequacy-patch-CSR
os: ${{ env.os }}

- name: Run parallel tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-parallel
os: ${{ env.os }}
variant: "parallel"

- name: Run tests introduced in 8.6.0
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
Expand Down Expand Up @@ -248,14 +266,6 @@ jobs:
batch-name: valid-mps
os: ${{ env.os }}

- name: Run tests for adequacy patch (CSR)
if: ${{ env.RUN_SIMPLE_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: adequacy-patch-CSR
os: ${{ env.os }}

- name: Run parallel tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' && !cancelled() }}
uses: ./.github/workflows/run-tests
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.2.0g"
"version": "v9.2.0h"
}
21 changes: 21 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
#
# Copyright 2007-2024, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# SPDX-License-Identifier: MPL-2.0
# This file is part of Antares-Simulator,
# Adequacy and Performance assessment for interconnected energy networks.
#
# Antares_Simulator is free software: you can redistribute it and/or modify
# it under the terms of the Mozilla Public Licence 2.0 as published by
# the Mozilla Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Antares_Simulator is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Mozilla Public Licence 2.0 for more details.
#
# You should have received a copy of the Mozilla Public Licence 2.0
# along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
#

sonar.projectName=Antares_Simulator
sonar.projectKey=AntaresSimulatorTeam_Antares_Simulator
sonar.organization=antaressimulatorteam
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ set(ANTARES_VERSION_HI 9)
set(ANTARES_VERSION_LO 2)
set(ANTARES_VERSION_REVISION 0)


# Beta release
set(ANTARES_BETA 0)
set(ANTARES_RC 7)
set(ANTARES_RC 8)

set(ANTARES_VERSION_YEAR 2024)

Expand Down Expand Up @@ -192,6 +191,7 @@ endif()
find_package(Boost REQUIRED)

find_package(antlr4-runtime REQUIRED)
find_package(yaml-cpp REQUIRED)

#Sirius solver
if(POLICY CMP0074)
Expand Down
21 changes: 15 additions & 6 deletions src/api/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Antares::API
{
SimulationResults APIInternal::run(
const IStudyLoader& study_loader,
const std::filesystem::path& output,
const Antares::Solver::Optimization::OptimizationOptions& optOptions)
{
try
Expand All @@ -43,9 +44,9 @@ SimulationResults APIInternal::run(
catch (const ::Antares::Error::StudyFolderDoesNotExist& e)
{
Antares::API::Error err{.reason = e.what()};
return {.simulationPath = "", .antares_problems = {}, .error = err};
return {.antares_problems = {}, .error = err};
}
return execute(optOptions);
return execute(output, optOptions);
}

/**
Expand All @@ -56,14 +57,15 @@ SimulationResults APIInternal::run(
* dupllication
*/
SimulationResults APIInternal::execute(
const std::filesystem::path& output,
const Antares::Solver::Optimization::OptimizationOptions& optOptions) const
{
// study_ == nullptr e.g when the -h flag is given
if (!study_)
{
using namespace std::string_literals;
Antares::API::Error err{.reason = "Couldn't create study"s};
return {.simulationPath{}, .antares_problems{}, .error = err};
return {.antares_problems{}, .error = err};
}

Settings settings;
Expand All @@ -75,10 +77,19 @@ SimulationResults APIInternal::execute(
auto ioQueueService = std::make_shared<Yuni::Job::QueueService>();
ioQueueService->maximumThreadCount(1);
ioQueueService->start();

study_->folderOutput = output;
auto resultWriter = Solver::resultWriterFactory(parameters.resultFormat,
study_->folderOutput,
ioQueueService,
durationCollector);

// In some cases (e.g tests) we don't want to write anything
if (!output.empty())
{
study_->saveAboutTheStudy(*resultWriter);
}

SimulationObserver simulationObserver;

optimizationInfo = simulationRun(*study_,
Expand All @@ -90,8 +101,6 @@ SimulationResults APIInternal::execute(
// Importing Time-Series if asked
study_->importTimeseriesIntoInput();

return {.simulationPath = study_->folderOutput,
.antares_problems = simulationObserver.acquireLps(),
.error{}};
return {.antares_problems = simulationObserver.acquireLps(), .error{}};
}
} // namespace Antares::API
10 changes: 4 additions & 6 deletions src/api/include/antares/api/SimulationResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <filesystem>
#include <optional>
#include <string>

#include "antares/solver/lps/LpsFromAntares.h"

namespace Antares::API
Expand All @@ -31,7 +32,8 @@ namespace Antares::API
* @struct Error
* @brief The Error structure is used to represent an error that occurred during the simulation.
*/
struct Error {
struct Error
{
/**
* @brief The reason for the error.
*/
Expand All @@ -45,10 +47,6 @@ struct Error {
*/
struct [[nodiscard("Contains results and potential error")]] SimulationResults
{
/**
* @brief The path to the simulation (output).
*/
std::filesystem::path simulationPath;
/**
* @brief weekly problems
*/
Expand All @@ -59,4 +57,4 @@ struct [[nodiscard("Contains results and potential error")]] SimulationResults
std::optional<Error> error;
};

}
} // namespace Antares::API
1 change: 1 addition & 0 deletions src/api/include/antares/api/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ namespace Antares::API
*/
SimulationResults PerformSimulation(
const std::filesystem::path& study_path,
const std::filesystem::path& output,
const Antares::Solver::Optimization::OptimizationOptions& optOptions) noexcept;
} // namespace Antares::API
2 changes: 2 additions & 0 deletions src/api/private/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ class APIInternal
* @return SimulationResults object which contains the results of the simulation.
*/
SimulationResults run(const IStudyLoader& study_loader,
const std::filesystem::path& output,
const Antares::Solver::Optimization::OptimizationOptions& optOptions);

private:
std::shared_ptr<Antares::Data::Study> study_;
SimulationResults execute(
const std::filesystem::path& output,
const Antares::Solver::Optimization::OptimizationOptions& optOptions) const;
};

Expand Down
5 changes: 3 additions & 2 deletions src/api/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ namespace Antares::API

SimulationResults PerformSimulation(
const std::filesystem::path& study_path,
const std::filesystem::path& output,
const Antares::Solver::Optimization::OptimizationOptions& optOptions) noexcept
{
try
{
APIInternal api;
FileTreeStudyLoader study_loader(study_path);
return api.run(study_loader, optOptions);
return api.run(study_loader, output, optOptions);
}
catch (const std::exception& e)
{
Antares::API::Error err{.reason = e.what()};
return SimulationResults{.simulationPath = study_path, .antares_problems{}, .error = err};
return SimulationResults{.antares_problems{}, .error = err};
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/api_client_example/src/API_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

#include <utility>

Antares::API::SimulationResults solve(std::filesystem::path study_path)
Antares::API::SimulationResults solve(std::filesystem::path study_path,
std::filesystem::path output)
{
return Antares::API::PerformSimulation(std::move(study_path), {});
return Antares::API::PerformSimulation(std::move(study_path), std::move(output), {});
}
5 changes: 3 additions & 2 deletions src/api_client_example/src/API_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

#pragma once

#include <antares/api/solver.h>
#include <antares/api/SimulationResults.h>
#include <antares/api/solver.h>

Antares::API::SimulationResults solve(std::filesystem::path study_path);
Antares::API::SimulationResults solve(std::filesystem::path study_path,
std::filesystem::path output);
8 changes: 5 additions & 3 deletions src/api_client_example/tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
#define BOOST_TEST_MODULE test_client_api

#include <boost/test/unit_test.hpp>

#include "API_client.h"

BOOST_AUTO_TEST_CASE(test_run) {
auto results = solve("dummy_study_test_client_api");
BOOST_AUTO_TEST_CASE(test_run)
{
auto results = solve("dummy_study_test_client_api", {});
BOOST_CHECK(results.error);
BOOST_CHECK(!results.error->reason.empty());
auto c = results.error->reason;
Expand All @@ -34,4 +36,4 @@ BOOST_AUTO_TEST_CASE(test_run) {
BOOST_CHECK(results.error->reason.find("folder") != std::string::npos);
BOOST_CHECK(results.error->reason.find("not") != std::string::npos);
BOOST_CHECK(results.error->reason.find("exist") != std::string::npos);
}
}
5 changes: 3 additions & 2 deletions src/ext/yuni/src/yuni/core/nonmovable.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ class YUNI_DECL NonMovable
{
protected:
//! Default constructor
NonCopyable()
NonMovable()
{
}

//! Protected non-virtual destructor
~NonCopyable()
~NonMovable()
{
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/format-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ $# -eq 0 ]
then
# No arguments: format all
SOURCE_DIRS="analyzer/ libs/ solver/ tools/ config/ tests/ packaging/"
SOURCE_DIRS="analyzer/ libs/ solver/ tools/ config/ tests/ packaging/ api/"
SOURCE_FILES=$(find $SOURCE_DIRS -regextype egrep -regex ".*/*\.(c|cxx|cpp|cc|h|hxx|hpp)$" ! -path '*/antlr-interface/*')
else
# Format files provided as arguments
Expand Down
5 changes: 2 additions & 3 deletions src/libs/antares/exception/LoadingError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ InvalidSolverSpecificParameters::InvalidSolverSpecificParameters(const std::stri
{
}

InvalidStudy::InvalidStudy(const Yuni::String& study):
LoadingError(std::string("The folder `") + study.c_str()
+ "` does not seem to be a valid study")
InvalidStudy::InvalidStudy(const std::string& study):
LoadingError(std::string("The folder `") + study + "` does not seem to be a valid study")
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class InvalidSolverSpecificParameters: public LoadingError
class InvalidStudy: public LoadingError
{
public:
explicit InvalidStudy(const Yuni::String& study);
explicit InvalidStudy(const std::string& study);
};

class NoStudyProvided: public LoadingError
Expand Down
3 changes: 2 additions & 1 deletion src/libs/antares/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ source_group("io" FILES ${SRC_IO})
add_library(io
${SRC_IO}
)
add_library(Antares::io ALIAS io)

target_link_libraries(io
PRIVATE
Expand All @@ -26,4 +27,4 @@ target_include_directories(io

install(DIRECTORY include/antares
DESTINATION "include"
)
)
3 changes: 1 addition & 2 deletions src/libs/antares/io/include/antares/io/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#define __LIBS_ANTARES_IO_FILE_H__

#include <filesystem>

#include <yuni/core/string.h>
#include <string>

namespace Antares::IO
{
Expand Down
10 changes: 6 additions & 4 deletions src/libs/antares/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ set(SRC_STUDY_PART_THERMAL
include/antares/study/parts/thermal/cost_provider.h
include/antares/study/parts/thermal/cluster.hxx
parts/thermal/cluster.cpp
parts/thermal/scenarized_cost_provider.cpp
parts/thermal/constant_cost_provider.cpp
parts/thermal/scenarized_cost_provider.cpp
parts/thermal/constant_cost_provider.cpp
include/antares/study/parts/thermal/cluster_list.h
parts/thermal/cluster_list.cpp
include/antares/study/parts/thermal/pollutant.h
Expand All @@ -102,7 +102,9 @@ set(SRC_STUDY_PART_SHORT_TERM_STORAGE
parts/short-term-storage/series.cpp
include/antares/study/parts/short-term-storage/series.h
include/antares/study/parts/short-term-storage/cluster.h
include/antares/study/parts/short-term-storage/AdditionalConstraint.h
parts/short-term-storage/cluster.cpp
parts/short-term-storage/AdditionalConstraint.cpp
)
source_group("study\\part\\short-term-storage" FILES ${SRC_STUDY_PART_SHORT_TERM_SOTRAGE})

Expand Down Expand Up @@ -306,12 +308,12 @@ target_link_libraries(study
)

target_include_directories(study
PUBLIC
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

# Make more than just study visible but it's the lesser evil for now
)

install(DIRECTORY include/antares
install(DIRECTORY include/antares
DESTINATION "include"
)
Loading

0 comments on commit 47af157

Please sign in to comment.