From cdea17e76826a9152480d7d09caf8f0557ee0f3d Mon Sep 17 00:00:00 2001 From: Ruaridh Williamson Date: Thu, 21 May 2020 17:44:00 +0100 Subject: [PATCH] :bug: Cast quadratic coefficients to floats explicitly --- pyomo/solvers/plugins/solvers/cplex_direct.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyomo/solvers/plugins/solvers/cplex_direct.py b/pyomo/solvers/plugins/solvers/cplex_direct.py index eb74f513c76..5ab58a832da 100644 --- a/pyomo/solvers/plugins/solvers/cplex_direct.py +++ b/pyomo/solvers/plugins/solvers/cplex_direct.py @@ -51,7 +51,7 @@ def __init__( self.offset = offset or 0.0 self.q_variables1 = q_variables1 or [] self.q_variables2 = q_variables2 or [] - self.q_coefficients = q_coefficients or [] + self.q_coefficients = [float(coef) for coef in q_coefficients or []] def _is_numeric(x): @@ -584,7 +584,7 @@ def _set_objective(self, obj): self._solver_model.objective.set_linear(list(zip(cplex_expr.variables, cplex_expr.coefficients))) if quadratic_objective_already_exists or contains_quadratic_terms: - self._solver_model.objective.set_quadratic([0] * num_cols) + self._solver_model.objective.set_quadratic([0.0] * num_cols) if contains_quadratic_terms: self._solver_model.objective.set_quadratic_coefficients(