hdavid16 / DisjunctiveProgramming.jl

A JuMP extension for Generalized Disjunctive Programming
MIT License
27 stars 3 forks source link

Support `JuMP.value` for Logical Variables #96

Closed pulsipher closed 7 months ago

pulsipher commented 7 months ago

Closes #94. It also alphabetizes the Project file to fix an Aqua test failure.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (3879754) 99.90% compared to head (97de4cd) 99.90%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #96 +/- ## ======================================= Coverage 99.90% 99.90% ======================================= Files 10 10 Lines 1001 1003 +2 ======================================= + Hits 1000 1002 +2 Misses 1 1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

hdavid16 commented 7 months ago

Thanks for putting this together. What are your thoughts on returning the corresponding Bool instead of 0 or 1? Should be a simple update: value(binary) == 1 (or use isone).

pulsipher commented 7 months ago

Thanks for putting this together. What are your thoughts on returning the corresponding Bool instead of 0 or 1? Should be a simple update: value(binary) == 1 (or use isone).

I thought about this, but the problem is MIP solvers return binary variable solutions as Float64 not 0 or 1. So, we would need to use some sort of tolerance to round to the appropriate integer solution and then convert to Bool. I would prefer to not hard-code some tolerance or add more complexity to value by adding a keyword that would only work on logical variables.

hdavid16 commented 7 months ago

That is a good point. Since the value is binary, what about comparing it to 0.5 (value > 0.5)?

pulsipher commented 7 months ago

Ok, I have changed it to round based on 0.5.