-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable modification of objective function coefficients for DualOptimi…
…zer (#100)
- Loading branch information
1 parent
a8676f4
commit 3a8bb08
Showing
5 changed files
with
82 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Dualization" | ||
uuid = "191a621a-6537-11e9-281d-650236a99e60" | ||
authors = ["guilhermebodin <[email protected]>"] | ||
version = "0.3.3" | ||
version = "0.3.4" | ||
|
||
[deps] | ||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" | ||
|
This file contains 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 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 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,59 @@ | ||
@testset "modify" begin | ||
model = Model(GLPK_DUAL_FACTORY) | ||
@variable(model, x[1:2] >= 0) | ||
@constraint(model, 2x[1] + x[2] <= 4) | ||
@constraint(model, x[1] + 2x[2] <= 4) | ||
@objective(model, Max, 4x[1] + 3x[2]) | ||
optimize!(model) | ||
@test objective_value(model) ≈ 28/3 | ||
set_objective_coefficient(model, x[1], 5.0) | ||
optimize!(model) | ||
@test objective_value(model) ≈ 10.6666666666 | ||
|
||
model = Model(GLPK_DUAL_FACTORY) | ||
@variable(model, x[1:2] >= 0) | ||
@constraint(model, 2x[1] + x[2] <= 4) | ||
@constraint(model, x[1] + 2x[2] <= 4) | ||
@objective(model, Min, -4x[1] + -3x[2]) | ||
optimize!(model) | ||
@test objective_value(model) ≈ -28/3 | ||
set_objective_coefficient(model, x[1], -5.0) | ||
optimize!(model) | ||
@test objective_value(model) ≈ -10.6666666666 | ||
|
||
model = Model(SCS_DUAL_FACTORY) | ||
@variable(model, x[1:2] >= 0) | ||
@constraint(model, 2x[1] + x[2] <= 4) | ||
@constraint(model, x[1] + 2x[2] <= 4) | ||
@objective(model, Max, 4x[1] + 3x[2]) | ||
optimize!(model) | ||
@test objective_value(model) ≈ 28/3 atol=1e-3 | ||
set_objective_coefficient(model, x[1], 5.0) | ||
optimize!(model) | ||
@test objective_value(model) ≈ 10.6666666666 atol=1e-3 | ||
|
||
model = Model(SCS_DUAL_FACTORY) | ||
@variable(model, x[1:2] >= 0) | ||
@constraint(model, 2x[1] + x[2] <= 4) | ||
@constraint(model, x[1] + 2x[2] <= 4) | ||
@objective(model, Min, -4x[1] + -3x[2]) | ||
optimize!(model) | ||
@test objective_value(model) ≈ -28/3 atol=1e-3 | ||
set_objective_coefficient(model, x[1], -5.0) | ||
optimize!(model) | ||
@test objective_value(model) ≈ -10.6666666666 atol=1e-3 | ||
|
||
model = Model(SCS_DUAL_FACTORY) | ||
@variable(model, x) | ||
@variable(model, y) | ||
@variable(model, z) | ||
@constraint(model, x + 2y + 3z >= 4) | ||
@constraint(model, x + y >= 1) | ||
@objective(model, Min, x^2 + x*y + y^2 + y*z + z^2) | ||
optimize!(model) | ||
@test objective_value(model) ≈ 1.8571 atol=1e-3 | ||
# Now the objective is @objective(model, Min, x^2 + x*y + y^2 + y*z + z^2 - 5x) | ||
set_objective_coefficient(model, x, -5.0) | ||
optimize!(model) | ||
@test objective_value(model) ≈ -9.15 atol=1e-3 | ||
end |
This file contains 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