WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 189f581

Browse files
Hack once_flag
1 parent 61e4450 commit 189f581

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/solver/optimisation/include/antares/solver/optimisation/opt_fonctions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,9 @@ void OPT_InitialiserNombreMinEtMaxDeGroupesCoutsDeDemarrage(PROBLEME_HEBDO*);
110110
void OPT_AjusterLeNombreMinDeGroupesDemarresCoutsDeDemarrage(PROBLEME_HEBDO*);
111111
double OPT_SommeDesPminThermiques(const PROBLEME_HEBDO*, int, uint);
112112

113+
namespace Antares::Solver::Optimization
114+
{
115+
void reset();
116+
}
117+
113118
#endif /* __SOLVER_OPTIMISATION_FUNCTIONS_H__ */

src/solver/optimisation/opt_optimisation_lineaire.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
using namespace Antares::Solver;
3636
using Antares::Solver::Optimization::OptimizationOptions;
3737

38-
std::once_flag export_once;
38+
auto export_once = std::make_unique<std::once_flag>();
3939

4040
namespace
4141
{
@@ -269,7 +269,7 @@ bool OPT_OptimisationLineaire(const OptimizationOptions& options,
269269
problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
270270
if (problemeHebdo->ExportStructure)
271271
{
272-
std::call_once(export_once,
272+
std::call_once(*export_once,
273273
[&problemeHebdo, &writer]()
274274
{ OPT_ExportStructures(problemeHebdo, writer); });
275275
}
@@ -302,3 +302,17 @@ bool OPT_OptimisationLineaire(const OptimizationOptions& options,
302302
}
303303
return ret;
304304
}
305+
306+
namespace Antares::Solver::Optimization
307+
{
308+
/**
309+
* Reset state
310+
*
311+
* Useful for API clients
312+
* Where there is a state there should be a class
313+
*/
314+
void reset()
315+
{
316+
export_once = std::make_unique<std::once_flag>();
317+
}
318+
} // namespace Antares::Solver::Optimization

src/solver/simulation/economy.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Economy::Economy(Data::Study& study,
4242
simulationObserver_(simulationObserver),
4343
simulationTables_(study.parameters.noOutput ? 0 : study.maxNbYearsInParallel)
4444
{
45+
Optimization::reset();
4546
}
4647

4748
Benchmarking::OptimizationInfo Economy::getOptimizationInfo() const

0 commit comments

Comments
 (0)