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

Constraints transitivity inconsistencies in BinaryConstraintsManager.add_constraint #3

Closed
erwanschild opened this issue Sep 20, 2021 · 1 comment
Assignees
Labels
bug Need a fix

Comments

@erwanschild
Copy link
Collaborator

Describe the bug
It is possible to add inconsistencies in the constraints manager.
To do it, add a new constraint (not already explicitly added) that is inconsistent with the constraints transitivity inference.

To Reproduce

from cognitivefactory.interactive_clustering.constraints.factory import managing_factory
from cognitivefactory.interactive_clustering.sampling.factory import sampling_factory

# Initialize constraints manager.
constraints_manager = managing_factory(["0", "1", "2"])

# Add "MUST_LINK" constraints between "0" and "1" and between "1" and "2".
constraints_manager.add_constraint("0", "1", "MUST_LINK")
constraints_manager.add_constraint("1", "2", "MUST_LINK")
# By transitivity: There is a "MUST_LINK" constraint between "0" and "2".

# Add a inconsistent constraint with a "CANNOT_LINK" constraint between "0" and "2".
constraints_manager.add_constraint("0", "2", "CANNOT_LINK")  # Should be False.

# Print the transitivity inference.
print(constraints_manager._constraints_transitivity)
"""
{
    '0': {'MUST_LINK': {'0': None, '1': None, '2': None}, 'CANNOT_LINK': {'0': None, '1': None, '2': None}},
    '1': {'MUST_LINK': {'0': None, '1': None, '2': None}, 'CANNOT_LINK': {'0': None, '1': None, '2': None}},
    '2': {'MUST_LINK': {'0': None, '1': None, '2': None}, 'CANNOT_LINK': {'0': None, '1': None, '2': None}}
}  # INCONSISTENT !
"""

Expected behavior

  • The line constraints_manager.add_constraint("0", "2", "CANNOT_LINK") should return False (it's an inference conflict) ;
  • The line print(constraints_manager._constraints_transitivity) should display :
"""
{
    '0': {'MUST_LINK': {'0': None, '1': None, '2': None}, 'CANNOT_LINK': {}},
    '1': {'MUST_LINK': {'0': None, '1': None, '2': None}, 'CANNOT_LINK': {}},
    '2': {'MUST_LINK': {'0': None, '1': None, '2': None}, 'CANNOT_LINK': {}}
}
"""

System (please complete the following information):

  • Interactive Clustering version: 0.2.1
  • Python version: 3.8
  • OS: Windows
@erwanschild erwanschild added the bug Need a fix label Sep 20, 2021
@erwanschild erwanschild self-assigned this Sep 20, 2021
@erwanschild
Copy link
Collaborator Author

Fixed in 0.2.1.

@erwanschild erwanschild linked a pull request Nov 15, 2023 that will close this issue
@erwanschild erwanschild removed a link to a pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Need a fix
Projects
None yet
Development

No branches or pull requests

1 participant