Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
feead09
WCNF parser
ThomSerg Sep 11, 2025
5ade48e
Small docstring change
ThomSerg Sep 11, 2025
7f52f5f
OPB parser
ThomSerg Sep 11, 2025
548de8e
Move parser out of init and add cli
ThomSerg Sep 12, 2025
4505025
Add MSE and OPB datasets
ThomSerg Sep 12, 2025
2b26034
Rename datasets to dataset
ThomSerg Sep 12, 2025
e238c29
Dataset specific 'open'
ThomSerg Sep 12, 2025
669875a
Dataset module init file
ThomSerg Sep 12, 2025
c1bd2fe
Add benchmark runners
ThomSerg Sep 12, 2025
83454e0
Formatting
ThomSerg Sep 12, 2025
7f2d363
XCSP3 as dataset and benchmark
ThomSerg Sep 12, 2025
9173c9f
Parsers with changeable 'open'
ThomSerg Sep 12, 2025
52b95de
Type-hints and docstrings
ThomSerg Sep 12, 2025
bf5ecd2
Add TODOs
ThomSerg Sep 12, 2025
5dc3886
Mising helper functions
ThomSerg Sep 12, 2025
7209c62
Print stacktrace of process
ThomSerg Sep 12, 2025
f66c8c5
Fix arguments
ThomSerg Sep 12, 2025
6ab8b32
Fix overwritten open
ThomSerg Sep 12, 2025
34c8a9e
Read as string instead of StringIO
ThomSerg Sep 12, 2025
fd55b3a
Read as text instead of binary
ThomSerg Sep 12, 2025
2be9fa6
Sigterm callbacks
ThomSerg Sep 12, 2025
2e64623
Attempt at fixing some nested memory exceptions
ThomSerg Sep 12, 2025
5b92680
Overwritable exit status
ThomSerg Sep 12, 2025
8fff254
Validate dataset arguments
ThomSerg Sep 12, 2025
2b4a8f0
Check non-empty dataset
ThomSerg Sep 12, 2025
b68144d
Add feedback finished downloading
ThomSerg Sep 12, 2025
b08df43
Small fixes
ThomSerg Sep 12, 2025
431b065
Fix intermediate solutions and time tracking
ThomSerg Oct 10, 2025
7d98c35
Increase intermediate solution time resolution
ThomSerg Oct 10, 2025
4664051
Missing default return argument
ThomSerg Oct 10, 2025
582fc96
Only import "resource" when supported
ThomSerg Oct 17, 2025
2eea41c
remove var x0 which is not used in opb
OrestisLomis Oct 23, 2025
6111fc4
rcpsp dataset and benchmark
ThomSerg Oct 24, 2025
af36c87
opb fix intermediate solutions
ThomSerg Oct 24, 2025
a834387
update docstrings
ThomSerg Oct 24, 2025
8805cad
Fix more docstring
ThomSerg Oct 24, 2025
ce6b6bc
Add JSPLib dataset and benchmark
ThomSerg Oct 24, 2025
9098299
Add bounds for all jsplib instances
ThomSerg Oct 24, 2025
658967d
Fix choco args
ThomSerg Oct 25, 2025
eb41634
Merge branch 'benchmark_datasets' of https://github.com/CPMpy/cpmpy i…
ThomSerg Oct 25, 2025
38db290
Fixes
ThomSerg Oct 25, 2025
41e3768
Merge remote-tracking branch 'origin/master' into benchmark_datasets
ThomSerg Oct 27, 2025
62b605d
correct jsplib output file name
ThomSerg Nov 3, 2025
ddf6938
remove matplotlib import
ThomSerg Nov 3, 2025
344aaaf
xcsp3 track intermediate sol time
ThomSerg Nov 3, 2025
7cd1bb1
opb print intermediate solutions
ThomSerg Nov 3, 2025
a21a040
mse print intermediate solutions
ThomSerg Nov 3, 2025
eda839c
cplex and hexaly solver arguments
ThomSerg Nov 3, 2025
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
67 changes: 67 additions & 0 deletions cpmpy/tools/benchmark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import sys
import time
import warnings
import psutil


TIME_BUFFER = 5 # seconds
# TODO : see if good value
MEMORY_BUFFER_SOFT = 2 # MiB
MEMORY_BUFFER_HARD = 0 # MiB
MEMORY_BUFFER_SOLVER = 20 # MB



def set_memory_limit(mem_limit):
"""
Set memory limit (Virtual Memory Size).
"""
if mem_limit is not None:
soft = max(_mib_as_bytes(mem_limit) - _mib_as_bytes(MEMORY_BUFFER_SOFT), _mib_as_bytes(MEMORY_BUFFER_SOFT))
hard = max(_mib_as_bytes(mem_limit) - _mib_as_bytes(MEMORY_BUFFER_HARD), _mib_as_bytes(MEMORY_BUFFER_HARD))
if sys.platform != "win32":
import resource
resource.setrlimit(resource.RLIMIT_AS, (soft, hard)) # limit memory in number of bytes
else:
warnings.warn("Memory limits using `resource` are not supported on Windows. Skipping hard limit.")

def disable_memory_limit():
if sys.platform != "win32":
import resource
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
# set a very high soft limit
resource.setrlimit(resource.RLIMIT_AS, (hard, hard))

def set_time_limit(time_limit, verbose:bool=False):
"""
Set time limit (CPU time in seconds).
"""
if time_limit is not None:
if sys.platform != "win32":
import resource
soft = time_limit
hard = resource.RLIM_INFINITY
resource.setrlimit(resource.RLIMIT_CPU, (soft, hard))
else:
warnings.warn("CPU time limits using `resource` are not supported on Windows. Skipping hard limit.")

def _wall_time(p: psutil.Process):
return time.time() - p.create_time()

def _mib_as_bytes(mib: int) -> int:
return mib * 1024 * 1024

def _mb_as_bytes(mb: int) -> int:
return mb * 1000 * 1000

def _bytes_as_mb(bytes: int) -> int:
return bytes // (1000 * 1000)

def _bytes_as_gb(bytes: int) -> int:
return bytes // (1000 * 1000 * 1000)

def _bytes_as_mb_float(bytes: int) -> float:
return bytes / (1000 * 1000)

def _bytes_as_gb_float(bytes: int) -> float:
return bytes / (1000 * 1000 * 1000)
Loading
Loading