diff --git a/src/solver/optimisation/opt_optimisation_lineaire.cpp b/src/solver/optimisation/opt_optimisation_lineaire.cpp index ecb0231f11..b0fb17effc 100644 --- a/src/solver/optimisation/opt_optimisation_lineaire.cpp +++ b/src/solver/optimisation/opt_optimisation_lineaire.cpp @@ -67,29 +67,33 @@ void OPT_WriteSolution(const PROBLEME_ANTARES_A_RESOUDRE& pb, int optimizationNumber, Solver::IResultWriter& writer) { + auto s = [](int x) { return static_cast(x); }; + Yuni::Clob buffer; auto filename = createSolutionFilename(optPeriodStringGenerator, optimizationNumber); for (int var = 0; var < pb.NombreDeVariables; var++) { - buffer.appendFormat("%s\t%11.10e\n", pb.NomDesVariables[var].c_str(), pb.X[var]); + buffer.appendFormat("%s\t%11.10e\n", pb.NomDesVariables[s(var)].c_str(), pb.X[s(var)]); } writer.addEntryFromBuffer(filename, buffer); buffer.clear(); filename = createMarginalCostFilename(optPeriodStringGenerator, optimizationNumber); - for (unsigned int cont = 0; cont < pb.NombreDeContraintes; ++cont) + for (int cont = 0; cont < pb.NombreDeContraintes; ++cont) { buffer.appendFormat("%s\t%11.10e\n", - pb.NomDesContraintes[cont].c_str(), - pb.CoutsMarginauxDesContraintes[cont]); + pb.NomDesContraintes[s(cont)].c_str(), + pb.CoutsMarginauxDesContraintes[s(cont)]); } writer.addEntryFromBuffer(filename, buffer); buffer.clear(); filename = createReducedCostFilename(optPeriodStringGenerator, optimizationNumber); - for (unsigned int var = 0; var < pb.NombreDeVariables; ++var) + for (int var = 0; var < pb.NombreDeVariables; ++var) { - buffer.appendFormat("%s\t%11.10e\n", pb.NomDesVariables[var].c_str(), pb.CoutsReduits[var]); + buffer.appendFormat("%s\t%11.10e\n", + pb.NomDesVariables[s(var)].c_str(), + pb.CoutsReduits[s(var)]); } writer.addEntryFromBuffer(filename, buffer); } diff --git a/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h b/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h index a3eac2966a..617d3ed772 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h +++ b/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h @@ -63,30 +63,29 @@ struct VCardPriceCSR //! The VCard to look for for calculating spatial aggregates typedef VCardPrice VCardForSpatialAggregate; - enum - { - //! Data Level - categoryDataLevel = Category::DataLevel::area, - //! File level (provided by the type of the results) - categoryFileLevel = ResultsType::categoryFile - & (Category::FileLevel::id | Category::FileLevel::va), - //! Precision (views) - precision = Category::all, - //! Indentation (GUI) - nodeDepthForGUI = +0, - //! Decimal precision - decimal = 2, - //! Number of columns used by the variable (One ResultsType per column) - columnCount = 1, - //! The Spatial aggregation - spatialAggregate = Category::spatialAggregateAverage, - spatialAggregateMode = Category::spatialAggregateEachYear, - spatialAggregatePostProcessing = Category::spatialAggregatePostProcessingPrice, - //! Intermediate values - hasIntermediateValues = 1, - //! Can this variable be non applicable (0 : no, 1 : yes) - isPossiblyNonApplicable = 0, - }; + //! Data Level + static constexpr uint8_t categoryDataLevel = Category::DataLevel::area; + //! File level (provided by the type of the results) + static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile + & (Category::FileLevel::id + | Category::FileLevel::va); + //! Precision (views) + static constexpr uint8_t precision = Category::all; + //! Indentation (GUI) + static constexpr uint8_t nodeDepthForGUI = +0; + //! Decimal precision + static constexpr uint8_t decimal = 2; + //! Number of columns used by the variable (One ResultsType per column) + static constexpr int columnCount = 1; + //! The Spatial aggregation + static constexpr uint8_t spatialAggregate = Category::spatialAggregateAverage; + static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear; + static constexpr uint8_t spatialAggregatePostProcessing = Category:: + spatialAggregatePostProcessingPrice; + //! Intermediate values + static constexpr uint8_t hasIntermediateValues = 1; + //! Can this variable be non applicable (0 : no, 1 : yes) + static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; typedef IntermediateValues* IntermediateValuesType; diff --git a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp index d4340dce12..7c3cfd67ad 100644 --- a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp +++ b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp @@ -661,7 +661,7 @@ BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_ValidRhs) iniFile.close(); std::ofstream rhsFile(testPath / "rhs_constraint1.txt"); - for (int i = 0; i < HOURS_PER_YEAR; ++i) + for (unsigned int i = 0; i < HOURS_PER_YEAR; ++i) { rhsFile << i * 1.0 << "\n"; } @@ -704,7 +704,7 @@ BOOST_AUTO_TEST_CASE(Load2ConstraintsFromIniFile) iniFile.close(); std::ofstream rhsFile(testPath / "rhs_constraint1.txt"); - for (int i = 0; i < HOURS_PER_YEAR; ++i) + for (unsigned int i = 0; i < HOURS_PER_YEAR; ++i) { rhsFile << i * 1.0 << "\n"; } @@ -882,7 +882,7 @@ BOOST_DATA_TEST_CASE(Validate_AllVariableOperatorCombinationsFromFile, // Write the `rhs_constraint1.txt` file std::ofstream rhsFile(testPath / "rhs_constraint1.txt"); - for (int i = 0; i < HOURS_PER_YEAR; ++i) + for (unsigned int i = 0; i < HOURS_PER_YEAR; ++i) { rhsFile << i * 1.0 << "\n"; } @@ -911,7 +911,7 @@ BOOST_DATA_TEST_CASE(Validate_AllVariableOperatorCombinationsFromFile, BOOST_CHECK_EQUAL(loadedConstraint.operatorType, op); BOOST_REQUIRE_EQUAL(loadedConstraint.rhs.size(), HOURS_PER_YEAR); - int i = 0; + unsigned int i = 0; do { BOOST_CHECK_CLOSE(loadedConstraint.rhs[i], i * 1.0, 0.001); diff --git a/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp b/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp index c1a5a52ec9..9d356be167 100644 --- a/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp +++ b/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp @@ -122,7 +122,7 @@ void LinearProblemBuildingFixture::createModel(string modelId, { Antares::Solver::NodeRegistry node_registry(node, move(nodes)); Expression expression("expression", move(node_registry)); - return move(expression); + return expression; }; vector parameters; for (auto parameter_id: parameterIds)