Skip to content

Commit 395b4b8

Browse files
authored
Apply suggestions from code review
1 parent 8bf4e0d commit 395b4b8

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

src/duals.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,4 @@ function _compute_parameters_in_ci!(
204204
MOI.get(model, ParameterValue(), term.scalar_term.variable_1)
205205
end
206206
return
207-
end
207+
end

src/parametric_functions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,3 +794,4 @@ function _current_function(f::ParametricVectorQuadraticFunction{T}) where {T}
794794
f.current_constant,
795795
)
796796
end
797+

src/update_parameters.jl

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ function _affine_build_change_and_up_param_func(
160160
return changes
161161
end
162162

163+
# TODO
164+
# This function is currently commented out because there is no vector version
165+
# of MOI.ScalarCoefficientChange.
166+
# For the update the entire MOI.ConstraintFunction must be updated
163167
# function _affine_build_change_and_up_param_func(
164168
# pf::ParametricVectorQuadraticFunction{T},
165169
# delta_terms,
@@ -298,6 +302,15 @@ function update_parameters!(model::Optimizer)
298302
end
299303
end
300304

305+
# Different from the above cases, it is not possible to update
306+
# vector function in-place because there is no vector version of
307+
# MOI.ScalarCoefficientChange.
308+
# Therefore, vector quadratic function must be update via
309+
# MOI.ConstraintFunction that replaces the entire function.
310+
# Consequently, this operation is much slower.
311+
# Moreover, to perform the update, it is easier to use the
312+
# current_function code, hence, this update must be executed
313+
# after the update of the parameters cache (the loop above).
301314
_update_vector_quadratic_constraints!(model)
302315

303316
return
@@ -361,23 +374,6 @@ function _delta_parametric_constant(
361374
return delta_constants
362375
end
363376

364-
function _quadratic_build_change_and_up_param_func!(
365-
pf::ParametricVectorQuadraticFunction{T},
366-
delta_quad_terms::Dict{Int, Vector{MOI.ScalarQuadraticTerm{T}}}
367-
) where {T}
368-
for (output_idx, terms) in delta_quad_terms
369-
if haskey(pf.quadratic_terms_with_p, output_idx)
370-
for term in terms
371-
# Update the current coefficient in the parametric function
372-
for (vars, coeff_info) in pf.quadratic_terms_with_p[output_idx]
373-
param_coeff, current_coeff = coeff_info
374-
pf.quadratic_terms_with_p[output_idx][vars] = (param_coeff, current_coeff + term.coefficient)
375-
end
376-
end
377-
end
378-
end
379-
end
380-
381377
function _update_vector_quadratic_constraints!(
382378
model::Optimizer,
383379
vector_quadratic_constraint_cache_inner::DoubleDictInner{F,S,V},

0 commit comments

Comments
 (0)