@@ -47,6 +47,7 @@ def __init__(
47
47
Optionally sort the searchspace by the order in which the parameter values were specified. By default, sort goes from first to last parameter, to reverse this use sort_last_param_first.
48
48
"""
49
49
# set the object attributes using the arguments
50
+ framework_l = framework .lower ()
50
51
restrictions = restrictions if restrictions is not None else []
51
52
self .tune_params = tune_params
52
53
self .restrictions = restrictions
@@ -66,21 +67,23 @@ def __init__(
66
67
if (
67
68
len (restrictions ) > 0
68
69
and any (isinstance (restriction , str ) for restriction in restrictions )
69
- and not (framework . lower () == "pysmt" or framework . lower () == "bruteforce" )
70
+ and not (framework_l == "pysmt" or framework_l == "pyatf" or framework_l == "bruteforce" )
70
71
):
71
72
self .restrictions = compile_restrictions (
72
- restrictions , tune_params , monolithic = False , try_to_constraint = framework . lower () == "pythonconstraint"
73
+ restrictions , tune_params , monolithic = False , try_to_constraint = framework_l == "pythonconstraint"
73
74
)
74
75
75
76
# get the framework given the framework argument
76
- if framework . lower () == "pythonconstraint" :
77
+ if framework_l == "pythonconstraint" :
77
78
searchspace_builder = self .__build_searchspace
78
- elif framework . lower () == "pysmt" :
79
+ elif framework_l == "pysmt" :
79
80
searchspace_builder = self .__build_searchspace_pysmt
80
- elif framework .lower () == "atf_cache" :
81
+ elif framework_l == "pyatf" :
82
+ searchspace_builder = self .__build_searchspace_pyATF
83
+ elif framework_l == "atf_cache" :
81
84
searchspace_builder = self .__build_searchspace_ATF_cache
82
85
self .path_to_ATF_cache = path_to_ATF_cache
83
- elif framework . lower () == "bruteforce" :
86
+ elif framework_l == "bruteforce" :
84
87
searchspace_builder = self .__build_searchspace_bruteforce
85
88
else :
86
89
raise ValueError (f"Invalid framework parameter { framework } " )
@@ -247,6 +250,28 @@ def all_smt(formula, keys) -> list:
247
250
248
251
return self .__parameter_space_list_to_lookup_and_return_type (parameter_space_list )
249
252
253
+ def __build_searchspace_pyATF (self , block_size_names : list , max_threads : int , solver : Solver ):
254
+ """Builds the searchspace using pyATF."""
255
+ from pyatf import TP , Set , Tuner
256
+ from pyatf .cost_functions .generic import CostFunction
257
+ from pyatf .search_techniques import Exhaustive
258
+
259
+ costfunc = CostFunction ("echo 'hello'" )
260
+
261
+ def get_params ():
262
+ params = List ()
263
+ for key , values in self .tune_params .items ():
264
+ TP (key , Set (values ))
265
+ return params
266
+
267
+ tuning_result = (
268
+ Tuner ()
269
+ .tuning_parameters (* get_params ())
270
+ .search_technique (Exhaustive ())
271
+ .tune (costfunc )
272
+ )
273
+ return tuning_result
274
+
250
275
def __build_searchspace_ATF_cache (self , block_size_names : list , max_threads : int , solver : Solver ):
251
276
"""Imports the valid configurations from an ATF CSV file, returns the searchspace, a dict of the searchspace for fast lookups and the size."""
252
277
if block_size_names != default_block_size_names or max_threads != 1024 :
0 commit comments