@@ -278,7 +278,7 @@ function _cubic_objective_set_forward!(model::POI.Optimizer{T}) where {T}
278278 quadratic_terms = MOI. ScalarQuadraticTerm{T}[]
279279
280280 # pvv terms: Δp * coeff → quadratic perturbation
281- for term in POI. _cubic_pvv_terms (pf)
281+ for term in POI. cubic_parameter_variable_variable_terms (pf)
282282 p = term. index_1
283283 v1 = term. index_2
284284 v2 = term. index_3
@@ -288,15 +288,12 @@ function _cubic_objective_set_forward!(model::POI.Optimizer{T}) where {T}
288288 if v1 == v2
289289 qcoeff *= 2 # MOI diagonal convention
290290 end
291- push! (
292- quadratic_terms,
293- MOI. ScalarQuadraticTerm {T} (qcoeff, v1, v2),
294- )
291+ push! (quadratic_terms, MOI. ScalarQuadraticTerm {T} (qcoeff, v1, v2))
295292 end
296293 end
297294
298295 # ppv terms: chain rule on two params → affine perturbation
299- for term in POI. _cubic_ppv_terms (pf)
296+ for term in POI. cubic_parameter_parameter_variable_terms (pf)
300297 p1 = term. index_1
301298 p2 = term. index_2
302299 v = term. index_3
@@ -312,7 +309,7 @@ function _cubic_objective_set_forward!(model::POI.Optimizer{T}) where {T}
312309 end
313310
314311 # ppp terms: chain rule on three params → constant perturbation
315- for term in POI. _cubic_ppp_terms (pf)
312+ for term in POI. cubic_parameter_parameter_parameter_terms (pf)
316313 p1 = term. index_1
317314 p2 = term. index_2
318315 p3 = term. index_3
@@ -322,49 +319,39 @@ function _cubic_objective_set_forward!(model::POI.Optimizer{T}) where {T}
322319 p1_val = MOI. get (model, MOI. VariablePrimal (), p1)
323320 p2_val = MOI. get (model, MOI. VariablePrimal (), p2)
324321 p3_val = MOI. get (model, MOI. VariablePrimal (), p3)
325- cte += term. coefficient * (
326- Δp1 * p2_val * p3_val +
327- p1_val * Δp2 * p3_val +
328- p1_val * p2_val * Δp3
329- )
322+ cte +=
323+ term. coefficient * (
324+ Δp1 * p2_val * p3_val +
325+ p1_val * Δp2 * p3_val +
326+ p1_val * p2_val * Δp3
327+ )
330328 end
331329
332330 # Degree-2: p terms (affine parameter → constant perturbation)
333- for term in pf . p
331+ for term in POI . cubic_affine_parameter_terms (pf)
334332 p = term. variable
335333 Δp = get (sensitivity_data. parameter_input_forward, p, zero (T))
336334 cte += Δp * term. coefficient
337335 end
338336 # Degree-2: pp terms (parameter-parameter → constant perturbation)
339- for term in pf . pp
337+ for term in POI . cubic_parameter_parameter_terms (pf)
340338 p_1 = term. variable_1
341339 p_2 = term. variable_2
342340 Δp1 = get (sensitivity_data. parameter_input_forward, p_1, zero (T))
343341 Δp2 = get (sensitivity_data. parameter_input_forward, p_2, zero (T))
344342 p1_val = MOI. get (model, MOI. VariablePrimal (), p_1)
345343 p2_val = MOI. get (model, MOI. VariablePrimal (), p_2)
346- cte +=
347- Δp1 *
348- term. coefficient *
349- p2_val /
350- ifelse (p_1 === p_2, T (2 ), T (1 ))
351- cte +=
352- Δp2 *
353- term. coefficient *
354- p1_val /
355- ifelse (p_1 === p_2, T (2 ), T (1 ))
344+ cte += Δp1 * term. coefficient * p2_val / ifelse (p_1 === p_2, T (2 ), T (1 ))
345+ cte += Δp2 * term. coefficient * p1_val / ifelse (p_1 === p_2, T (2 ), T (1 ))
356346 end
357347 # Degree-2: pv terms (parameter-variable → affine perturbation)
358- for term in pf . pv
348+ for term in POI . cubic_parameter_variable_terms (pf)
359349 p = term. variable_1
360350 Δp = get (sensitivity_data. parameter_input_forward, p, zero (T))
361351 if ! iszero (Δp)
362352 push! (
363353 affine_terms,
364- MOI. ScalarAffineTerm {T} (
365- Δp * term. coefficient,
366- term. variable_2,
367- ),
354+ MOI. ScalarAffineTerm {T} (Δp * term. coefficient, term. variable_2),
368355 )
369356 end
370357 end
@@ -385,14 +372,18 @@ function _cubic_objective_get_reverse!(model::POI.Optimizer{T}) where {T}
385372 model,
386373 POI. ParametricObjectiveFunction {POI.ParametricCubicFunction{T}} (),
387374 )
388- pvv_terms = POI. _cubic_pvv_terms (pf)
389- ppv_terms = POI. _cubic_ppv_terms (pf)
390- ppp_terms = POI. _cubic_ppp_terms (pf)
391- p_terms = pf. p
392- pp_terms = pf. pp
393- pv_terms = pf. pv
394- if isempty (pvv_terms) && isempty (ppv_terms) && isempty (ppp_terms) &&
395- isempty (p_terms) && isempty (pp_terms) && isempty (pv_terms)
375+ pvv_terms = POI. cubic_parameter_variable_variable_terms (pf)
376+ ppv_terms = POI. cubic_parameter_parameter_variable_terms (pf)
377+ ppp_terms = POI. cubic_parameter_parameter_parameter_terms (pf)
378+ p_terms = POI. cubic_affine_parameter_terms (pf)
379+ pp_terms = POI. cubic_parameter_parameter_terms (pf)
380+ pv_terms = POI. cubic_parameter_variable_terms (pf)
381+ if isempty (pvv_terms) &&
382+ isempty (ppv_terms) &&
383+ isempty (ppp_terms) &&
384+ isempty (p_terms) &&
385+ isempty (pp_terms) &&
386+ isempty (pv_terms)
396387 return
397388 end
398389 sensitivity_data = _get_sensitivity_data (model)
0 commit comments