Skip to content

Commit eaad3cf

Browse files
Wout4Dimosts
andauthored
Update requirements
* requirements for minizinc 2.8.0 added requirements for ortools updated to v9.9 * remove higher minizinc requirement, was for testing * move minimum required version to v2.8.2 * different errors for not installed and outdated. supported() should not raise exceptions * cleanup formatting * remove hard-coded minizinc call --------- Co-authored-by: Dimos Tsouros <[email protected]>
1 parent 6ec19f8 commit eaad3cf

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

cpmpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
# Tias Guns, 2019-2024
1616

17-
__version__ = "0.9.19"
17+
__version__ = "0.9.20"
1818

1919

2020
from .expressions import *

cpmpy/solvers/minizinc.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,32 @@ class CPM_minizinc(SolverInterface):
7171
The `DirectConstraint`, when used, adds a constraint with that name and the given args to the MiniZinc model.
7272
"""
7373

74+
required_version = (2, 8, 2)
7475
@staticmethod
7576
def supported():
77+
return CPM_minizinc.installed() and not CPM_minizinc.outdated()
78+
79+
@staticmethod
80+
def installed():
7681
# try to import the package
7782
try:
7883
import minizinc
7984
return True
8085
except ImportError as e:
8186
return False
8287

88+
@staticmethod
89+
def outdated():
90+
from minizinc import default_driver
91+
if default_driver.parsed_version >= CPM_minizinc.required_version:
92+
return False
93+
else:
94+
#outdated
95+
return True
96+
97+
98+
99+
83100
@staticmethod
84101
def solvernames():
85102
"""
@@ -116,8 +133,13 @@ def __init__(self, cpm_model=None, subsolver=None):
116133
- subsolver: str, name of a subsolver (optional)
117134
has to be one of solvernames()
118135
"""
119-
if not self.supported():
136+
if not self.installed():
120137
raise Exception("CPM_minizinc: Install the python package 'minizinc'")
138+
elif self.outdated():
139+
version = str(self.required_version[0])
140+
for x in self.required_version[1:]:
141+
version = version + "." + str(x)
142+
raise ImportError("Your Minizinc compiler is outdated, please upgrade to a version >= " + version)
121143

122144
import minizinc
123145

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
author = 'Tias Guns'
2525

2626
# The full version, including alpha/beta/rc tags
27-
release = '0.9.19'
27+
release = '0.9.20'
2828

2929
# variables to be accessed from html
3030
html_context = {

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
numpy < 2.0
2-
ortools >= 9.6
2+
ortools >= 9.9

tests/test_globalconstraints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ def test_cumulative(self):
830830
b = cp.boolvar()
831831
a = cp.boolvar()
832832

833-
self.assertTrue(cp.Model([cp.Cumulative([x,y],[x,2],[z,q],1,x)]).solve(solver="minizinc:com.google.ortools.sat"))
833+
self.assertTrue(cp.Model([cp.Cumulative([x,y],[x,2],[z,q],1,x)]).solve())
834834
self.assertRaises(TypeError, cp.Cumulative, [x,y],[x,y],[a,y],1,x)
835835
self.assertRaises(TypeError, cp.Cumulative, [x,y],[x,y],[x,y],1,x)
836836
self.assertRaises(TypeError, cp.Cumulative, [x,y],[x,y],[x,y],x,False)

0 commit comments

Comments
 (0)