Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add problem update time #1110

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/solver/optimisation/opt_appel_solveur_lineaire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool OPT_AppelDuSimplexe(PROBLEME_HEBDO* ProblemeHebdo,
double* pt;
char PremierPassage;
double CoutOpt;
long long solveTime;
long long solveTime, updateTime;
PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre;

PROBLEME_SPX* ProbSpx;
Expand Down Expand Up @@ -184,6 +184,7 @@ bool OPT_AppelDuSimplexe(PROBLEME_HEBDO* ProblemeHebdo,
}
measure.tick();
optimizationStatistics->addUpdateTime(measure.duration_ms());
updateTime = measure.duration_ms();
}
}

Expand Down Expand Up @@ -334,11 +335,13 @@ bool OPT_AppelDuSimplexe(PROBLEME_HEBDO* ProblemeHebdo,
{
ProblemeHebdo->coutOptimalSolution1[NumIntervalle] = CoutOpt;
ProblemeHebdo->tempsResolution1[NumIntervalle] = solveTime;
ProblemeHebdo->updateTime1[NumIntervalle] = updateTime;
}
else
{
ProblemeHebdo->coutOptimalSolution2[NumIntervalle] = CoutOpt;
ProblemeHebdo->tempsResolution2[NumIntervalle] = solveTime;
ProblemeHebdo->updateTime2[NumIntervalle] = updateTime;
}
for (Cnt = 0; Cnt < ProblemeAResoudre->NombreDeContraintes; Cnt++)
{
Expand Down
13 changes: 11 additions & 2 deletions src/solver/simulation/adequacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ bool Adequacy::year(Progression::Task& progression,
pProblemesHebdo[numSpace]->firstWeekOfSimulation = true;
bool reinitOptim = true;

OptimizationStatisticsWriter optWriter(study.resultWriter, state.year);
OptimizationStatisticsWriter optWriter(study.resultWriter,
"weeksSolveTimes_",
state.year);

OptimizationStatisticsWriter updateWriter(study.resultWriter,
"weeksUpdateTimes_",
state.year);

for (uint w = 0; w != pNbWeeks; ++w)
{
Expand Down Expand Up @@ -356,13 +362,16 @@ bool Adequacy::year(Progression::Task& progression,
optWriter.addTime(w,
pProblemesHebdo[numSpace]->tempsResolution1[0],
pProblemesHebdo[numSpace]->tempsResolution2[0]);

updateWriter.addTime(w,
pProblemesHebdo[numSpace]->updateTime1[0],
pProblemesHebdo[numSpace]->updateTime2[0]);
++progression;
}

updatingAnnualFinalHydroLevel(study, *pProblemesHebdo[numSpace]);

optWriter.finalize();
updateWriter.finalize();
finalizeOptimizationStatistics(*pProblemesHebdo[numSpace], state);

return true;
Expand Down
12 changes: 11 additions & 1 deletion src/solver/simulation/economy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ bool Economy::year(Progression::Task& progression,
pProblemesHebdo[numSpace]->firstWeekOfSimulation = true;
bool reinitOptim = true;

OptimizationStatisticsWriter optWriter(study.resultWriter, state.year);
OptimizationStatisticsWriter optWriter(study.resultWriter,
"weeksSolveTimes_",
state.year);

OptimizationStatisticsWriter updateWriter(study.resultWriter,
"weeksUpdateTimes_",
state.year);

for (uint w = 0; w != pNbWeeks; ++w)
{
Expand Down Expand Up @@ -261,6 +267,9 @@ bool Economy::year(Progression::Task& progression,
optWriter.addTime(w,
pProblemesHebdo[numSpace]->tempsResolution1[0],
pProblemesHebdo[numSpace]->tempsResolution2[0]);
updateWriter.addTime(w,
pProblemesHebdo[numSpace]->updateTime1[0],
pProblemesHebdo[numSpace]->updateTime2[0]);
}
catch (Data::AssertionError& ex)
{
Expand Down Expand Up @@ -299,6 +308,7 @@ bool Economy::year(Progression::Task& progression,
updatingAnnualFinalHydroLevel(study, *pProblemesHebdo[numSpace]);

optWriter.finalize();
updateWriter.finalize();
finalizeOptimizationStatistics(*pProblemesHebdo[numSpace], state);

return true;
Expand Down
3 changes: 2 additions & 1 deletion src/solver/simulation/opt_time_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

OptimizationStatisticsWriter::OptimizationStatisticsWriter(
Antares::Solver::IResultWriter::Ptr writer,
const std::string& prefix,
uint year) :
pWriter(writer)
{
printHeader();
#define SEP Yuni::IO::Separator
pFilename << "debug" << SEP << "solver" << SEP << "weeksSolveTimes_" << year << ".txt";
pFilename << "debug" << SEP << "solver" << SEP << prefix << year << ".txt";
#undef SEP
}

Expand Down
3 changes: 2 additions & 1 deletion src/solver/simulation/opt_time_writer.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#pragma once
#include <yuni/core/string.h>
#include <string>
#include <i_writer.h>

#include "simulation.h"

class OptimizationStatisticsWriter
{
public:
OptimizationStatisticsWriter(Antares::Solver::IResultWriter::Ptr writer, uint year);
OptimizationStatisticsWriter(Antares::Solver::IResultWriter::Ptr writer, const std::string& prefix, uint year);
void addTime(uint week, double opt_1_ms, double opt_2_ms);
void finalize();

Expand Down
7 changes: 7 additions & 0 deletions src/solver/simulation/sim_alloc_probleme_hebdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ void SIM_AllocationProblemeHebdo(PROBLEME_HEBDO& problem, int NombreDePasDeTemps

problem.tempsResolution1 = (double*)MemAlloc(7 * sizeof(double));
problem.tempsResolution2 = (double*)MemAlloc(7 * sizeof(double));

problem.updateTime1 = (double*)MemAlloc(7 * sizeof(double));
problem.updateTime2 = (double*)MemAlloc(7 * sizeof(double));

}

void SIM_DesallocationProblemeHebdo(PROBLEME_HEBDO& problem)
Expand Down Expand Up @@ -899,4 +903,7 @@ void SIM_DesallocationProblemeHebdo(PROBLEME_HEBDO& problem)
MemFree(problem.coutOptimalSolution2);
MemFree(problem.tempsResolution1);
MemFree(problem.tempsResolution2);

MemFree(problem.updateTime1);
MemFree(problem.updateTime2);
}
4 changes: 4 additions & 0 deletions src/solver/simulation/sim_structure_probleme_economique.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,13 @@ struct PROBLEME_HEBDO
double* coutOptimalSolution1;
double* coutOptimalSolution2;

// TODO[FOM] Move
double* tempsResolution1;
double* tempsResolution2;

double* updateTime1;
double* updateTime2;

COUTS_MARGINAUX_ZONES_DE_RESERVE** CoutsMarginauxDesContraintesDeReserveParZone;
/* Unused for now, will be used in future revisions */
#if 0
Expand Down
Loading