-
Notifications
You must be signed in to change notification settings - Fork 6
Remove error from feasibility sense #162
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c333945
Remove error from feasibility sense
guilhermebodin e9f309e
add kwarg
joaquimg 889e537
Merge branch 'master' into gb/feasibility_sense
joaquimg 9452844
fix typo
joaquimg 213a3d9
Merge branch 'gb/feasibility_sense' of https://github.com/jump-dev/Du…
joaquimg 9275b8a
fix test
joaquimg 21b3142
Update src/objective_coefficients.jl
joaquimg 81766c1
add flag to dual optimizer
joaquimg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function feasibility_1_test() | ||
#= | ||
min 0 | ||
s.t. | ||
x_1 + 2x_2 <= 3 | ||
x_1 >= 3 | ||
=# | ||
model = TestModel{Float64}() | ||
|
||
X = MOI.add_variables(model, 2) | ||
|
||
MOI.add_constraint( | ||
model, | ||
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.([1.0, 2.0], X), 0.0), | ||
MOI.LessThan(3.0), | ||
) | ||
|
||
MOI.add_constraint(model, X[1], MOI.GreaterThan(3.0)) | ||
|
||
return model | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
@testset "linear problems" begin | ||
@testset "feasibility_1_test" begin | ||
#= | ||
primal | ||
min 0 | ||
s.t. | ||
x_1 >= 3 :y_2 | ||
x_1 + 2x_2 <= 3 :y_3 | ||
dual | ||
max 3y_2 + 3y_3 | ||
s.t. | ||
y_2 >= 0 | ||
y_3 <= 0 | ||
y_2 + y_3 == 0 :x_1 | ||
2y_3 == 0 :x_2 | ||
=# | ||
primal_model = feasibility_1_test() | ||
|
||
# fail due no objective sense | ||
@test_throws ErrorException Dualization.dualize(primal_model) | ||
|
||
dual = | ||
Dualization.dualize(primal_model, assume_min_if_feasibility = true) | ||
dual_model = dual.dual_model | ||
primal_dual_map = dual.primal_dual_map | ||
|
||
@test MOI.get(dual_model, MOI.NumberOfVariables()) == 2 | ||
list_of_cons = MOI.get(dual_model, MOI.ListOfConstraintTypesPresent()) | ||
@test Set(list_of_cons) == Set( | ||
[ | ||
(MOI.VariableIndex, MOI.GreaterThan{Float64}) | ||
(MOI.VariableIndex, MOI.LessThan{Float64}) | ||
(MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}) | ||
], | ||
) | ||
@test MOI.get( | ||
dual_model, | ||
MOI.NumberOfConstraints{ | ||
MOI.VariableIndex, | ||
MOI.GreaterThan{Float64}, | ||
}(), | ||
) == 1 | ||
@test MOI.get( | ||
dual_model, | ||
MOI.NumberOfConstraints{MOI.VariableIndex,MOI.LessThan{Float64}}(), | ||
) == 1 | ||
@test MOI.get( | ||
dual_model, | ||
MOI.NumberOfConstraints{ | ||
MOI.ScalarAffineFunction{Float64}, | ||
MOI.EqualTo{Float64}, | ||
}(), | ||
) == 2 | ||
obj_type = MOI.get(dual_model, MOI.ObjectiveFunctionType()) | ||
@test obj_type == MOI.ScalarAffineFunction{Float64} | ||
obj = MOI.get(dual_model, MOI.ObjectiveFunction{obj_type}()) | ||
@test MOI.constant(obj) == 0.0 | ||
@test MOI.coefficient.(obj.terms) == [3.0; 3.0] | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 also be a parameter of
dual_optimizer
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.
Yep