Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for custom scaling #152

Merged
merged 3 commits into from
Mar 25, 2022
Merged

Add interface for custom scaling #152

merged 3 commits into from
Mar 25, 2022

Conversation

frapac
Copy link
Collaborator

@frapac frapac commented Mar 14, 2022

This PR exposes the scaling of the problem to the user with two functions:

  • scale_objective
  • scale_constraints!

The idea is to dispatch on the AbstractNLPModel being employed. By doing so, the user can overload the two functions to chose a different scaling. For instance, the user can scale the objective by a factor 1e-3with:

function scale_objective(nlp::MySpecialModel, grad::AbstractVector; max_gradient=1e-8)
     return 1e-3
end

This code was already employed to scale the reduced model in the paper.

@frapac frapac requested a review from sshin23 March 14, 2022 14:25
@codecov-commenter
Copy link

Codecov Report

Merging #152 (d4951bb) into master (b582ef3) will decrease coverage by 6.68%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
- Coverage   81.22%   74.53%   -6.69%     
==========================================
  Files          31       32       +1     
  Lines        3392     3385       -7     
==========================================
- Hits         2755     2523     -232     
- Misses        637      862     +225     
Impacted Files Coverage Δ
src/MadNLP.jl 62.50% <ø> (ø)
lib/MadNLPGPU/src/kernels.jl 65.00% <100.00%> (+65.00%) ⬆️
src/interiorpointsolver.jl 95.52% <100.00%> (-0.05%) ⬇️
src/scaling.jl 100.00% <100.00%> (ø)
lib/MadNLPGraph/src/plasmo_interface.jl 0.00% <0.00%> (-93.31%) ⬇️
lib/MadNLPGraph/src/schur.jl 0.00% <0.00%> (-80.24%) ⬇️
lib/MadNLPGraph/src/graphtools.jl 0.00% <0.00%> (-66.67%) ⬇️
lib/MadNLPGraph/src/schwarz.jl 0.00% <0.00%> (-63.77%) ⬇️
src/matrixtools.jl 83.60% <0.00%> (-16.40%) ⬇️
src/utils.jl 47.61% <0.00%> (-10.72%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec2aa2f...d4951bb. Read the comment docs.

Copy link
Member

@sshin23 sshin23 left a comment

Choose a reason for hiding this comment

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

Great idea @frapac!

@frapac frapac merged commit 9c07280 into master Mar 25, 2022
@frapac frapac deleted the fp/scaling branch March 25, 2022 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants