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

Disallow logical propositions with only 1 logical variable #92

Merged
merged 2 commits into from
Nov 1, 2023

Conversation

hdavid16
Copy link
Owner

Currently, @constraint(m, y := true) throws an error, but @constraint(m, logical_not(y) := true does not. For consistency, both should error since the user should fix the value of the logical variable instead. This PR makes adds additional checks to enforce this.

@hdavid16 hdavid16 requested a review from pulsipher October 30, 2023 12:17
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b26e1ed) 99.89% compared to head (79c54c0) 99.89%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #92   +/-   ##
=======================================
  Coverage   99.89%   99.89%           
=======================================
  Files          10       10           
  Lines         963      967    +4     
=======================================
+ Hits          962      966    +4     
  Misses          1        1           
Files Coverage Δ
src/constraints.jl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@pulsipher pulsipher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. The only thing is that with these changes I think the following is unnecessary:

if _isa_literal(lexpr)
add_to_expression!(func, 1 - _reformulate_clause(model, lexpr.args[1]))
. This is the line that is missing the code coverage.

@hdavid16
Copy link
Owner Author

hdavid16 commented Nov 1, 2023

It is still needed to reformulate:

@constraint(model, y[1]  ¬y[2] := true)

I have updated test_intersection_reformulation() to use this constraint for the test, which should allow for testing the line you indicate.

Copy link
Collaborator

@pulsipher pulsipher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@hdavid16 hdavid16 merged commit ad813ad into master Nov 1, 2023
6 checks passed
@hdavid16 hdavid16 deleted the proposition_single_variable branch November 1, 2023 14:02
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

Successfully merging this pull request may close these issues.

2 participants