Skip to content

Conversation

andrewrosemberg
Copy link
Collaborator

Had issues with my old pr (#282). So this one is the updated version.

andrewrosemberg and others added 30 commits February 22, 2025 12:38
* fix conic error

* use jump psd problem

* [docs] update to Documenter@1 (#286)

* [docs] update to Documenter@1

* Update

* update

* format

* Pass attributes through Objective.FunctionConversionBridge (#287)

* Pass attributes through Objective.FunctionConversionBridge

* Fix

* add test

* fix tol

* fix test

* add reverse test

---------

Co-authored-by: joaquimg <[email protected]>

* bump POI

* cleanup

---------

Co-authored-by: Oscar Dowson <[email protected]>
Co-authored-by: Benoît Legat <[email protected]>
Co-authored-by: joaquimg <[email protected]>
* prepare more tests

* sketch

* temp examples

* remove printing

* remove printing

* remove duplicatie def

* move definition

* format

* format

* simplify conic model

* force nlp on nlp tests

* fix param tests

* cleanup parameter usage

* remove code

* cleanup usage of parameters

* format

* add temp dep

* format

* add temp dep

* fix PSDSquare

* temp fix for tests

* format
@andrewrosemberg andrewrosemberg self-assigned this Aug 20, 2025
@andrewrosemberg andrewrosemberg mentioned this pull request Aug 20, 2025
3 tasks
@andrewrosemberg andrewrosemberg added the enhancement New feature or request label Aug 20, 2025
@andrewrosemberg
Copy link
Collaborator Author

andrewrosemberg commented Aug 20, 2025

waiting final rebase after #281 is merged

Copy link

codecov bot commented Aug 20, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.13%. Comparing base (23c27b6) to head (2a0c9b8).

Files with missing lines Patch % Lines
src/NonLinearProgram/NonLinearProgram.jl 84.61% 6 Missing ⚠️
src/diff_opt.jl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #303      +/-   ##
==========================================
+ Coverage   88.94%   89.13%   +0.19%     
==========================================
  Files          16       16              
  Lines        2045     2090      +45     
==========================================
+ Hits         1819     1863      +44     
- Misses        226      227       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Using Lagrangian duality we could already calculate the objective sensitivity with respect to parameters that appear in the RHS of the constraints (e.g, `cons` in this case for parameter `p`) - i.e. The objective sensitivity w.r.t. a parameter change in the RHS of the constraints is given by the optimal multiplier.

On the other hand, if the parameter appears in the LHS of the constraints, we can calculate the objective sensitivity with respect to the parameter using: the sensitivities of the variables with respect to the parameter, \( \frac{\partial x}{\partial p} \), and the gradient of the objective with respect to the variables \( \frac{\partial f}{\partial x} \):
Copy link
Member

Choose a reason for hiding this comment

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

So this means you can compute it using the dual objective if you only have parameters as constraint constants and you can also use it with the primal objective using the solution sensitivity which also works even if you have parameters as constraint coefficients.
2 questions the readers might have:

  1. If you only have parameters on the constraint constants, would computing the sensitivity using the primal or dual objective match ?
  2. Why not use the dual objective but also include the sensitivity of the dual solution ?

Copy link
Member

Choose a reason for hiding this comment

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

Probably it would make sense to also add ForwardDualObjectiveSensitivity (in another PR of course) ?

Copy link
Collaborator Author

@andrewrosemberg andrewrosemberg Sep 12, 2025

Choose a reason for hiding this comment

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

This is a good point. I will add an issue for this.

My naive response for now is:

If you only have parameters on the constraint constants, would computing the sensitivity using the primal or dual objective match?

Yes, and we add this as a test. Also added a sentence on this:

Note that, if the parameter appears as a constant in a constraint, the objective sensitivity calculated through solution sensitivity is equivalent to the optimal multiplier associated with the constraint.

Why not use the dual objective but also include the sensitivity of the dual solution?

Added a sentence on this (and equivalence under strong duality) and will create an issue

Copy link
Collaborator Author

@andrewrosemberg andrewrosemberg Sep 12, 2025

Choose a reason for hiding this comment

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

Sentence:

**Dual Objective Sensitivity**
In addition to the primal objective sensitivity, one could also calculate the dual objective sensitivity with respect to the parameters using the gradients of the dual objective and the sensitivities of the dual variables with respect to the parameters.
This is currently not implemented for any problem class, but will be available in future releases.
Note that the dual objective sensitivity is equivalent to the primal objective sensitivity problems where strong duality holds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Issue #315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants