Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in minimal_contrastive_reason() #19

Open
gildasmorvan opened this issue Jun 17, 2024 · 0 comments
Open

Bug in minimal_contrastive_reason() #19

gildasmorvan opened this issue Jun 17, 2024 · 0 comments

Comments

@gildasmorvan
Copy link
Contributor

Calling explainer.minimal_contrastive_reason(time_limit=5) raises this error:

File ~/Logiciels/pyxai/pyxai/sources/core/explainer/explainerBT.py:363, in ExplainerBT.minimal_contrastive_reason(self, n, time_limit)
    361 starting_time = -time.process_time()
    362 contrastive_bt = ContrastiveBT()
--> 363 c = contrastive_bt.create_model_and_solve(self, None if self._theory is False else self._theory_clauses(), self._excluded_literals, n, time_limit)
    364 time_used = starting_time + time.process_time()
    365 self._elapsed_time = time_used if time_limit is None or time_used < time_limit else Explainer.TIMEOUT

File ~/Logiciels/pyxai/pyxai/sources/solvers/MIP/ContrastiveBT.py:28, in ContrastiveBT.create_model_and_solve(self, explainer, theory, excluded, n, time_limit)
     25 flipped = [solver.BoolVar(f"z[{i}]") for i in range(bin_len)]  # The flipped variables
     27 # Constraints related to tree structure
---> 28 tree_structure_constraints(explainer, solver, active_leaves, instance)
     30 # Constraints related to theory
     31 theory_constraints(solver, instance, theory)

File ~/Logiciels/pyxai/pyxai/sources/solvers/MIP/help_functions.py:19, in tree_structure_constraints(explainer, solver, active_leaves, instance)
     17 for j, tree in enumerate(forest):
     18     for i, leave in enumerate(tree.get_leaves()):
---> 19         t = TypeLeaf.LEFT if leave.parent.left == leave else TypeLeaf.RIGHT
     20         cube = forest[j].create_cube(leave.parent, t)
     21         nb_neg = sum((1 for l in cube if l < 0))

AttributeError: 'NoneType' object has no attribute 'left'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant