Skip to content

Commit

Permalink
handle case where 1-d list is given
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimosts committed Sep 7, 2023
1 parent 0e3e906 commit e2a878e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cpmpy/solvers/ortools.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,13 @@ def solution_hint(self, cpm_vars, vals):
"""
self.ort_model.ClearHints() # because add just appends

if hasattr(cpm_vars, "flat"):
cpm_vars= cpm_vars.flat
else:
cpm_vars = np.concatenate(cpm_vars).flat
if not hasattr(cpm_vars, "flat"):
cpm_vars = np.array(cpm_vars)
cpm_vars=cpm_vars.flat

if hasattr(vals, "flat"):
vals = vals.flat
else:
vals = np.concatenate(vals).flat
if not hasattr(vals, "flat"):
vals = np.array(vals)
vals=vals.flat

assert (len(cpm_vars) == len(vals)), "Variables and values must have the same size for hinting"

Expand Down

0 comments on commit e2a878e

Please sign in to comment.