From c850bd5ffb9a5188bc583840dae254599a2036a1 Mon Sep 17 00:00:00 2001 From: Abdoulbari Zaher <32519851+a-zakir@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:01:35 +0200 Subject: [PATCH] fix warnings on solvers interfaces (#928) --- src/cpp/helpers/solver_utils.cc | 14 +++++++------- src/cpp/multisolver_interface/SolverCbc.cpp | 1 - src/cpp/multisolver_interface/SolverXpress.cpp | 17 +++++++++-------- src/cpp/multisolver_interface/SolverXpress.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cpp/helpers/solver_utils.cc b/src/cpp/helpers/solver_utils.cc index a328c2da7..2a7f31f53 100644 --- a/src/cpp/helpers/solver_utils.cc +++ b/src/cpp/helpers/solver_utils.cc @@ -29,9 +29,9 @@ void solver_addcols(SolverAbstract &solver_p, std::vector const &objx_p, assert((objx_p.size() == mstart_p.size()) || (mstart_p.size() == 0)); assert(mrwind_p.size() == dmatval_p.size()); - int newCols = colTypes_p.size(); - int ncolInit = solver_p.get_ncols(); - int newnnz = dmatval_p.size(); + int newCols = static_cast(colTypes_p.size()); + int ncolInit = static_cast(solver_p.get_ncols()); + int newnnz = static_cast(dmatval_p.size()); solver_p.add_cols(newCols, newnnz, objx_p.data(), mstart_p.data(), mrwind_p.data(), dmatval_p.data(), bdl_p.data(), bdu_p.data()); @@ -65,11 +65,11 @@ void solver_addrows(SolverAbstract &solver_p, std::vector const &qrtype_p, assert((range_p.size() == 0) || (range_p.size() == qrtype_p.size())); assert(mclind_p.size() == dmatval_p.size()); - int nrows = rhs_p.size(); + int nrows = static_cast(rhs_p.size()); - solver_p.add_rows(nrows, dmatval_p.size(), qrtype_p.data(), rhs_p.data(), - range_p.data(), mstart_p.data(), mclind_p.data(), - dmatval_p.data(), names); + solver_p.add_rows(nrows, static_cast(dmatval_p.size()), qrtype_p.data(), + rhs_p.data(), range_p.data(), mstart_p.data(), + mclind_p.data(), dmatval_p.data(), names); } void solver_getlpsolution(SolverAbstract::Ptr const solver_p, std::vector &x_p) 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/multisolver_interface/SolverXpress.cpp b/src/cpp/multisolver_interface/SolverXpress.cpp index 341b9bf0b..fbbed0b9e 100644 --- a/src/cpp/multisolver_interface/SolverXpress.cpp +++ b/src/cpp/multisolver_interface/SolverXpress.cpp @@ -297,16 +297,16 @@ int SolverXpress::get_col_index(std::string const &name) { return id; } -std::vector SolverXpress::get_names(int type, size_t nelements) { +std::vector SolverXpress::get_names(int type, int n_elements) { int xprs_name_length; zero_status_check(XPRSgetintattrib(_xprs, XPRS_NAMELENGTH, &xprs_name_length), "get xprs name length", LOGLOCATION); std::string names_in_one_string; - names_in_one_string.resize((8 * xprs_name_length + 1) * nelements); + names_in_one_string.resize((8 * xprs_name_length + 1) * n_elements); zero_status_check( - XPRSgetnames(_xprs, type, names_in_one_string.data(), 0, nelements - 1), + XPRSgetnames(_xprs, type, names_in_one_string.data(), 0, n_elements - 1), "get " + TYPETONAME.at(type) + " names.", LOGLOCATION); return StringManip::split(StringManip::trim(names_in_one_string), '\0'); @@ -404,7 +404,8 @@ void SolverXpress::add_names(int type, const std::vector &cnames, void SolverXpress::chg_obj(const std::vector &mindex, const std::vector &obj) { assert(obj.size() == mindex.size()); - int status = XPRSchgobj(_xprs, obj.size(), mindex.data(), obj.data()); + int status = XPRSchgobj(_xprs, static_cast(obj.size()), mindex.data(), + obj.data()); zero_status_check(status, "change objective", LOGLOCATION); } @@ -419,16 +420,16 @@ void SolverXpress::chg_bounds(const std::vector &mindex, const std::vector &bnd) { assert(qbtype.size() == mindex.size()); assert(bnd.size() == mindex.size()); - int status = XPRSchgbounds(_xprs, mindex.size(), mindex.data(), qbtype.data(), - bnd.data()); + int status = XPRSchgbounds(_xprs, static_cast(mindex.size()), + mindex.data(), qbtype.data(), bnd.data()); zero_status_check(status, "change bounds", LOGLOCATION); } void SolverXpress::chg_col_type(const std::vector &mindex, const std::vector &qctype) { assert(qctype.size() == mindex.size()); - int status = - XPRSchgcoltype(_xprs, mindex.size(), mindex.data(), qctype.data()); + int status = XPRSchgcoltype(_xprs, static_cast(mindex.size()), + mindex.data(), qctype.data()); zero_status_check(status, "change column types", LOGLOCATION); } diff --git a/src/cpp/multisolver_interface/SolverXpress.h b/src/cpp/multisolver_interface/SolverXpress.h index 0c6226057..deb82874c 100644 --- a/src/cpp/multisolver_interface/SolverXpress.h +++ b/src/cpp/multisolver_interface/SolverXpress.h @@ -196,7 +196,7 @@ class SolverXpress : public SolverAbstract { std::ofstream _log_stream; private: - std::vector get_names(int type, size_t nelements); + std::vector get_names(int type, int n_elements); }; /************************************************************************************\