-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add timeout to the smt operations
- Loading branch information
Showing
9 changed files
with
109 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
flamapy/metamodels/smt_metamodel/operations/valid_model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
from z3 import Solver, sat | ||
from z3 import Solver, sat, unknown | ||
|
||
from flamapy.core.operations import Operation | ||
from flamapy.metamodels.smt_metamodel.models import PySMTModel | ||
|
||
|
||
class ValidModel(Operation): | ||
def __init__(self) -> None: | ||
self.result: bool = True | ||
self.result: bool | str = True | ||
|
||
def get_result(self) -> bool: | ||
def get_result(self) -> bool | str: | ||
return self.result | ||
|
||
def execute(self, model: PySMTModel) -> None: | ||
solver = Solver() | ||
solver.set("timeout", 3000) | ||
solver.add(model.domain) | ||
self.result = solver.check() == sat | ||
if solver.check() == unknown: | ||
self.result = ( | ||
"Execution timed out after 3 seconds. " | ||
"The complexity of the model is too high, " | ||
"try lowering the maximum level of the graph." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters