Skip to content

Commit

Permalink
add statistiscs
Browse files Browse the repository at this point in the history
  • Loading branch information
wanko committed May 16, 2024
1 parent 20f2249 commit ba9bf4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fclingo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self):
self.translate_program = 0
self.constraints_added = 0
self.rules_added = 0
self.variables_added = 0


class AppConfig:
Expand Down Expand Up @@ -150,6 +151,7 @@ def _on_statistics(self, step, akku):
translation = fclingo["Translation time in seconds"]
translation["AST rewriting"] = self.stats.rewrite_ast
translation["Translation"] = self.stats.translate_program
fclingo["Number of variables added"] = self.stats.variables_added
fclingo["Number of constraints added"] = self.stats.constraints_added
fclingo["Number of rules added"] = self.stats.rules_added
return True
Expand Down
3 changes: 3 additions & 0 deletions fclingo/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,12 @@ def _add_auxvar(self):
clingo.TheoryTermType.Function,
)
self._auxvars += 1
self._stats.variables_added+=1
return var

def _add_atom(self, symbol=None):
with self._prg.backend() as backend:
self._stats.constraints_added+=1
if symbol:
return backend.add_atom(symbol)
return backend.add_atom()
Expand All @@ -256,6 +258,7 @@ def _search_atom(self, lit):

def _add_rule(self, head, body, choice=False):
with self._prg.backend() as backend:
self._stats.rules_added+=1
backend.add_rule(head, body, choice)
if self._config.print_trans:
head_atoms = []
Expand Down

0 comments on commit ba9bf4b

Please sign in to comment.