Uno icon indicating copy to clipboard operation
Uno copied to clipboard

Pass the information of linear/nonlinear constraints in C and Python interfaces

Open cvanaret opened this issue 1 month ago • 5 comments

This info is used in l1RelaxedProblem: if no trust-region constraint is present, we do not need to relax the linear constraints.

cc @amontoison

cvanaret avatar Nov 07 '25 16:11 cvanaret

Maybe we can add an option to specify that we hav a constant Jacobian like in Ipopt?

amontoison avatar Nov 07 '25 17:11 amontoison

Ideally, we want to pass a vector of size number_constraints where component $i$ is whether constraint $c_i$ is linear (L) or nonlinear (N). If no such vector is passed, we assume that all the constraints are nonlinear.

cvanaret avatar Nov 07 '25 17:11 cvanaret

I like this idea, we could also specify if some constraints are quadratic this way, which allow to not recompute all the Hessian of the Lagrangian. Ipopt doesn't do that but KNITRO yes.

Update: We need to update the API of Uno to only compute a partial part of the Hessian of the Lagrangian if a mix of nonlinear / quadratic constraints (it is an issue). But if we only have quadratic constraints, it is free for us.

amontoison avatar Nov 07 '25 17:11 amontoison

Oh yeah! Perhaps the easiest way is to partition the constraints directly in the C interface:

uno_set_linear_constraints(...);
uno_set_quadratic_constraints(...);
uno_set_nonlinear_constraints(...);

For the Hessian it's perhaps not so straightforward because it also contains the objective contribution. Perhaps it is the modeler's/the modeling framework's responsibility to not recompute the Hessian of linear/quadratic constraints? In this case, Uno would still ask for the whole Hessian evaluation (objective + all constraints), which would be aggregated on the modeling side (some parts of it being constant).

cvanaret avatar Nov 07 '25 18:11 cvanaret

I like a lot:

uno_set_linear_constraints(...);
uno_set_quadratic_constraints(...);
uno_set_nonlinear_constraints(...);

and by default uno_set_constraints(...) is full non-linear constraints.

amontoison avatar Nov 07 '25 18:11 amontoison