Skip to content

Commit

Permalink
Headers files : remove useless inclusions in OPT (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
guilpier-code authored Sep 24, 2024
1 parent 380ccd7 commit c4b9373
Show file tree
Hide file tree
Showing 41 changed files with 90 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@

#include <unordered_map>

#include <yuni/yuni.h>

#include <antares/mersenne-twister/mersenne-twister.h>
#include <antares/study/area/area.h>
#include <antares/study/fwd.h>
#include <antares/study/parts/hydro/container.h>
#include "antares/date/date.h"
#include "antares/solver/simulation/sim_structure_donnees.h"
#include "antares/writer/i_writer.h"

namespace Antares
Expand Down Expand Up @@ -113,7 +111,6 @@ class HydroManagement final
const Data::AreaList& areas_;
const Date::Calendar& calendar_;
const Data::Parameters& parameters_;
unsigned int maxNbYearsInParallel_ = 0;
Solver::IResultWriter& resultWriter_;

HYDRO_VENTILATION_RESULTS ventilationResults_;
Expand Down
25 changes: 9 additions & 16 deletions src/solver/hydro/management/daily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,20 @@

#include <array>
#include <cassert>
#include <filesystem>
#include <limits>
#include <sstream>

#include <yuni/yuni.h>
#include <yuni/io/directory.h>
#include <yuni/io/file.h>

#include <antares/antares/fatal-error.h>
#include <antares/study/area/scratchpad.h>
#include <antares/study/study.h>
#include <antares/utils/utils.h>
#include <antares/writer/i_writer.h>
#include "antares/solver/hydro/daily/h2o_j_donnees_mensuelles.h"
#include "antares/solver/hydro/daily/h2o_j_fonctions.h"
#include "antares/solver/hydro/daily2/h2o2_j_donnees_mensuelles.h"
#include "antares/solver/hydro/daily2/h2o2_j_fonctions.h"
#include "antares/solver/hydro/management/management.h"

using namespace Yuni;

#define SEP IO::Separator
namespace fs = std::filesystem;

namespace
{
Expand Down Expand Up @@ -135,8 +128,8 @@ struct DebugData

void writeTurb(const std::string filename, uint y) const
{
std::ostringstream buffer, path;
path << "debug" << SEP << "solver" << SEP << (1 + y) << SEP << filename;
std::ostringstream buffer;
auto path = fs::path("debug") / "solver" / std::to_string(1 + y) / filename;

buffer << "\tTurbine\t\t\tOPP\t\t\t\tTurbine Cible\tDLE\t\t\t\tDLN\n";
for (uint day = 0; day != 365; ++day)
Expand All @@ -148,17 +141,17 @@ struct DebugData
buffer << '\n';
}
auto buffer_str = buffer.str();
pWriter.addEntryFromBuffer(path.str(), buffer_str);
pWriter.addEntryFromBuffer(path.string(), buffer_str);
}

void writeDailyDebugData(const Date::Calendar& calendar,
int initReservoirLvlMonth,
uint y,
const Data::AreaName& areaName) const
{
std::ostringstream buffer, path;
path << "debug" << SEP << "solver" << SEP << (1 + y) << SEP << "daily." << areaName.c_str()
<< ".txt";
std::ostringstream buffer;
auto path = fs::path("debug") / "solver" / std::to_string(1 + y) / "daily."
/ areaName.c_str() / ".txt";

buffer << "\tNiveau init : " << hydro_specific.monthly[initReservoirLvlMonth].MOL << "\n";
for (uint month = 0; month != MONTHS_PER_YEAR; ++month)
Expand Down Expand Up @@ -217,7 +210,7 @@ struct DebugData
}
}
auto buffer_str = buffer.str();
pWriter.addEntryFromBuffer(path.str(), buffer_str);
pWriter.addEntryFromBuffer(path.string(), buffer_str);
}
};

Expand Down
3 changes: 0 additions & 3 deletions src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
#include <cmath>
#include <limits>

#include <antares/antares/fatal-error.h>
#include <antares/study/area/scratchpad.h>
#include <antares/study/parts/hydro/container.h>
#include <antares/study/study.h>

namespace Antares
{
Expand Down
29 changes: 10 additions & 19 deletions src/solver/hydro/management/monthly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,22 @@
** 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/>.
*/
#include <filesystem>
#include <iomanip>
#include <limits>
#include <sstream>

#include <yuni/yuni.h>
#include <yuni/io/directory.h>
#include <yuni/io/file.h>

#include <antares/antares/fatal-error.h>
#include <antares/study/study.h>
#include <antares/utils/utils.h>
#include "antares/solver/hydro/management/management.h"
#include "antares/solver/hydro/monthly/h2o_m_donnees_annuelles.h"
#include "antares/solver/hydro/monthly/h2o_m_fonctions.h"

using namespace Yuni;

#define SEP IO::Separator
namespace fs = std::filesystem;

namespace Antares
{
template<class ProblemT>
static void CheckHydroAllocationProblem(Data::Area& area,
ProblemT& problem,
DONNEES_ANNUELLES& problem,
int initLevelMonth,
double lvi)
{
Expand Down Expand Up @@ -206,10 +198,9 @@ void HydroManagement::prepareMonthlyOptimalGenerations(const double* random_rese
{
case OUI:
{
if (Logs::Verbosity::Debug::enabled)
{
CheckHydroAllocationProblem(area, problem, initReservoirLvlMonth, lvi);
}
#ifndef NDEBUG
CheckHydroAllocationProblem(area, problem, initReservoirLvlMonth, lvi);
#endif

for (uint month = 0; month != MONTHS_PER_YEAR; ++month)
{
Expand Down Expand Up @@ -269,9 +260,9 @@ void HydroManagement::prepareMonthlyOptimalGenerations(const double* random_rese
#endif
if (parameters_.hydroDebug)
{
std::ostringstream buffer, path;
path << "debug" << SEP << "solver" << SEP << (1 + y) << SEP << "monthly." << area.name
<< ".txt";
std::ostringstream buffer;
auto path = fs::path("debug") / "solver" / std::to_string(1 + y) / "monthly."
/ area.name.c_str() / ".txt";

if (area.hydro.reservoirManagement)
buffer << "Initial Reservoir Level\t" << lvi << "\n";
Expand Down Expand Up @@ -313,7 +304,7 @@ void HydroManagement::prepareMonthlyOptimalGenerations(const double* random_rese
buffer << '\n';
}
auto content = buffer.str();
resultWriter_.addEntryFromBuffer(path.str(), content);
resultWriter_.addEntryFromBuffer(path.string(), content);
}
indexArea++;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void OPT_InitialiserLeSecondMembreDuProblemeLineaire(PROBLEME_HEBDO*, int, int,
void OPT_InitialiserLeSecondMembreDuProblemeQuadratique(PROBLEME_HEBDO*, int);
void OPT_InitialiserLesCoutsLineaire(PROBLEME_HEBDO*, const int, const int);
void OPT_InitialiserLesCoutsQuadratiques(PROBLEME_HEBDO*, int);
void OPT_ControleDesPminPmaxThermiques(PROBLEME_HEBDO*);
bool OPT_AppelDuSolveurQuadratique(PROBLEME_ANTARES_A_RESOUDRE*, const int);

using namespace Antares::Data::AdequacyPatch;
Expand Down
3 changes: 1 addition & 2 deletions src/solver/optimisation/opt_alloc_probleme_a_optimiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
*/

#include <antares/logs/logs.h>
#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

using namespace Antares;
int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*);

void OPT_AllocateFromNumberOfVariableConstraints(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre,
int NbTermes)
Expand Down
29 changes: 7 additions & 22 deletions src/solver/optimisation/opt_appel_solveur_lineaire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,23 @@
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include <yuni/yuni.h>

#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"
#include "antares/solver/simulation/simulation.h"
#include "antares/solver/utils/basis_status.h"

extern "C"
{
#include "spx_definition_arguments.h"
#include "spx_fonctions.h"
#include "srs_api.h"
}

#include <chrono>
#include <spx_definition_arguments.h>
#include <spx_fonctions.h>

#include <antares/antares/fatal-error.h>
#include <antares/logs/logs.h>
#include "antares/optimization-options/options.h"
#include "antares/solver/infeasible-problem-analysis/unfeasible-pb-analyzer.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"
#include "antares/solver/utils/filename.h"
#include "antares/solver/utils/mps_utils.h"

using namespace operations_research;

using namespace Antares;
using namespace Antares::Data;
using namespace Yuni;
using Antares::Solver::IResultWriter;
using Antares::Solver::Optimization::OptimizationOptions;

class TimeMeasurement
{
Expand Down Expand Up @@ -267,11 +255,8 @@ static SimplexResult OPT_TryToCallSimplex(const OptimizationOptions& options,

logs.info() << " Solver: Standard resolution failed";
logs.info() << " Solver: Retry in safe mode"; // second trial w/o scaling
logs.debug() << " solver: resetting";

if (Logs::Verbosity::Debug::enabled)
{
logs.info() << " solver: resetting";
}
return {.success = false,
.timeMeasure = timeMeasure,
.mps_writer_factory = mps_writer_factory};
Expand Down
12 changes: 5 additions & 7 deletions src/solver/optimisation/opt_appel_solveur_quadratique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,22 @@

#include <limits>

#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"

/*
pi_define.h doesn't include this header, yet it uses struct jmp_buf.
It would be nice to remove this include, but would require to change pi_define.h,
which isn't part of Antares
*/
#include <setjmp.h>

#include <setjmp.h>
extern "C"
{
#include "pi_define.h"
#include "pi_definition_arguments.h"
#include "pi_fonctions.h"
#include <pi_constantes_externes.h>
#include <pi_definition_arguments.h>
#include <pi_fonctions.h>
}

#include <antares/logs/logs.h>
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"

using namespace Antares;

Expand Down
7 changes: 1 addition & 6 deletions src/solver/optimisation/opt_calcul_des_pmin_MUT_MDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include <math.h>

#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_donnees.h"
#include "antares/solver/simulation/simulation.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

constexpr double ZERO_PMIN = 1.e-2;

Expand Down
3 changes: 1 addition & 2 deletions src/solver/optimisation/opt_chainage_intercos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/simulation/simulation.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

void OPT_ChainagesDesIntercoPartantDUnNoeud(PROBLEME_HEBDO* problemeHebdo)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/solver/optimisation/opt_fonctions.h"
#include <spx_constantes_externes.h>

#include "antares/solver/optimisation/opt_rename_problem.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

#include "spx_constantes_externes.h"
#include "variables/VariableManagerUtils.h"

void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireCoutsDeDemarrage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
*/
#include <spx_constantes_externes.h>

#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_rename_problem.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

#include "variables/VariableManagerUtils.h"

void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireCoutsDeDemarrage(PROBLEME_HEBDO*,
bool);

void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaire(PROBLEME_HEBDO* problemeHebdo)
{
const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/sim_structure_donnees.h"
#include "antares/solver/simulation/simulation.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

#include "pi_constantes_externes.h"
#include "variables/VariableManagerUtils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
*/

#include <antares/antares/fatal-error.h>
#include <antares/logs/logs.h>
#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
#include "antares/solver/simulation/simulation.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

using namespace Antares;

void OPT_DecompteDesVariablesEtDesContraintesCoutsDeDemarrage(PROBLEME_HEBDO*);

int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO* problemeHebdo)
{
const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "antares/solver/optimisation/LinearProblemMatrixStartUpCosts.h"
#include "antares/solver/optimisation/constraints/constraint_builder_utils.h"
#include "antares/solver/optimisation/opt_fonctions.h"
#include "antares/solver/simulation/simulation.h"

void OPT_DecompteDesVariablesEtDesContraintesCoutsDeDemarrage(PROBLEME_HEBDO* problemeHebdo)
{
Expand All @@ -37,6 +35,4 @@ void OPT_DecompteDesVariablesEtDesContraintesCoutsDeDemarrage(PROBLEME_HEBDO* pr

OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireCoutsDeDemarrage(problemeHebdo,
true);

return;
}
2 changes: 1 addition & 1 deletion src/solver/optimisation/opt_export_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "antares/solver/optimisation/opt_export_structure.h"

#include <sstream>
#include <string>

#include "antares/solver/simulation/sim_structure_probleme_economique.h"

Expand Down
Loading

0 comments on commit c4b9373

Please sign in to comment.