diff --git a/src/cpp/benders/benders_core/BendersBase.cpp b/src/cpp/benders/benders_core/BendersBase.cpp index 408c260d0..9786d8ae5 100644 --- a/src/cpp/benders/benders_core/BendersBase.cpp +++ b/src/cpp/benders/benders_core/BendersBase.cpp @@ -345,7 +345,6 @@ void BendersBase::ComputeXCut() { void BendersBase::ComputeInvestCost() { _data.invest_cost = 0; - int ncols = _master->_solver->get_ncols(); std::vector obj(MasterObjectiveFunctionCoeffs()); for (const auto &[col_name, value] : _data.x_cut) { diff --git a/src/cpp/benders/factories/BendersFactory.cpp b/src/cpp/benders/factories/BendersFactory.cpp index 772538136..e8c7feb57 100644 --- a/src/cpp/benders/factories/BendersFactory.cpp +++ b/src/cpp/benders/factories/BendersFactory.cpp @@ -163,7 +163,6 @@ int BendersMainFactory::RunExternalLoop() const { &criterion_computation); double tau = 0.5; - double epsilon_lambda = 0.1; std::shared_ptr master_updater = std::make_shared( diff --git a/src/cpp/helpers/ArchiveWriter.cpp b/src/cpp/helpers/ArchiveWriter.cpp index 8f8ba622d..a4a69683e 100644 --- a/src/cpp/helpers/ArchiveWriter.cpp +++ b/src/cpp/helpers/ArchiveWriter.cpp @@ -59,7 +59,8 @@ int32_t ArchiveWriter::AddFileInArchive(const FileBuffer& FileBufferToAdd) { } const auto len = FileBufferToAdd.buffer.size(); auto bw = mz_zip_writer_entry_write(pmz_zip_writer_instance_, - FileBufferToAdd.buffer.c_str(), len); + FileBufferToAdd.buffer.c_str(), + static_cast(len)); if (bw != len) { Close(); Delete(); diff --git a/src/cpp/lpnamer/model/Candidate.h b/src/cpp/lpnamer/model/Candidate.h index 68e418dee..a8bbd0537 100644 --- a/src/cpp/lpnamer/model/Candidate.h +++ b/src/cpp/lpnamer/model/Candidate.h @@ -8,21 +8,21 @@ struct CandidateData { bool enable = true; - std::string link_name; - int link_id; - std::string linkor; - std::string linkex; - std::string installed_direct_link_profile_name; - std::string installed_indirect_link_profile_name; + std::string link_name = ""; + int link_id = 0; + std::string linkor = ""; + std::string linkex = ""; + std::string installed_direct_link_profile_name = ""; + std::string installed_indirect_link_profile_name = ""; double already_installed_capacity = 1.0; - std::string name; + std::string name = ""; double annual_cost_per_mw = 0.0; double max_investment = 0.0; double unit_size = 0.0; double max_units = 0.0; - std::string direct_link_profile; - std::string indirect_link_profile; + std::string direct_link_profile = ""; + std::string indirect_link_profile = ""; }; /*! diff --git a/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp b/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp index 8c1ee291d..aec3767b9 100644 --- a/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp +++ b/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp @@ -29,9 +29,6 @@ AntaresProblemToXpansionProblemTranslator::translateToXpansionProblem( convertSignToLEG(hebdo->Sens.data()).data(), hebdo->SecondMembre.data(), {}, constant->Mdeb.data(), constant->IndicesColonnes.data(), constant->CoefficientsDeLaMatriceDesContraintes.data()); - auto rows = problem->get_nrows(); - auto cols = problem->get_ncols(); - auto elem = problem->get_nelems(); // On peut ajouter la partie qui renomme les variables ici si on stocke les // données du type de variables dans ConstantDataFromAntares, i.e. en // définissant une autre implémentation de IProblemVariablesProviderPort diff --git a/src/cpp/multisolver_interface/SolverCbc.cpp b/src/cpp/multisolver_interface/SolverCbc.cpp index bf1ebb472..4bfc0b754 100644 --- a/src/cpp/multisolver_interface/SolverCbc.cpp +++ b/src/cpp/multisolver_interface/SolverCbc.cpp @@ -122,7 +122,6 @@ void SolverCbc::write_prob_mps(const std::filesystem::path &filename) { } { - auto mcol = _clp_inner_solver.getMatrixByCol(); auto col = *(_clp_inner_solver.getMatrixByCol()); auto infinity = _clp_inner_solver.getInfinity(); writer.setMpsData( diff --git a/src/cpp/xpansion_interfaces/ILogger.h b/src/cpp/xpansion_interfaces/ILogger.h index 325ce0ccb..95564ff34 100644 --- a/src/cpp/xpansion_interfaces/ILogger.h +++ b/src/cpp/xpansion_interfaces/ILogger.h @@ -46,25 +46,25 @@ inline std::string criterion_to_str( } struct LogData { - double lb; - double best_ub; - double ub; - int it; - int best_it; - double subproblem_cost; - double invest_cost; - LogPoint x_in; - LogPoint x_out; - LogPoint x_cut; - LogPoint min_invest; - LogPoint max_invest; - double optimality_gap; - double relative_gap; - int max_iterations; - double benders_elapsed_time; - double master_time; - double subproblem_time; - int cumulative_number_of_subproblem_resolved; + double lb = 0.; + double best_ub = 0.; + double ub = 0.; + int it = 0; + int best_it = 0; + double subproblem_cost = 0.; + double invest_cost = 0.; + LogPoint x_in = {}; + LogPoint x_out = {}; + LogPoint x_cut = {}; + LogPoint min_invest = {}; + LogPoint max_invest = {}; + double optimality_gap = 0.; + double relative_gap = 0.; + int max_iterations = 0; + double benders_elapsed_time = 0.; + double master_time = 0.; + double subproblem_time = 0.; + int cumulative_number_of_subproblem_resolved = 0; }; /** diff --git a/src/cpp/xpansion_interfaces/OutputWriter.h b/src/cpp/xpansion_interfaces/OutputWriter.h index c474496a0..becb2d780 100644 --- a/src/cpp/xpansion_interfaces/OutputWriter.h +++ b/src/cpp/xpansion_interfaces/OutputWriter.h @@ -27,26 +27,28 @@ const std::string ANTARES_C("antares"), VERSION_C("version"), PROBLEMPATH_C("problem_path"), CUMULATIVE_NUMBER_OF_SUBPROBLEM_RESOLVED_C( "cumulative_number_of_subproblem_resolutions"); + struct CandidateData { - std::string name; - double invest; - double min; - double max; + std::string name = ""; + double invest = 0.; + double min = 0.; + double max = 0.; }; + typedef std::vector CandidatesVec; struct Iteration { - double master_duration; - double subproblem_duration; - double lb; - double ub; - double best_ub; - double optimality_gap; - double relative_gap; - double investment_cost; - double operational_cost; - double overall_cost; - CandidatesVec candidates; - int cumulative_number_of_subproblem_resolved; + double master_duration = 0.; + double subproblem_duration = 0.; + double lb = 0.; + double ub = 0.; + double best_ub = 0.; + double optimality_gap = 0.; + double relative_gap = 0.; + double investment_cost = 0.; + double operational_cost = 0.; + double overall_cost = 0.; + CandidatesVec candidates = {}; + int cumulative_number_of_subproblem_resolved = 0; }; typedef std::vector Iterations; /*! @@ -56,11 +58,11 @@ typedef std::vector Iterations; * solution : solution data as iteration */ struct SolutionData { - Iteration solution; - int nbWeeks_p; - int best_it; - std::string problem_status; - std::string stopping_criterion; + Iteration solution = {}; + int nbWeeks_p = 0; + int best_it = 0; + std::string problem_status = ""; + std::string stopping_criterion = ""; }; /*! * \brief struct containing some entries to be later written to the json file @@ -73,16 +75,18 @@ struct SolutionData { * max_iter : maximum number of iterations */ struct IterationsData { - int nbWeeks_p; - double elapsed_time; - Iterations iters; - SolutionData solution_data; + int nbWeeks_p = 0; + double elapsed_time = 0; + Iterations iters = {}; + SolutionData solution_data = {}; }; + struct ProblemData { - std::string name; - std::filesystem::path path; - std::string status; + std::string name = ""; + std::filesystem::path path = ""; + std::string status = ""; }; + /*! * \class OutputWriter * \brief OutputWriter class to describe the execuion session of an antares diff --git a/tests/cpp/logger/logger_test.cpp b/tests/cpp/logger/logger_test.cpp index 2fcfc1a24..9e14096dd 100644 --- a/tests/cpp/logger/logger_test.cpp +++ b/tests/cpp/logger/logger_test.cpp @@ -949,14 +949,11 @@ TEST(MathLoggerBendersByBatchTest, DataInFileLong) { } TEST(MathLoggerBendersByBatchTest, DataInStdOutShort) { - HEADERSTYPE headers_type = HEADERSTYPE::SHORT; std::streamsize width = 25; CurrentIterationData data; data.it = 35; data.lb = 256999; - // data.ub = 222256999; - // data.best_ub = 222256999; data.min_simplexiter = 3; data.max_simplexiter = 30; data.number_of_subproblem_solved = 657; @@ -965,8 +962,6 @@ TEST(MathLoggerBendersByBatchTest, DataInStdOutShort) { data.timer_master = 10; data.subproblems_walltime = 16; data.subproblems_cumulative_cputime = 160; - auto time_not_solving = - data.iteration_time - data.timer_master - data.subproblems_walltime; std::ostringstream expected_msg; expected_msg << std::left << std::setw(width) << data.it; @@ -1055,7 +1050,6 @@ TEST(MathLoggerBendersBaseTest, DataInFileLong) { } TEST(MathLoggerBendersBaseTest, DataInStdOutShort) { - HEADERSTYPE headers_type = HEADERSTYPE::SHORT; std::streamsize width = 25; CurrentIterationData data; @@ -1071,8 +1065,6 @@ TEST(MathLoggerBendersBaseTest, DataInStdOutShort) { data.timer_master = 10; data.subproblems_walltime = 16; data.subproblems_cumulative_cputime = 160; - auto time_not_solving = - data.iteration_time - data.timer_master - data.subproblems_walltime; std::ostringstream expected_msg; expected_msg << std::left << std::setw(width) << data.it; diff --git a/tests/cpp/lp_namer/ProblemModifierTest.cpp b/tests/cpp/lp_namer/ProblemModifierTest.cpp index f8749efb8..8d7d2a16a 100644 --- a/tests/cpp/lp_namer/ProblemModifierTest.cpp +++ b/tests/cpp/lp_namer/ProblemModifierTest.cpp @@ -701,7 +701,6 @@ TEST_F(ProblemModifierTest, candidateWithNullProfileIsRemoved) { p_direct_cost_columns, p_indirect_cost_columns); - const int cand1_id = -1; ASSERT_THROW(problem_modifier.get_candidate_col_id(cand1.name), std::runtime_error); @@ -936,7 +935,6 @@ TEST_F(ProblemModifierTestMultiChronicle, candidateWithNotNullProfileExists) { p_direct_cost_columns, p_indirect_cost_columns); - const int cand1_id = 3; ASSERT_TRUE(problem_modifier.has_candidate_col_id(cand1.name)); } diff --git a/tests/cpp/outer_loop/outer_loop_test.cpp b/tests/cpp/outer_loop/outer_loop_test.cpp index 45e19101f..61cd87bd3 100644 --- a/tests/cpp/outer_loop/outer_loop_test.cpp +++ b/tests/cpp/outer_loop/outer_loop_test.cpp @@ -147,7 +147,6 @@ TEST_P(MasterUpdateBaseTest, ConstraintIsAddedBendersMPI) { // get added constraint infos (coeff, sign & rhs) std::vector mstart(1 + 1); auto n_elems = benders->MasterGetNElems(); - auto nnz = master_variables.size(); std::vector mclind(n_elems); std::vector matval(n_elems); std::vector p_nels(1, 0); diff --git a/tests/cpp/zip_mps/zip_mps_lib_tests.cpp b/tests/cpp/zip_mps/zip_mps_lib_tests.cpp index e70c5ca33..ce7ff167f 100644 --- a/tests/cpp/zip_mps/zip_mps_lib_tests.cpp +++ b/tests/cpp/zip_mps/zip_mps_lib_tests.cpp @@ -139,17 +139,17 @@ void compareArchiveAndDir(const std::filesystem::path& archivePath, reader = mz_zip_reader_create(); const auto& archive_path_str = archivePath.string(); auto archive_path_c_str = archive_path_str.c_str(); - assert(mz_zip_reader_open_file(reader, archive_path_c_str) == MZ_OK); + ASSERT_EQ(mz_zip_reader_open_file(reader, archive_path_c_str), MZ_OK); for (const auto& file : std::filesystem::directory_iterator(dirPath)) { const auto& filename_path = file.path().filename(); const auto& filename_str = filename_path.string(); const auto searchFilename = filename_str.c_str(); - assert(mz_zip_reader_locate_entry(reader, searchFilename, 1) == MZ_OK); - assert(mz_zip_reader_entry_open(reader) == MZ_OK); + ASSERT_EQ(mz_zip_reader_locate_entry(reader, searchFilename, 1), MZ_OK); + ASSERT_EQ(mz_zip_reader_entry_open(reader), MZ_OK); const auto extractedFilePath = tmpDir / searchFilename; mz_zip_reader_entry_save_file(reader, extractedFilePath.string().c_str()); - assert(equal_files(extractedFilePath, file.path())); + ASSERT_TRUE(equal_files(extractedFilePath, file.path())); } mz_zip_reader_close(reader); mz_zip_reader_delete(&reader);