Skip to content

Commit

Permalink
made the tool compatible with newer versions of minizinc
Browse files Browse the repository at this point in the history
  • Loading branch information
hadipourh committed Jul 4, 2024
1 parent 255d1b9 commit 19ff127
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 24 deletions.
21 changes: 17 additions & 4 deletions ascon/impossible/distinguisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
from argparse import ArgumentParser, RawTextHelpFormatter
from drawdistinguisher import DrawDL

# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False


class ID:
DL_counter = 0
Expand All @@ -48,10 +61,10 @@ def __init__(self, param) -> None:
self.cp_solver_name = param["solver"]
self.num_of_threads = param["threads"]
##################################################
# Use this block if you install Or-Tools bundeled with MiniZinc
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
##################################################
if ortools_available:
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
#################################################
self.cp_solver = minizinc.Solver.lookup(self.cp_solver_name)
self.time_limit = param["timelimit"]
self.mzn_file_name = None
Expand Down
20 changes: 16 additions & 4 deletions ascon/zero-correlation/distinguisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
import datetime
from argparse import ArgumentParser, RawTextHelpFormatter
from drawdistinguisher import DrawDL
# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False


class ID:
Expand All @@ -48,10 +60,10 @@ def __init__(self, param) -> None:
self.cp_solver_name = param["solver"]
self.num_of_threads = param["threads"]
##################################################
# Use this block if you install Or-Tools bundeled with MiniZinc
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
##################################################
if ortools_available:
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
#################################################
self.cp_solver = minizinc.Solver.lookup(self.cp_solver_name)
self.time_limit = param["timelimit"]
self.mzn_file_name = None
Expand Down
21 changes: 17 additions & 4 deletions forkskinny/impossible/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
from tweakeyschedule import *
line_separator = "#"*55

# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False

class ID:
ID_counter = 0

Expand Down Expand Up @@ -66,10 +79,10 @@ def __init__(self, params) -> None:
'picat', 'scip', 'choco', 'ortools']
assert(self.cp_solver_name in self.supported_cp_solvers)
##################################################
# Use this block if you install Or-Tools bundeled with MiniZinc
# if self.cp_solver_name == "ortools":
# self.cp_solver_name = "com.google.ortools.sat"
##################################################
if ortools_available:
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
#################################################
self.cp_solver = minizinc.Solver.lookup(self.cp_solver_name)

if self.RB + self.RF == 0:
Expand Down
12 changes: 12 additions & 0 deletions forkskinny/integral/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
from pathlib import Path
from drawattack import *
line_separator = "#"*55
# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False

class IntegralAttack:
Integral_counter = 0
Expand Down
21 changes: 17 additions & 4 deletions present/impossible/distinguisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
from drawdistinguisher import DrawDL
import itertools

# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False


class ID:
DL_counter = 0
Expand All @@ -49,10 +62,10 @@ def __init__(self, param) -> None:
self.cp_solver_name = param["solver"]
self.num_of_threads = param["threads"]
##################################################
# Use this block if you install Or-Tools bundeled with MiniZinc
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
##################################################
if ortools_available:
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
#################################################
self.cp_solver = minizinc.Solver.lookup(self.cp_solver_name)
self.time_limit = param["timelimit"]
self.mzn_file_name = None
Expand Down
22 changes: 18 additions & 4 deletions present/zero-correlation/distinguisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
from drawdistinguisher import DrawDL
import itertools

# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False



class ZC:
DL_counter = 0
Expand All @@ -49,10 +63,10 @@ def __init__(self, param) -> None:
self.cp_solver_name = param["solver"]
self.num_of_threads = param["threads"]
##################################################
# Use this block if you install Or-Tools bundeled with MiniZinc
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
##################################################
if ortools_available:
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
#################################################
self.cp_solver = minizinc.Solver.lookup(self.cp_solver_name)
self.time_limit = param["timelimit"]
self.mzn_file_name = None
Expand Down
21 changes: 17 additions & 4 deletions skinny/impossible/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
from tweakeyschedule import *
line_separator = "#"*55

# Check if "OR Tools" appears in the output of "minizinc --solvers" command
import subprocess
try:
output = subprocess.run(['minizinc', '--solvers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "com.google.ortools.sat" in output.stdout.decode("utf-8"):
ortools_available = True
print("OR Tools is available")
else:
ortools_available = False
print("OR Tools is not available")
except FileNotFoundError:
ortools_available = False

class ID:
ID_counter = 0

Expand Down Expand Up @@ -66,10 +79,10 @@ def __init__(self, params) -> None:
'picat', 'scip', 'choco', 'ortools']
assert(self.cp_solver_name in self.supported_cp_solvers)
##################################################
# Use this block if you install Or-Tools bundeled with MiniZinc
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
##################################################
if ortools_available:
if self.cp_solver_name == "ortools":
self.cp_solver_name = "com.google.ortools.sat"
#################################################
self.cp_solver = minizinc.Solver.lookup(self.cp_solver_name)

if self.RB + self.RF == 0:
Expand Down

0 comments on commit 19ff127

Please sign in to comment.