Résolution des problèmes d'optimisation avec contraintes, en utilisant la méthode de pénalité quadratique.#6
Open
bouayoubegrine wants to merge 3 commits intodpo-mth8408:mainfrom
Open
Conversation
bouayoubegrine
commented
Jul 18, 2025
- Résolution des problèmes d'optimisation avec contraintes, en utilisant la méthode de pénalité quadratique.
dpo
reviewed
Aug 17, 2025
dpo
reviewed
Aug 17, 2025
| @@ -0,0 +1,125 @@ | |||
| #| echo: false | |||
| #| output: falseusing Pkg | |||
|
Status: |
dpo
reviewed
Aug 17, 2025
| # modifier la fonction fournie en laboratoire | ||
|
|
||
| function c!(cx,x) | ||
| return [10 * (x[2] - x[1]^2)] |
Contributor
There was a problem hiding this comment.
Il faut placer ce vecteur dans cx.
| ################ | ||
| ##### Initialiser cx en x | ||
| cx = zeros(eltype(x), nlp.meta.ncon)# Initialiser la violation des contraintes | ||
| nlp.c!(cx, x) |
| function kkt_residual(nlp,x,y) | ||
| J = jac(nlp, x) | ||
| gradient = grad(nlp, x) | ||
| gradient = gradient - J'*y |
Contributor
There was a problem hiding this comment.
La réalisabilité primale fait aussi partie des conditions de KKT.
| println("Problème ", i, " résolu avec newton modifiée") | ||
| quad_penalty(nlp; x =nlp.meta.x0, ϵa = 1e-6, ϵr = 1e-6,σ = 2.0, max_iter =100, method = "Modified_Newton") | ||
| println("Problème ", i, " résolu avec newton inexact") | ||
| quad_penalty(nlp; x =nlp.meta.x0, ϵa = 1e-6, ϵr = 1e-6,σ = 2.0, max_iter =100, method = "Inexact_Newton") |
Contributor
There was a problem hiding this comment.
Sur certains problèmes, ton "résidu de KKT" est tout petit, mais ||c(x)|| n'est pas petit et tu t'arrêtes quand-même. Sur un des problèmes, tu génères des NaN. Tu n'as pas examiné tes résultats à la loupe.
|
|
||
| # En-têtes de colonnes | ||
| col_names = ["nom", "nvar", "ncon", "‖r_KKT‖ (initial)", | ||
| "‖r_KKT‖ (final)", "‖y‖ (final)", "rho", "iterations", "status finale"] |
Contributor
There was a problem hiding this comment.
On ne voit pas toutes les colonnes.
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.