@@ -66,7 +66,9 @@ function ParametricCubicFunction(parsed::_ParsedCubicExpression{T}) where {T}
6666
6767 # Split affine data
6868 affine_data = Dict {MOI.VariableIndex,T} ()
69+ sizehint! (affine_data, length (v_in_param_terms))
6970 affine_data_np = Dict {MOI.VariableIndex,T} ()
71+ sizehint! (affine_data_np, length (parsed. v))
7072 for term in parsed. v
7173 if term. variable in v_in_param_terms
7274 affine_data[term. variable] =
@@ -319,8 +321,7 @@ function _delta_parametric_constant(
319321 # From p terms
320322 for term in cubic_affine_parameter_terms (f)
321323 p_i = p_idx (term. variable)
322- if haskey (model. updated_parameters, p_i) &&
323- ! isnan (model. updated_parameters[p_i])
324+ if ! isnan (model. updated_parameters[p_i])
324325 old_val = model. parameters[p_i]
325326 new_val = model. updated_parameters[p_i]
326327 delta += term. coefficient * (new_val - old_val)
@@ -331,12 +332,8 @@ function _delta_parametric_constant(
331332 for term in cubic_parameter_parameter_terms (f)
332333 pi1 = p_idx (term. variable_1)
333334 pi2 = p_idx (term. variable_2)
334- updated1 =
335- haskey (model. updated_parameters, pi1) &&
336- ! isnan (model. updated_parameters[pi1])
337- updated2 =
338- haskey (model. updated_parameters, pi2) &&
339- ! isnan (model. updated_parameters[pi2])
335+ updated1 = ! isnan (model. updated_parameters[pi1])
336+ updated2 = ! isnan (model. updated_parameters[pi2])
340337
341338 if updated1 || updated2
342339 divisor = term. variable_1 == term. variable_2 ? 2 : 1
@@ -358,15 +355,9 @@ function _delta_parametric_constant(
358355 pi1 = p_idx (term. index_1)
359356 pi2 = p_idx (term. index_2)
360357 pi3 = p_idx (term. index_3)
361- updated1 =
362- haskey (model. updated_parameters, pi1) &&
363- ! isnan (model. updated_parameters[pi1])
364- updated2 =
365- haskey (model. updated_parameters, pi2) &&
366- ! isnan (model. updated_parameters[pi2])
367- updated3 =
368- haskey (model. updated_parameters, pi3) &&
369- ! isnan (model. updated_parameters[pi3])
358+ updated1 = ! isnan (model. updated_parameters[pi1])
359+ updated2 = ! isnan (model. updated_parameters[pi2])
360+ updated3 = ! isnan (model. updated_parameters[pi3])
370361
371362 if updated1 || updated2 || updated3
372363 old_val =
@@ -402,8 +393,7 @@ function _delta_parametric_affine_terms(
402393 # From pv terms (parameter * variable, always off-diagonal)
403394 for term in cubic_parameter_variable_terms (f)
404395 p_i = p_idx (term. variable_1)
405- if haskey (model. updated_parameters, p_i) &&
406- ! isnan (model. updated_parameters[p_i])
396+ if ! isnan (model. updated_parameters[p_i])
407397 var = term. variable_2
408398 coef = term. coefficient # Off-diagonal: use as-is
409399 old_val = model. parameters[p_i]
@@ -418,12 +408,8 @@ function _delta_parametric_affine_terms(
418408 var = term. index_3
419409 pi1 = p_idx (term. index_1)
420410 pi2 = p_idx (term. index_2)
421- updated1 =
422- haskey (model. updated_parameters, pi1) &&
423- ! isnan (model. updated_parameters[pi1])
424- updated2 =
425- haskey (model. updated_parameters, pi2) &&
426- ! isnan (model. updated_parameters[pi2])
411+ updated1 = ! isnan (model. updated_parameters[pi1])
412+ updated2 = ! isnan (model. updated_parameters[pi2])
427413
428414 if updated1 || updated2
429415 old_val =
@@ -459,8 +445,7 @@ function _delta_parametric_quadratic_terms(
459445 v2 = ifelse (first_is_greater, term. index_2, term. index_3)
460446 var_pair = (v1, v2)
461447
462- if haskey (model. updated_parameters, p_i) &&
463- ! isnan (model. updated_parameters[p_i])
448+ if ! isnan (model. updated_parameters[p_i])
464449 old_val = model. parameters[p_i]
465450 new_val = model. updated_parameters[p_i]
466451 delta = term. coefficient * (new_val - old_val)
0 commit comments