version finale - #4
Open
dawutesse1 wants to merge 3 commits into
Open
dawutesse1 wants to merge 3 commits into
dawutesse1 wants to merge 3 commits into
Conversation
|
Status: |
dpo
reviewed
Aug 17, 2025
| Pkg.activate("labo3_env") | ||
| Pkg.add("LDLFactorizations") | ||
| Pkg.add("Metis") | ||
| Pkg.add("AMD") |
Contributor
There was a problem hiding this comment.
Tu n'utilises pas Metis, ni AMD...
| using LinearAlgebra | ||
| using Printf | ||
| using NLPModels | ||
| using ADNLPModels |
| g = grad(model, x) | ||
| gnorm = norm(g, Inf) | ||
| println(@sprintf("%4d | %12.4e | %12.4e | - ", k, fval, gnorm)) | ||
| if gnorm < max(eps_a, eps_r*norm(x,Inf)) |
Contributor
There was a problem hiding this comment.
pourquoi utiliser
|
|
||
| # 3) direction inexacte via CG de Krylov.jl | ||
| Hop = hess_op(model, x) | ||
| tol_cg = min(0.5, sqrt(gnorm)) * gnorm |
| tol_cg = min(0.5, sqrt(gnorm)) * gnorm | ||
| # cg de Krylov : tol, maxiter, linesearch | ||
| p, history = Krylov.cg(Hop, -g; | ||
| atol = tol_cg, |
| end | ||
|
|
||
| x .+= α*p | ||
| println(@sprintf("%4d | %12.4e | %12.4e | %8.4e", k, fval, gnorm, α)) |
Contributor
There was a problem hiding this comment.
Tu affiches deux lignes par itération.
| itmax = n, | ||
| linesearch = true) | ||
|
|
||
| # 4) recherche linéaire Armijo |
Contributor
There was a problem hiding this comment.
Mettre Armijo dans une fonction.
| model = ADNLPModel(pb) # wrapping ADNLPModels | ||
| println("\n=== Problème : ", nom, " ===") | ||
| x_star = newton_modifiee(model) | ||
| println("Solution trouvée : ", x_star) |
Contributor
There was a problem hiding this comment.
fval et ||g|| ne changent jamais... que se passe-t-il ?
|
|
||
| # 4) recherche linéaire Armijo | ||
| α = 1.0; ρ = 0.5; c = 1e-4 | ||
| while obj(model, x + α*p) > fval + c * α * dot(g, p) |
Contributor
There was a problem hiding this comment.
Tu recalcules dot(g, p) à chaque passage ...
|
|
||
| À nouveau, chaque pas de Newton complet (α=1) suffit. | ||
|
|
||
| Newton inexacte converge en 6 itérations également : |
Contributor
There was a problem hiding this comment.
??? Elle prend 100 itérations et ne semble pas changer x une seule fois.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.