Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cpmpy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"""
import copy
import warnings
import time

import numpy as np

Expand Down Expand Up @@ -183,6 +184,7 @@ def solve(self, solver=None, time_limit=None, **kwargs):
- True if a solution is found (not necessarily optimal, e.g. could be after timeout)
- False if no solution is found
"""
start_time = time.time()
if kwargs and solver is None:
raise NotSupportedError("Specify the solver when using kwargs, since they are solver-specific!")

Expand All @@ -193,7 +195,8 @@ def solve(self, solver=None, time_limit=None, **kwargs):
s = SolverLookup.get(solver, self)

# call solver
ret = s.solve(time_limit=time_limit, **kwargs)
remaining_time_limit = None if time_limit is None else time_limit - (time.time() - start_time)
ret = s.solve(time_limit=remaining_time_limit, **kwargs)
# store CPMpy status (s object has no further use)
self.cpm_status = s.status()
return ret
Expand Down
Loading