Skip to content

Commit

Permalink
Merge pull request #152 from jump-dev/jg/qpparam
Browse files Browse the repository at this point in the history
Add sense change to Parametric Max QP
  • Loading branch information
joaquimg authored Oct 4, 2022
2 parents e80c31c + 3bb3b7d commit 88bc9ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
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.5.5"
version = "0.5.6"

[deps]
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Expand Down
4 changes: 3 additions & 1 deletion src/dual_equality_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function add_dual_equality_constraints(
scalar_affine_terms,
primal_dual_map.primal_parameter,
primal_objective,
sense_change,
)

# Constrained variables
Expand Down Expand Up @@ -276,13 +277,14 @@ function add_scalar_affine_terms_from_quad_params(
},
primal_parameter::Dict{MOI.VariableIndex,MOI.VariableIndex},
primal_objective::PrimalObjective{T},
sense_change::T,
) where {T}
for (key, val) in primal_objective.quad_cross_parameters
for term in val
dual_vi = primal_parameter[term.variable]
push_to_scalar_affine_terms!(
scalar_affine_terms[key],
-MOI.coefficient(term),
-sense_change * MOI.coefficient(term),
dual_vi,
)
end
Expand Down
14 changes: 10 additions & 4 deletions test/Tests/test_max_min_dual_equal_feasibility_quadratic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ function get_DualMinModel_no_bounds()
MinModel = Model()
@variable(MinModel, Q₁)
@variable(MinModel, Q₂)
@variable(MinModel, param)

@objective(MinModel, Min, (Q₁ + Q₂)^2)
@objective(MinModel, Min, (Q₁ + Q₂)^2 + (Q₁ + Q₂) * param)
@constraint(MinModel, C₁, Q₁ + 1 >= 0)
@constraint(MinModel, C₂, Q₂ + 1 >= 0)

Expand All @@ -15,7 +16,9 @@ function get_DualMaxModel_no_bounds()
MaxModel = Model()
@variable(MaxModel, Q₁)
@variable(MaxModel, Q₂)
@objective(MaxModel, Max, -(Q₁ + Q₂)^2)
@variable(MaxModel, param)

@objective(MaxModel, Max, -((Q₁ + Q₂)^2 + (Q₁ + Q₂) * param))
@constraint(MaxModel, C₁, Q₁ + 1 >= 0)
@constraint(MaxModel, C₂, Q₂ + 1 >= 0)

Expand All @@ -27,8 +30,9 @@ function get_DualMinModel_with_bounds()
MinModel = Model()
@variable(MinModel, Q₁ >= 0)
@variable(MinModel, Q₂ >= 0)
@variable(MinModel, param)

@objective(MinModel, Min, (Q₁ + Q₂)^2)
@objective(MinModel, Min, (Q₁ + Q₂)^2 + (Q₁ + Q₂) * param)
@constraint(MinModel, C₁, Q₁ + 1 >= 0)
@constraint(MinModel, C₂, Q₂ + 1 >= 0)

Expand All @@ -41,7 +45,9 @@ function get_DualMaxModel_with_bounds()

@variable(MaxModel, Q₁ >= 0)
@variable(MaxModel, Q₂ >= 0)
@objective(MaxModel, Max, -(Q₁ + Q₂)^2)
@variable(MaxModel, param)

@objective(MaxModel, Max, -((Q₁ + Q₂)^2 + (Q₁ + Q₂) * param))
@constraint(MaxModel, C₁, Q₁ + 1 >= 0)
@constraint(MaxModel, C₂, Q₂ + 1 >= 0)

Expand Down

2 comments on commit 88bc9ff

@joaquimg
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/69513

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.6 -m "<description of version>" 88bc9fffb14c670dee7bb9f94dbffe9bf85b3982
git push origin v0.5.6

Please sign in to comment.