Skip to content

add ScaledModel - #123

Open
frapac wants to merge 6 commits into
JuliaSmoothOptimizers:mainfrom
frapac:fp/scaler
Open

add ScaledModel#123
frapac wants to merge 6 commits into
JuliaSmoothOptimizers:mainfrom
frapac:fp/scaler

Conversation

@frapac

@frapac frapac commented Jul 25, 2024

Copy link
Copy Markdown

Following a suggestion by @dpo

@codecov

codecov Bot commented Jul 25, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.04762% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.87%. Comparing base (b28197a) to head (9f3543c).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/scaled-model.jl 69.04% 52 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
- Coverage   97.29%   92.87%   -4.42%     
==========================================
  Files           6        7       +1     
  Lines         886     1067     +181     
==========================================
+ Hits          862      991     +129     
- Misses         24       76      +52     

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
ADNLPModels.jl
AmplNLReader.jl
CUTEst.jl
CaNNOLeS.jl
DCI.jl
FletcherPenaltySolver.jl
JSOSolvers.jl
LLSModels.jl
NLPModelsIpopt.jl
NLPModelsJuMP.jl
NLPModelsTest.jl
Percival.jl
QuadraticModels.jl
SolverBenchmark.jl
SolverTools.jl

@tmigot tmigot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @frapac for the PR! Here is a first pass of comments. Sorry if I ask for a lot of clarification.
By the way, would you have a more general use case that would serve as a basis for a tutorial?

Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl
Comment thread src/scaled-model.jl
the gradient and the Jacobian evaluated at the initial point ``x0``.

"""
struct ScaledModel{T, S, M} <: NLPModels.AbstractNLPModel{T, S}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and same comment throughout the file

@frapac

frapac commented Jul 22, 2026

Copy link
Copy Markdown
Author

The linear and nonlinear API for the constraints have been implemented.

@dpo dpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! I think we can use this in multiple places. I just have a few comments to make the code more explicit.

Comment thread test/nlp/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl
# Compute scaling as min(1, max_gradient / norm(∇cᵢ, Inf) )
for i in eachindex(cons)
cons[i] = min(1.0, max_gradient / cons[i])
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Either I don't understand this function, or it doesn't do what's announced above. Maybe a docstring would clarify.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The idea is to first compute the norm inf of the gradient of each constraint in cons. Then, the scaling is defined as specified in the comment.

Comment thread src/scaled-model.jl Outdated
end
end

function _set_jacobian_scaling!(Jx, Ji, Jj, cons)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The name cons suggests "constraint" (values). But that's not what it is, is it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Indeed, the name scaling is more appropriate

Comment thread src/scaled-model.jl
Comment thread src/scaled-model.jl
Comment thread src/scaled-model.jl Outdated
Comment thread src/scaled-model.jl Outdated
Co-authored-by: Maxence Gollier <134112149+MaxenceGollier@users.noreply.github.com>
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.

4 participants