From 439ab3e397d14737742aceeff1b65dcd75aa2aa2 Mon Sep 17 00:00:00 2001 From: joaquim Date: Tue, 4 Oct 2022 10:25:38 -0300 Subject: [PATCH 1/2] Add sense change to Parametric Max QP --- Project.toml | 2 +- src/dual_equality_constraints.jl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index b558fb1..1aa0cfb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Dualization" uuid = "191a621a-6537-11e9-281d-650236a99e60" authors = ["guilhermebodin "] -version = "0.5.5" +version = "0.5.6" [deps] JuMP = "4076af6c-e467-56ae-b986-b466b2749572" diff --git a/src/dual_equality_constraints.jl b/src/dual_equality_constraints.jl index d0283d8..ec0e9e8 100644 --- a/src/dual_equality_constraints.jl +++ b/src/dual_equality_constraints.jl @@ -54,6 +54,7 @@ function add_dual_equality_constraints( scalar_affine_terms, primal_dual_map.primal_parameter, primal_objective, + sense_change, ) # Constrained variables @@ -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 From 3bb3b7d141e8c60865e74c17b4e86688a38d16eb Mon Sep 17 00:00:00 2001 From: joaquim Date: Tue, 4 Oct 2022 10:30:48 -0300 Subject: [PATCH 2/2] include parameters in tests --- ...est_max_min_dual_equal_feasibility_quadratic.jl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/Tests/test_max_min_dual_equal_feasibility_quadratic.jl b/test/Tests/test_max_min_dual_equal_feasibility_quadratic.jl index e724460..986a0d3 100644 --- a/test/Tests/test_max_min_dual_equal_feasibility_quadratic.jl +++ b/test/Tests/test_max_min_dual_equal_feasibility_quadratic.jl @@ -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) @@ -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) @@ -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) @@ -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)