Skip to content

Conversation

rafabench
Copy link

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.

@rafabench rafabench changed the title Add new tests for semi continuous and semi integer variables Add tests for semi continuous and semi integer variables Feb 21, 2020
@rafabench rafabench closed this Feb 21, 2020
@blegat
Copy link
Member

blegat commented Feb 22, 2020

Why did you close, it is a welcome addition

@rafabench
Copy link
Author

Sorry, it had a bug in the code. I was going to make another PR.

@rafabench rafabench reopened this Feb 22, 2020
@codecov-io
Copy link

codecov-io commented Feb 22, 2020

Codecov Report

Merging #1033 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/Test/intlinear.jl 100% <100%> (ø) ⬆️
src/FileFormats/MOF/nonlinear.jl 100% <0%> (ø) ⬆️
src/FileFormats/MOF/write.jl 66.31% <0%> (+0.72%) ⬆️
src/Utilities/mockoptimizer.jl 92.1% <0%> (+2.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4af130f...6c2d48a. Read the comment docs.

MOI.optimize!(model)

@test MOI.get(model, MOI.TerminationStatus()) == config.optimal_status

Copy link
Member

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 ?

Copy link
Author

@rafabench rafabench Feb 27, 2020

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, ...

Copy link
Member

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

@rafabench rafabench requested a review from blegat February 28, 2020 17:07
end
end

function semiconttest(model::MOI.ModelLike, config::TestConfig{T}) where T
Copy link
Member

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)

# 2 variables
# min x
# st x >= y
# x ∈ {0.0} U [2.0,3.0]
Copy link
Member

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

Copy link
Author

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

Copy link
Member

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

@rafabench rafabench requested a review from blegat March 3, 2020 20:56
@blegat blegat modified the milestones: v0.9.12, v0.9.13 Mar 5, 2020
@blegat blegat merged commit bab7682 into jump-dev:master Mar 5, 2020
@blegat
Copy link
Member

blegat commented Mar 5, 2020

Thanks for the contribution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants