-
Notifications
You must be signed in to change notification settings - Fork 94
Add tests for semi continuous and semi integer variables #1033
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
Conversation
Why did you close, it is a welcome addition |
Sorry, it had a bug in the code. I was going to make another PR. |
Codecov Report
@@ Coverage Diff @@
## master #1033 +/- ##
==========================================
+ Coverage 95.19% 95.26% +0.07%
==========================================
Files 100 100
Lines 11344 11436 +92
==========================================
+ Hits 10799 10895 +96
+ Misses 545 541 -4
Continue to review full report at Codecov.
|
Fix typos and remove debug line
src/Test/intlinear.jl
Outdated
MOI.optimize!(model) | ||
|
||
@test MOI.get(model, MOI.TerminationStatus()) == config.optimal_status | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the empty lines in between these lines to be consistent with other tests ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like to remove only the lines between the MOI.optimize!(model)
and @test MOI.get(model, MOI.TerminationStatus()) == config.optimal_status
(lines 725,747, ...) or all empty lines in the if config.solve
block (723, 725,727, ...) ?
I don't like these empty lines too, but I was trying to make it look the same as the other tests, like in lines 363, 303, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave 723 and 725 bu remove 727, 729, ..., 737
src/Test/intlinear.jl
Outdated
end | ||
end | ||
|
||
function semiconttest(model::MOI.ModelLike, config::TestConfig{T}) where T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests seem to differ in only a few places, could you refactor with an auxiliary function
function _semitest(model::MOI.ModelLike, config::TestConfig{T}, int::Bool) where T
[...]
end
semiconttest(model::MOI.ModelLike, config::TestConfig) = _semitest(model, config, false)
semiinttest(model::MOI.ModelLike, config::TestConfig) = _semitest(model, config, true)
src/Test/intlinear.jl
Outdated
# 2 variables | ||
# min x | ||
# st x >= y | ||
# x ∈ {0.0} U [2.0,3.0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should depend on int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this?
# 2 variables
#
# If int == false
# min x
# st x >= y
# x ∈ {0.0} U [2.0,3.0]
# y = 0.0
#
# If int == true
# min x
# st x >= y
# x ∈ {0.0} U {2.0} U {3.0}
# y = 0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but you can do the if only around the semi... constraint. Also, do int
and !int
Thanks for the contribution ! |
I've added some tests for semi-continuous and semi-integer variables.
It's a simple model:
min x
st x >= y
x ∈ {0.0} U [2.0,3.0]
y = 0.0
And changed the fixed value of y to see the result.
I've tested on both CPLEX and Xpress solvers.