Skip to content

Commit

Permalink
#94: updated how constants rewriting requirements are stored
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-biasion committed Oct 25, 2024
1 parent 07c4d82 commit 8e295be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
13 changes: 8 additions & 5 deletions sxpat/specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class TemplateType(enum.Enum):
NON_SHARED = 'nonshared'
SHARED = 'shared'

class ConstantsType(enum.Enum):
class ConstantsMode(enum.Enum):
NEVER = 'never'
OPTIMIZE = 'optimize'
ALWAYS = 'always'

class EnumChoicesAction(argparse.Action):
Expand Down Expand Up @@ -62,7 +63,8 @@ class Specifications:
subxpat: bool
template: TemplateType
encoding: EncodingType
constants: ConstantsType
use_constants: bool #rw
constants_mode: ConstantsMode
wanted_models: int
iteration: int = dc.field(init=False, default=None) # rw
# exploration (2)
Expand Down Expand Up @@ -221,10 +223,10 @@ def parse_args(cls):
default=1,
help='Wanted number of models to generate for each step')

_consts = parser.add_argument('--constants',
type=ConstantsType,
_consts = parser.add_argument('--constants-mode',
type=ConstantsMode,
action=EnumChoicesAction,
default=ConstantsType.NEVER,
default=ConstantsMode.NEVER,
help='The way constants are used')
# > error stuff

Expand Down Expand Up @@ -270,6 +272,7 @@ def parse_args(cls):
# custom defaults
if raw_args.current_benchmark is None:
raw_args.current_benchmark = raw_args.exact_benchmark
raw_args.use_constants = raw_args.constants_mode is ConstantsMode.ALWAYS

# define dependencies
dependencies: Dict[Tuple[argparse.Action, Optional[Any]], List[argparse.Action]] = defaultdict(list)
Expand Down
2 changes: 1 addition & 1 deletion sxpat/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def get_grid_name(self):
technique_specific = f'{self.tool_name}_{self.specs.error_partitioning.value}_'
technique_specific += f'enc{self.specs.encoding.value}_'

tail = f'mode{self.specs.extraction_mode}_omax{self.specs.omax}_imax{self.specs.imax}_const{self.specs.constants.value}_'
tail = f'mode{self.specs.extraction_mode}_omax{self.specs.omax}_imax{self.specs.imax}_const{self.specs.constants_mode.value}_'
tail += f'{self.template_name}_time'

# Get the current date and time
Expand Down
6 changes: 3 additions & 3 deletions sxpat/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .annotatedGraph import AnnotatedGraph
from .config import paths as sxpatpaths
from .config import config as sxpatconfig
from .specifications import Specifications, TemplateType, ConstantsType
from .specifications import Specifications, TemplateType, ConstantsMode


class Synthesis:
Expand Down Expand Up @@ -182,10 +182,10 @@ def set_path(self, this_path: Tuple[str, str], this_name: Optional[str] = None,
f'enc{self.specs.encoding.value}',
f'imax{self.specs.imax}',
f'omax{self.specs.omax}',
f'const{self.specs.constants.value}',
f'const{self.specs.constants_mode.value}',
))

# update et
# update inline data
ET_PATTERN = re.compile(r'_et\d+')
data.root = ET_PATTERN.sub(f'_et{self.specs.et}', data.root)

Expand Down

0 comments on commit 8e295be

Please sign in to comment.