Skip to content

Commit

Permalink
Merge pull request #159 from jump-dev/od/fix-kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimg authored May 11, 2023
2 parents 75a7164 + b0b487b commit 4f0ee85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/dualize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,7 @@ function dualize(
return dual_problem
end

function dualize(
model::JuMP.Model,
optimizer_constructor = nothing;
dual_names::DualNames = EMPTY_DUAL_NAMES,
)
function dualize(model::JuMP.Model, optimizer_constructor = nothing; kwargs...)
mode = JuMP.mode(model)
if mode != JuMP.AUTOMATIC
error("Dualization does not support solvers in $(mode) mode")
Expand All @@ -207,7 +203,7 @@ function dualize(
dualize(
JuMP.backend(model),
DualProblem(JuMP.backend(dual_model));
dual_names = dual_names,
kwargs...,
)
_fill_obj_dict_with_variables!(dual_model)
_fill_obj_dict_with_constraints!(dual_model)
Expand Down
14 changes: 14 additions & 0 deletions test/Tests/test_JuMP_dualize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ end
@test typeof(dual_model[:dualeqcon_1]) == VariableRef
@test !haskey(dual_model, Symbol(""))
end
@testset "JuMP_dualize_kwargs" begin
model = Model()
@variable(model, x >= 0)
@constraint(model, x <= 2)
@objective(model, Max, 2 * x + 1)
dual_model = Dualization.dualize(
model;
dual_names = DualNames("dual_", "dual_"),
ignore_objective = true,
consider_constrained_variables = false,
)
@test dual_model isa Model
@test num_variables(dual_model) == 2
end
end

0 comments on commit 4f0ee85

Please sign in to comment.