Skip to content

Commit

Permalink
fix warnings on solvers interfaces (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir authored Sep 13, 2024
1 parent 12c3891 commit c850bd5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/cpp/helpers/solver_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ void solver_addcols(SolverAbstract &solver_p, std::vector<double> 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<int>(colTypes_p.size());
int ncolInit = static_cast<int>(solver_p.get_ncols());
int newnnz = static_cast<int>(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());
Expand Down Expand Up @@ -65,11 +65,11 @@ void solver_addrows(SolverAbstract &solver_p, std::vector<char> 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<int>(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<int>(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<double> &x_p)
Expand Down
1 change: 0 additions & 1 deletion src/cpp/multisolver_interface/SolverCbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
17 changes: 9 additions & 8 deletions src/cpp/multisolver_interface/SolverXpress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,16 @@ int SolverXpress::get_col_index(std::string const &name) {
return id;
}

std::vector<std::string> SolverXpress::get_names(int type, size_t nelements) {
std::vector<std::string> 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');
Expand Down Expand Up @@ -404,7 +404,8 @@ void SolverXpress::add_names(int type, const std::vector<std::string> &cnames,
void SolverXpress::chg_obj(const std::vector<int> &mindex,
const std::vector<double> &obj) {
assert(obj.size() == mindex.size());
int status = XPRSchgobj(_xprs, obj.size(), mindex.data(), obj.data());
int status = XPRSchgobj(_xprs, static_cast<int>(obj.size()), mindex.data(),
obj.data());
zero_status_check(status, "change objective", LOGLOCATION);
}

Expand All @@ -419,16 +420,16 @@ void SolverXpress::chg_bounds(const std::vector<int> &mindex,
const std::vector<double> &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<int>(mindex.size()),
mindex.data(), qbtype.data(), bnd.data());
zero_status_check(status, "change bounds", LOGLOCATION);
}

void SolverXpress::chg_col_type(const std::vector<int> &mindex,
const std::vector<char> &qctype) {
assert(qctype.size() == mindex.size());
int status =
XPRSchgcoltype(_xprs, mindex.size(), mindex.data(), qctype.data());
int status = XPRSchgcoltype(_xprs, static_cast<int>(mindex.size()),
mindex.data(), qctype.data());
zero_status_check(status, "change column types", LOGLOCATION);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/multisolver_interface/SolverXpress.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class SolverXpress : public SolverAbstract {
std::ofstream _log_stream;

private:
std::vector<std::string> get_names(int type, size_t nelements);
std::vector<std::string> get_names(int type, int n_elements);
};

/************************************************************************************\
Expand Down

0 comments on commit c850bd5

Please sign in to comment.