Skip to content

Commit

Permalink
🐛 Cast quadratic coefficients to floats explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaridhw committed May 27, 2020
1 parent 12af4c4 commit 707babd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyomo/solvers/plugins/solvers/cplex_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 707babd

Please sign in to comment.