Skip to content

Conversation

@joaquimg
Copy link
Member

@joaquimg joaquimg commented Dec 1, 2025

No description provided.

end
dd += df_dx * val
else
error(
Copy link
Member

@blegat blegat Dec 2, 2025

Choose a reason for hiding this comment

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

If you use

elseif df_dx isa MOI.AbstractFunction
    MOI.Utilities.eval_variables(variable -> MOI.get(model, MOI.VariablePrimal(), term.variable), model, df_dx) * val
end

Then it will also work for nonlinear

Copy link
Member

Choose a reason for hiding this comment

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

But it will be quite inefficient to use that for loop for nonlinear. In that case, we should do reverse diff instead. But then, if the code only works for quadratic, we probably shouldn't do MOI.Nonlinear.SymbolicAD.derivative(obj_func, xi) and we should directly specialize it for the ScalarQuadraticFunction looping over the quadratic and linear terms.

xj_val = MOI.get(model, MOI.VariablePrimal(), term.variable)
dd += term.coefficient * xj_val * val
end
dd += df_dx * val
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this line be removed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants