Skip to content

Commit 0cc12eb

Browse files
committed
Make CTG MinConflictsSolver deterministic
python-constraints now allows you to pass a PRNG to MinConflictsSolve which allows it to be deterministic. Version 2.0 is also apparently several orders of magnitude faster.
1 parent a5a20fe commit 0cc12eb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Pygments>=2.4.2
2727
pyparsing>=2.4.0
2828
pytablewriter
2929
pytest
30-
python-constraint>=1.4.0
30+
python-constraint2>=2.0.2
3131
python-dateutil>=2.8.0
3232
pytz>=2019.1
3333
pyyaml

riscv-ctg/riscv_ctg/generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ def opcomb(self, cgf):
349349
while any([len(op_conds[x])!=0 for x in op_conds]+[len(op_comb)!=0]):
350350
cond_str = ''
351351
cond_vars = []
352-
solver = MinConflictsSolver() if self.random else None
352+
# Use a fixed seed for MinConflictsSolver so it is deterministic.
353+
solver = MinConflictsSolver(rand=random.Random(0)) if self.random else None
353354
problem = Problem(solver)
354355

355356
done = False

0 commit comments

Comments
 (0)