Skip to content

Commit

Permalink
Add transformation time printing to minizinc
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomSerg committed Jun 5, 2024
1 parent db1ca58 commit e13311d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cpmpy/solvers/minizinc.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,25 @@ def transform(self, cpm_expr):
:return: list of Expression
"""
with TimerContext("transformation") as top_tc:
expr_store = self.expr_store

with TimerContext("toplevel_list") as tc:
cpm_cons = toplevel_list(cpm_expr)
print(f"mzn:toplevel_list took {(tc.time):.4f} -- {len(cpm_cons)}")

supported = {"min", "max", "abs", "element", "count", "nvalue", "alldifferent", "alldifferent_except0", "allequal",
"inverse", "ite" "xor", "table", "cumulative", "circuit", "subcircuit", "gcc", "increasing",
"precedence", "no_overlap",
"decreasing","strictly_increasing","strictly_decreasing", "lex_lesseq", "lex_less", "lex_chain_less",
"lex_chain_lesseq", "among"}
with TimerContext("decompose_in_tree") as tc:
cpm_cons = decompose_in_tree(cpm_cons, supported, supported_reified=supported - {"circuit", "subcircuit", "precedence"})
cpm_cons = decompose_in_tree(cpm_cons, supported, supported_reified=supported - {"circuit", "subcircuit", "precedence"}, expr_store=expr_store)
print(f"mzn:decompose_in_tree took {(tc.time):.4f} -- {len(cpm_cons)}")

print(f"ort:transformation took {(top_tc.time):.4f}")
print("final size: " + str(len(cpm_cons)))
print("STORE: " + str(len(expr_store.items())))

return cpm_cons

def __add__(self, cpm_expr):
Expand Down

0 comments on commit e13311d

Please sign in to comment.