From c8c49193f202bc31313d7d16a4956daf17293dd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jason=20Mar=C3=A9chal?=
<45510813+JasonMarechal25@users.noreply.github.com>
Date: Mon, 28 Aug 2023 10:27:46 +0200
Subject: [PATCH 1/4] Cleanup date dependency (#1565)
* Move writer in libs
* wip
* Benchmarking
* Remove extra dependency
* Move writer in libs
* Fix post rebase
* Remove Yuni target include
* Lots of lib change
* Lots of lib change
* Remove extra writer dependency
* Improve Cmake correlation
* Improve Cmake checks
* Improve Cmake benchmarking
* Improve Cmake array
* Improve Cmake exception
* Improve Cmake inifile
* Improve Cmake io
* Improve Cmake jit
* Improve Cmake logs
* Fix date cmake
* Fix compil for logs
* Sys wip
* Memory wip
* Finish Memory/sys
* Remove sys as direct dependency of antares-core
* Clean Date
* Remove header
* Fix warnings for correlation
* Delete array1d: unused
* (dirty) Fix conflicting library name
* Fix missing header and dependency visibility
---
src/libs/antares/CMakeLists.txt | 6 +-
src/libs/antares/array/CMakeLists.txt | 2 +-
.../antares/array/antares/array/array1d.h | 127 -------
src/libs/antares/array/array1d.cpp | 317 ------------------
src/libs/antares/correlation/CMakeLists.txt | 11 +-
src/libs/antares/study/area/list.cpp | 4 -
.../antares/study/parts/hydro/container.cpp | 1 -
src/libs/antares/study/parts/hydro/prepro.cpp | 1 -
.../antares/study/parts/thermal/ecoInput.cpp | 1 -
.../antares/study/parts/thermal/prepro.cpp | 1 -
src/libs/antares/study/study.h | 8 +-
src/tools/yby-aggregator/CMakeLists.txt | 1 -
src/ui/simulator/CMakeLists.txt | 2 +-
13 files changed, 16 insertions(+), 466 deletions(-)
delete mode 100644 src/libs/antares/array/antares/array/array1d.h
delete mode 100644 src/libs/antares/array/array1d.cpp
diff --git a/src/libs/antares/CMakeLists.txt b/src/libs/antares/CMakeLists.txt
index 857b4fba30..24ad7719b3 100644
--- a/src/libs/antares/CMakeLists.txt
+++ b/src/libs/antares/CMakeLists.txt
@@ -504,7 +504,6 @@ target_link_libraries(libantares-core
yuni-static-uuid
Boost::boost
Antares::memory
- date
logs
exception
checks
@@ -513,9 +512,12 @@ target_link_libraries(libantares-core
inifile
io
array
- correlation
object
benchmarking
+ Antares::date
+
+ PRIVATE
+ Antares::correlation
)
import_std_libs(libantares-core)
diff --git a/src/libs/antares/array/CMakeLists.txt b/src/libs/antares/array/CMakeLists.txt
index 8f9f865699..5c212269d3 100644
--- a/src/libs/antares/array/CMakeLists.txt
+++ b/src/libs/antares/array/CMakeLists.txt
@@ -1,12 +1,12 @@
set(SRC_MATRIX
antares/array/matrix.h
- antares/array/array1d.h
antares/array/matrix.hxx
matrix.cpp
)
source_group("array" FILES ${SRC_MATRIX})
add_library(array ${SRC_MATRIX})
+add_library(Antares::array ALIAS array)
target_link_libraries(array
PRIVATE
diff --git a/src/libs/antares/array/antares/array/array1d.h b/src/libs/antares/array/antares/array/array1d.h
deleted file mode 100644
index 4c8a617e65..0000000000
--- a/src/libs/antares/array/antares/array/array1d.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-** Copyright 2007-2023 RTE
-** Authors: Antares_Simulator Team
-**
-** This file is part of Antares_Simulator.
-**
-** Antares_Simulator is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** There are special exceptions to the terms and conditions of the
-** license as they are applied to this software. View the full text of
-** the exceptions in file COPYING.txt in the directory of this software
-** distribution
-**
-** 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
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with Antares_Simulator. If not, see .
-**
-** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
-*/
-#ifndef __ANTARES_LIBS_ARRAY_ARRAY_1D_H__
-#define __ANTARES_LIBS_ARRAY_ARRAY_1D_H__
-
-/*!
-** \defgroup array1d 1D-Array
-** \ingroup toolbox
-*/
-
-/*!
-** \brief Load an integer 1D array from a file
-** \ingroup array1d
-**
-** \param filename The filename to read
-** \param[out] data The data structure to fill
-** \param height The size of the structure
-** \return A non-zero value if the operation was successful, 0 otherwise
-*/
-int Array1DLoadFromFile(const char filename[], double data[], const int height);
-
-/*!
-** \brief Save a 1D-Array into a file
-** \ingroup array1d
-**
-** \param filename The target filename
-** \param data The array to store
-** \param count The number of items in the array
-** \return A non-zero value if the operation was successful, 0 otherwise
-*/
-int Array1DSaveToFile(const char filename[],
- const double data[],
- const int count,
- uint precision = 6);
-
-/*!
-** \brief Check if all values are strictly positive
-**
-** \param msg The message to put in logs if an error occurs
-** \param data The 1D-array
-** \param count The size of the array
-** \return A non-zero value if all values are strictly positive
-*/
-int Array1DCheckStrictlyPositiveValues(const char msg[], const double data[], const int count);
-
-/*!
-** \brief Check if all values are positive or null
-**
-** \param msg The message to put in logs if an error occurs
-** \param data The 1D-array
-** \param count The size of the array
-** \return A non-zero value if all values are strictly positive
-*/
-int Array1DCheckPositiveValues(const char msg[], const double data[], const int count);
-
-/*!
-** \brief Check if all values are negative or null
-**
-** \param msg The message to put in logs if an error occurs
-** \param data The 1D-array
-** \param count The size of the array
-** \return A non-zero value if all values are strictly positive
-*/
-int Array1DCheckNegativeValues(const char msg[], const double data[], const int count);
-
-/*!
-** \brief Check if all values are within a range
-**
-** \param msg The message to put in logs if an error occurs
-** \param data The 1D-array
-** \param count The size of the array
-** \param minV The minimum value
-** \param maxV The maximum value
-** \return A non-zero value if all values are strictly positive
-*/
-int Array1DCheckForValuesInRange(const char msg[],
- const double data[],
- const int count,
- const double minV,
- const double maxV);
-
-/*!
-** \brief Check if all values are greater than or equal to a given number
-**
-** \param msg The message to put in logs if an error occurs
-** \param data The 1D-array
-** \param count The size of the array
-** \return A non-zero value if all values are strictly positive
-*/
-int Array1DCheckGreaterOrEqual(const char msg[],
- const double data[],
- const int count,
- const double v);
-
-/*!
-** \brief Set all values of a 1D-Array
-**
-** \param data The 1D-array
-** \param count The size of the array
-*/
-void Array1DSetValues(double data[], const int count, const double value);
-
-#endif /* __ANTARES_LIBS_ARRAY_ARRAY_1D_H__ */
diff --git a/src/libs/antares/array/array1d.cpp b/src/libs/antares/array/array1d.cpp
deleted file mode 100644
index a2cca42dd5..0000000000
--- a/src/libs/antares/array/array1d.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
-** Copyright 2007-2023 RTE
-** Authors: Antares_Simulator Team
-**
-** This file is part of Antares_Simulator.
-**
-** Antares_Simulator is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** There are special exceptions to the terms and conditions of the
-** license as they are applied to this software. View the full text of
-** the exceptions in file COPYING.txt in the directory of this software
-** distribution
-**
-** 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
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with Antares_Simulator. If not, see .
-**
-** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
-*/
-
-#include
-#include
-#include
-#include
-#include
-#include "array1d.h"
-#include "../logs.h"
-
-#define ARRAY_BUFFER_SIZE 1024 * 256 /* 256Ko */
-
-#ifdef YUNI_OS_MSVC
-#define ANTARES_MATRIX_SNPRINTF sprintf_s
-#else
-#define ANTARES_MATRIX_SNPRINTF snprintf
-#endif
-
-using namespace Antares;
-using namespace Yuni;
-
-template
-static int Array1DLoadFromBuffer(const char* filename, U& data, double values[], const int height)
-{
- logs.debug() << " :: loading `" << filename << "'";
- // Position
- Yuni::String::Size offset = 0;
- int y = 0;
- uint pos;
- int errorCount = 6;
- // char* pend;
-
- while (y < height and offset < data.size())
- {
- // Starting the reading of the begining of the line
- pos = offset;
- if ((offset = data.find('\n', offset)) != Yuni::String::npos)
- {
- data[offset] = '\0';
- AnyString cell(data.c_str() + pos, offset - pos);
- if (!cell)
- {
- logs.warning() << filename << ": empty data at line " << (y + 1) << ", assuming 0";
- values[y] = 0.;
- }
- else
- {
- double v;
- if (!cell.to(v))
- {
- if (errorCount)
- {
- logs.warning() << filename << ": invalid decimal value at line " << (y + 1)
- << ", assuming 0";
- if (!(--errorCount))
- logs.warning() << " ... (skipped)";
- }
- values[y] = 0.;
- }
- else
- values[y] = v;
- }
- /*
- // Adding the value
- if (data[pos] == '0' and data[pos + 1] == '\0')
- {
- values[y] = 0.;
- }
- else
- {
- // Convert string into double
- values[y] = strtod(data.c_str() + pos, &pend);
- if (!(pend and '\0' == *pend))
- {
- values[y] = 0.;
- if (errorCount)
- {
- logs.warning() << '`' << filename
- << "`: Invalid format: Decimal value expected (y:" << y
- << ", offset:" << (uint)pos << "byte)"; if (!(--errorCount)) logs.warning() << " ...
- (skipped)";
- }
- }
- }
- */
-
- pos = ++offset;
- }
-
- // Go to the next line
- ++y;
-
- } // while (y ...)
-
- // Not enough lines to describe our matrix
- if (y < height)
- {
- logs.warning() << filename << ": not enough rows (expected " << height << ", got " << y
- << ')';
-
- // Initialize missing values
- while (y < height)
- {
- values[y] = 0.;
- ++y;
- }
- return 0;
- }
- return 1;
-}
-
-int Array1DLoadFromFile(const char* filename, double* data, const int height)
-{
- assert(NULL != data);
- if (NULL != filename and '\0' != *filename)
- {
- // Get a file descriptor
- const uint64 size = IO::File::Size(filename);
-
- if (size)
- {
- IO::File::Stream file(filename);
- if (file.opened())
- {
- Clob buffer;
- buffer.resize((String::Size)size);
-
- // Read the entire file
- file >> buffer;
- // Adding a final \n to make sure we have a line return at the end of the file
- buffer += '\n';
-
- // Load the data
- return Array1DLoadFromBuffer(filename, buffer, data, height);
- }
- logs.error() << "I/O error: " << filename << ": Impossible to load the file";
- memset(data, 0, sizeof(double) * height);
- }
- else
- {
- logs.warning() << filename << ": The file should not be empty";
- memset(data, 0, sizeof(double) * height);
- }
- }
- return 0;
-}
-
-int Array1DSaveToFile(const char filename[], const double data[], const int count, uint precision)
-{
- assert(NULL != filename);
- logs.debug() << " :: writing `" << filename << "` (h:" << count << ')';
-
- // Open the file for reading
- IO::File::Stream file;
- if (file.openRW(filename))
- {
- if (count)
- {
- const char* format;
- switch (precision)
- {
- // The 0 value in first
- case 0:
- format = "%.0f\n";
- break;
- // Then 6
- case 6:
- format = "%.6f\n";
- break;
- // All other entry
- case 1:
- format = "%.1f\n";
- break;
- case 2:
- format = "%.2f\n";
- break;
- case 3:
- format = "%.3f\n";
- break;
- case 4:
- format = "%.4f\n";
- break;
- case 5:
- format = "%.5f\n";
- break;
- default:
- format = "%.6f\n";
- break;
- }
-
- char buffer[128];
- for (int i = 0; i < count; ++i)
- {
- if (Math::Zero(data[i]))
- {
- file += "0\n";
- }
- else
- {
- if (!precision or fabs(data[i] - floor(data[i])) < YUNI_EPSILON)
- ANTARES_MATRIX_SNPRINTF(buffer, sizeof(buffer), "%.0f\n", data[i]);
- else
- ANTARES_MATRIX_SNPRINTF(buffer, sizeof(buffer), format, data[i]);
- file += (const char*)buffer;
- }
- }
- }
- return 1;
- }
- logs.error() << "I/O error: " << filename << ": Impossible to write the file";
- return 0;
-}
-
-int Array1DCheckStrictlyPositiveValues(const char msg[], const double data[], const int count)
-{
- for (int i = 0; i < count; ++i)
- {
- if (data[i] <= 0.)
- {
- logs.error() << msg << ": At least one value is not strictly positive (at " << i << ')';
- return 0;
- }
- }
- return 1;
-}
-
-int Array1DCheckPositiveValues(const char msg[], const double data[], const int count)
-{
- for (int i = 0; i < count; ++i)
- {
- if (data[i] < 0.)
- {
- logs.error() << msg << ": At least one value is not positive (at " << i << ')';
- return 0;
- }
- }
- return 1;
-}
-
-int Array1DCheckNegativeValues(const char msg[], const double data[], const int count)
-{
- for (int i = 0; i < count; ++i)
- {
- if (data[i] > 0.)
- {
- logs.error() << msg << ": At least one value is not negative (at " << i << ')';
- return 0;
- }
- }
- return 1;
-}
-
-void Array1DSetValues(double data[], const int count, const double value)
-{
- for (int i = 0; i < count; ++i)
- data[i] = value;
-}
-
-int Array1DCheckForValuesInRange(const char msg[],
- const double data[],
- const int count,
- const double minV,
- const double maxV)
-{
- for (int i = 0; i < count; ++i)
- {
- if (data[i] < minV or data[i] > maxV)
- {
- logs.error() << msg << ": All values must be within the range [" << minV << ',' << maxV
- << ']';
- return 0;
- }
- }
- return 1;
-}
-
-int Array1DCheckGreaterOrEqual(const char msg[],
- const double data[],
- const int count,
- const double v)
-{
- int i = 0;
- for (; i < count; ++i)
- {
- if (data[i] < v)
- {
- logs.error() << msg << ": All values must be equal to or greater than " << v;
- return 0;
- }
- }
- return 1;
-}
diff --git a/src/libs/antares/correlation/CMakeLists.txt b/src/libs/antares/correlation/CMakeLists.txt
index ae5fd4359d..e9def03ddc 100644
--- a/src/libs/antares/correlation/CMakeLists.txt
+++ b/src/libs/antares/correlation/CMakeLists.txt
@@ -5,18 +5,21 @@ set(SRC_CORRELATION
)
source_group("correlation" FILES ${SRC_CORRELATION})
-add_library(correlation ${SRC_CORRELATION})
+add_library(correlation
+ ${SRC_CORRELATION}
+)
+add_library(Antares::correlation ALIAS correlation)
target_link_libraries(correlation
PRIVATE
yuni-static-core
- inifile
- array
+ Antares::inifile
+ Antares::array
+
)
target_include_directories(correlation
PRIVATE
- ${CMAKE_SOURCE_DIR}/libs/solver
${CMAKE_SOURCE_DIR}/libs/ #area -> antares/study/parameters/adq-patch-params.h
${CMAKE_SOURCE_DIR}/libs/antares/date #area -> antares/study/parameters/adq-patch-params.h -> date
${CMAKE_SOURCE_DIR}/libs/antares/writer #area -> antares/parts/thermal/cluster -> writer
diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp
index 0a9982f7c1..53f1c40f5c 100644
--- a/src/libs/antares/study/area/list.cpp
+++ b/src/libs/antares/study/area/list.cpp
@@ -27,15 +27,11 @@
#include "../../antares.h"
#include
-#include
#include "../study.h"
#include
#include "area.h"
-#include
#include
#include
-#include "../../config.h"
-#include "../filter.h"
#include "constants.h"
#include "antares/study/parts/parts.h"
#include "antares/study/parts/load/prepro.h"
diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp
index 97f7755b38..288ec58a44 100644
--- a/src/libs/antares/study/parts/hydro/container.cpp
+++ b/src/libs/antares/study/parts/hydro/container.cpp
@@ -28,7 +28,6 @@
#include "../../study.h"
#include "container.h"
#include
-#include
using namespace Antares;
using namespace Yuni;
diff --git a/src/libs/antares/study/parts/hydro/prepro.cpp b/src/libs/antares/study/parts/hydro/prepro.cpp
index 6e272b71b7..053ac05a2a 100644
--- a/src/libs/antares/study/parts/hydro/prepro.cpp
+++ b/src/libs/antares/study/parts/hydro/prepro.cpp
@@ -31,7 +31,6 @@
#include "../../study.h"
#include "prepro.h"
#include
-#include
#include
using namespace Antares;
diff --git a/src/libs/antares/study/parts/thermal/ecoInput.cpp b/src/libs/antares/study/parts/thermal/ecoInput.cpp
index 9c868cfb26..8241f07b77 100644
--- a/src/libs/antares/study/parts/thermal/ecoInput.cpp
+++ b/src/libs/antares/study/parts/thermal/ecoInput.cpp
@@ -32,7 +32,6 @@
#include "../../study.h"
#include "ecoInput.h"
#include
-#include
using namespace Yuni;
diff --git a/src/libs/antares/study/parts/thermal/prepro.cpp b/src/libs/antares/study/parts/thermal/prepro.cpp
index 090de14a57..d4cb3b654b 100644
--- a/src/libs/antares/study/parts/thermal/prepro.cpp
+++ b/src/libs/antares/study/parts/thermal/prepro.cpp
@@ -32,7 +32,6 @@
#include "../../study.h"
#include "prepro.h"
#include
-#include
using namespace Yuni;
diff --git a/src/libs/antares/study/study.h b/src/libs/antares/study/study.h
index b384e4294a..e442b8c1f4 100644
--- a/src/libs/antares/study/study.h
+++ b/src/libs/antares/study/study.h
@@ -56,9 +56,7 @@
#include
-namespace Antares
-{
-namespace Data
+namespace Antares::Data
{
/*!
** \brief Antares Study
@@ -721,8 +719,8 @@ YString StudyCreateOutputPath(StudyMode mode,
const YString& folder,
const YString& label,
Yuni::sint64 startTime);
-} // namespace Data
-} // namespace Antares
+} // namespace Antares::Data
+
#include "study.hxx"
#include "runtime.h"
diff --git a/src/tools/yby-aggregator/CMakeLists.txt b/src/tools/yby-aggregator/CMakeLists.txt
index b83ceb82de..7784a75ed9 100644
--- a/src/tools/yby-aggregator/CMakeLists.txt
+++ b/src/tools/yby-aggregator/CMakeLists.txt
@@ -48,7 +48,6 @@ INSTALL(EXPORT antares-ybyaggregator
set(YBY_AGGREGATOR_LIBS
libantares-core
- Antares::date
Antares::logs
yuni-static-core
Antares::sys
diff --git a/src/ui/simulator/CMakeLists.txt b/src/ui/simulator/CMakeLists.txt
index 4aad2a34d8..fef536e46e 100644
--- a/src/ui/simulator/CMakeLists.txt
+++ b/src/ui/simulator/CMakeLists.txt
@@ -146,10 +146,10 @@ set(ANTARES_LIBS
libantares-solver-constraints-builder
libantares-solver-variable-info
libantares-core
- date
yuni-static-core
yuni-static-uuid
libmodel_antares
+ Antares::date
)
target_link_libraries(${execname}
From 0cc16d12c9ea0225b3d6bcf305838dd5f224d347 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jason=20Mar=C3=A9chal?=
<45510813+JasonMarechal25@users.noreply.github.com>
Date: Mon, 28 Aug 2023 15:17:58 +0200
Subject: [PATCH 2/4] Split benchmarking (#1582)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Move writer in libs
* wip
* Benchmarking
* Remove extra dependency
* Move writer in libs
* Fix post rebase
* Remove Yuni target include
* Lots of lib change
* Lots of lib change
* Remove extra writer dependency
* Improve Cmake correlation
* Improve Cmake checks
* Improve Cmake benchmarking
* Improve Cmake array
* Improve Cmake exception
* Improve Cmake inifile
* Improve Cmake io
* Improve Cmake jit
* Improve Cmake logs
* Fix date cmake
* Fix compil for logs
* Sys wip
* Memory wip
* Finish Memory/sys
* Fix post merge
* Remove extra include
* Fix include
* Remove sys as direct dependency of antares-core (#1561)
* Remove memory usage
* Fix merge
* Remove extra dependency
* Move public dependency as private
* Remove deprecated dependency
* Split Duration collector and StudyInfoCollector
* Move OptimizationInfo in proper place
* Split SimulationInfoCollection from Benchmarking
* Update src/libs/antares/benchmarking/DurationCollector.cpp
Co-authored-by: Florian Omnès
* Fix merge
---------
Co-authored-by: Florian Omnès
---
src/libs/antares/CMakeLists.txt | 1 +
.../antares/InfoCollection/CMakeLists.txt | 35 ++++++++++
.../StudyInfoCollector.cpp} | 66 +++++++------------
.../infoCollection/StudyInfoCollector.h} | 66 +++++--------------
src/libs/antares/benchmarking/CMakeLists.txt | 23 ++-----
.../benchmarking/DurationCollector.cpp | 22 +++++++
.../antares/benchmarking/DurationCollector.h | 44 +++++++++++++
.../antares/benchmarking/file_content.h | 0
.../antares/benchmarking/timer.h | 0
src/libs/antares/study/fwd.h | 12 ++--
src/libs/antares/study/load.cpp | 2 +-
src/libs/antares/study/save.cpp | 2 +-
src/libs/antares/study/version.cpp | 8 +--
src/libs/antares/study/version.h | 8 +--
src/libs/antares/writer/CMakeLists.txt | 2 +-
.../writer/antares/writer/writer_factory.h | 2 +-
src/libs/antares/writer/private/zip_writer.h | 2 +-
src/libs/antares/writer/writer_factory.cpp | 8 +--
src/libs/antares/writer/zip_writer.cpp | 2 +
src/solver/CMakeLists.txt | 3 +-
src/solver/application.cpp | 9 ++-
src/solver/application.h | 11 ++--
src/solver/main/CMakeLists.txt | 12 +++-
src/solver/main/adequacy.cpp | 2 +-
src/solver/main/economy.cpp | 2 +-
src/solver/simulation/CMakeLists.txt | 9 ++-
src/solver/simulation/adequacy.h | 1 +
src/solver/simulation/economy.h | 1 +
src/solver/simulation/solver.h | 2 +-
src/solver/ts-generator/hydro.cpp | 2 +-
src/tests/end-to-end/utils/CMakeLists.txt | 1 +
31 files changed, 200 insertions(+), 160 deletions(-)
create mode 100644 src/libs/antares/InfoCollection/CMakeLists.txt
rename src/libs/antares/{benchmarking/info_collectors.cpp => InfoCollection/StudyInfoCollector.cpp} (76%)
rename src/libs/antares/{benchmarking/antares/benchmarking/info_collectors.h => InfoCollection/include/antares/infoCollection/StudyInfoCollector.h} (56%)
create mode 100644 src/libs/antares/benchmarking/DurationCollector.cpp
create mode 100644 src/libs/antares/benchmarking/include/antares/benchmarking/DurationCollector.h
rename src/libs/antares/benchmarking/{ => include}/antares/benchmarking/file_content.h (100%)
rename src/libs/antares/benchmarking/{ => include}/antares/benchmarking/timer.h (100%)
diff --git a/src/libs/antares/CMakeLists.txt b/src/libs/antares/CMakeLists.txt
index 24ad7719b3..28512b40fb 100644
--- a/src/libs/antares/CMakeLists.txt
+++ b/src/libs/antares/CMakeLists.txt
@@ -331,6 +331,7 @@ set(SRC_XCAST
source_group("study\\xcast" FILES ${SRC_XCAST})
add_subdirectory(benchmarking)
+add_subdirectory(InfoCollection)
add_subdirectory(io)
add_subdirectory(exception)
diff --git a/src/libs/antares/InfoCollection/CMakeLists.txt b/src/libs/antares/InfoCollection/CMakeLists.txt
new file mode 100644
index 0000000000..ad9266c1ec
--- /dev/null
+++ b/src/libs/antares/InfoCollection/CMakeLists.txt
@@ -0,0 +1,35 @@
+set(PROJ infoCollection)
+set(HEADERS
+ include/antares/${PROJ}/StudyInfoCollector.h
+)
+set(SRC_PROJ
+ ${HEADERS}
+ StudyInfoCollector.cpp
+)
+source_group("misc\\${PROJ}" FILES ${SRC_PROJ})
+
+add_library(${PROJ} ${SRC_PROJ})
+add_library(Antares::${PROJ} ALIAS ${PROJ})
+
+target_link_libraries(${PROJ}
+ PRIVATE
+ yuni-static-core
+ PUBLIC
+ Antares::benchmarking
+)
+
+target_include_directories(${PROJ}
+ PUBLIC
+ ${CMAKE_SOURCE_DIR}/libs #study
+ ${CMAKE_SOURCE_DIR}/libs/antares/date #parameters -> date
+ ${CMAKE_SOURCE_DIR}/libs/antares/array #links
+ ${CMAKE_SOURCE_DIR}/libs/antares/logs #study -> binding constraint -> matrix -> jit
+ ${CMAKE_SOURCE_DIR}/libs/antares/io #study -> binding constraint -> matrix
+ ${CMAKE_SOURCE_DIR}/libs/antares/writer #study
+ ${CMAKE_SOURCE_DIR}/libs/antares/exception #enum -> exception
+ ${CMAKE_SOURCE_DIR}/libs/antares/jit # something,something -> jit
+ ${CMAKE_SOURCE_DIR}/libs/antares/memory/include #study -> BC -> link -> memory
+ ${CMAKE_SOURCE_DIR}/libs/antares/inifile #study -> inifile
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
diff --git a/src/libs/antares/benchmarking/info_collectors.cpp b/src/libs/antares/InfoCollection/StudyInfoCollector.cpp
similarity index 76%
rename from src/libs/antares/benchmarking/info_collectors.cpp
rename to src/libs/antares/InfoCollection/StudyInfoCollector.cpp
index 34b15d8868..05f9894f12 100644
--- a/src/libs/antares/benchmarking/info_collectors.cpp
+++ b/src/libs/antares/InfoCollection/StudyInfoCollector.cpp
@@ -1,13 +1,15 @@
-#include
-#include
-#include
-#include
-#include
+//
+// Created by marechaljas on 22/08/23.
+//
+
+#include "antares/infoCollection/StudyInfoCollector.h"
+#include "antares/benchmarking/DurationCollector.h"
+#include "antares/benchmarking/file_content.h"
+#include "../../../config.h"
using namespace Antares::Data;
+namespace Benchmarking {
-namespace Benchmarking
-{
// Collecting data study
// ---------------------------
void StudyInfoCollector::toFileContent(FileContent& file_content)
@@ -82,17 +84,17 @@ void StudyInfoCollector::enabledBindingConstraintsCountToFileContent(FileContent
{
switch (activeContraints[i]->type())
{
- case BindingConstraint::Type::typeHourly:
- nbEnabledHourlyBC++;
- break;
- case BindingConstraint::Type::typeDaily:
- nbEnabledDailyBC++;
- break;
- case BindingConstraint::Type::typeWeekly:
- nbEnabledWeeklyBC++;
- break;
- default:
- break;
+ case BindingConstraint::Type::typeHourly:
+ nbEnabledHourlyBC++;
+ break;
+ case BindingConstraint::Type::typeDaily:
+ nbEnabledDailyBC++;
+ break;
+ case BindingConstraint::Type::typeWeekly:
+ nbEnabledWeeklyBC++;
+ break;
+ default:
+ break;
}
}
@@ -105,7 +107,7 @@ void StudyInfoCollector::enabledBindingConstraintsCountToFileContent(FileContent
void StudyInfoCollector::unitCommitmentModeToFileContent(FileContent& file_content)
{
const char* unitCommitment
- = UnitCommitmentModeToCString(study_.parameters.unitCommitment.ucMode);
+ = UnitCommitmentModeToCString(study_.parameters.unitCommitment.ucMode);
file_content.addItemToSection("study", "unit commitment", unitCommitment);
}
@@ -118,7 +120,7 @@ void StudyInfoCollector::solverVersionToFileContent(FileContent& file_content)
{
// Example : 8.3.0 -> 830
const unsigned int version
- = 100 * ANTARES_VERSION_HI + 10 * ANTARES_VERSION_LO + ANTARES_VERSION_BUILD;
+ = 100 * ANTARES_VERSION_HI + 10 * ANTARES_VERSION_LO + ANTARES_VERSION_BUILD;
file_content.addItemToSection("study", "antares version", version);
}
@@ -147,27 +149,7 @@ void SimulationInfoCollector::toFileContent(FileContent& file_content)
file_content.addItemToSection("optimization problem", "variables", opt_info_.nbVariables);
file_content.addItemToSection("optimization problem", "constraints", opt_info_.nbConstraints);
file_content.addItemToSection(
- "optimization problem", "non-zero coefficients", opt_info_.nbNonZeroCoeffs);
-}
-
-// Collecting durations from simulation
-// -------------------------------------
-void DurationCollector::toFileContent(FileContent& file_content)
-{
- for (const auto& element : duration_items_)
- {
- const std::string& name = element.first;
- const auto& durations = element.second;
- const int64_t duration_sum = accumulate(durations.begin(), durations.end(), (int64_t)0);
-
- file_content.addDurationItem(name, (unsigned int)duration_sum, (int)durations.size());
- }
-}
-
-void DurationCollector::addDuration(const std::string& name, int64_t duration)
-{
- const std::lock_guard lock(mutex_);
- duration_items_[name].push_back(duration);
+ "optimization problem", "non-zero coefficients", opt_info_.nbNonZeroCoeffs);
}
-} // namespace Benchmarking
+}
\ No newline at end of file
diff --git a/src/libs/antares/benchmarking/antares/benchmarking/info_collectors.h b/src/libs/antares/InfoCollection/include/antares/infoCollection/StudyInfoCollector.h
similarity index 56%
rename from src/libs/antares/benchmarking/antares/benchmarking/info_collectors.h
rename to src/libs/antares/InfoCollection/include/antares/infoCollection/StudyInfoCollector.h
index 092decdd04..bb3b1f1df8 100644
--- a/src/libs/antares/benchmarking/antares/benchmarking/info_collectors.h
+++ b/src/libs/antares/InfoCollection/include/antares/infoCollection/StudyInfoCollector.h
@@ -1,25 +1,13 @@
-#pragma once
-
-#include
-#include