diff --git a/README.md b/README.md index 9607f0130a044a8d35314ec7f73cd885e841b522..5a39c7b3a67a23c7669932a58a9d68437cb971c4 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,12 @@ ## Récupérer les sources -Pour récupérer les sources, il faut cloner ce dépot git : - -```bash -git clone https://gitlab.irit.fr/toc/mathn7/optimisation-numerique/projet-optinum.git -``` +Pour récupérer les sources, il faut cloner ce dépot git. Vous pouvez suivre les instructions : +[Cloner un dépôt Gitlab](https://gitlab.irit.fr/toc/etu-n7/documentation/-/wikis/Cloner-un-projet-Gitlab). ## Organisation des sources -Les sujets liés au projet se trouvent dans les notebooks. Voici l'ordre des sujets : +Les sujets liés au projet se trouvent dans les notebooks du répertoire `notebooks`. Voici l'ordre des sujets : * Newton * Régions de confiance @@ -20,9 +17,9 @@ Pour réaliser le projet vous aurez besoin de cette [documentation](doc-projet.p ## Installation de Julia -Si vous n'avez pas encore installer Julia sur votre compte N7 ou sur votre machine personnelle, suivez les indications : -[Utilisation de Julia à l'N7](https://gitlab.irit.fr/toc/mathn7/wiki/-/wikis/Utilisation-de-Julia-à-l'N7). +Si vous n'avez pas encore installer Julia sur votre compte N7 ou sur votre machine personnelle, suivez les instructions : +[Utilisation de Julia à l'N7](https://gitlab.irit.fr/toc/etu-n7/documentation/-/wikis/Utilisation-de-Julia-à-l'N7). ## Illustration de la méthode de Newton - + \ No newline at end of file diff --git a/doc-projet.pdf b/doc-projet.pdf index 62521cacf8f9ba52e96c87cb5aabe367d3ca9d13..f321b71330978dc4083f5f86e47cab2f9b3bd86c 100644 Binary files a/doc-projet.pdf and b/doc-projet.pdf differ diff --git a/src/Algorithme_De_Newton.jl b/src/Algorithme_De_Newton.jl deleted file mode 100644 index b47719bef2e9685f4fb49a5e5e0614f8c6574211..0000000000000000000000000000000000000000 --- a/src/Algorithme_De_Newton.jl +++ /dev/null @@ -1,61 +0,0 @@ - -@doc doc""" -#### Objet -Cette fonction implémente l'algorithme de Newton pour résoudre un problème d'optimisation sans contraintes - -#### Syntaxe -```julia -xmin,fmin,flag,nb_iters = Algorithme_de_Newton(f,gradf,hessf,x0,option) -``` - -#### Entrées : - - f : (Function) la fonction à minimiser - - gradf : (Function) le gradient de la fonction f - - hessf : (Function) la hessienne de la fonction f - - x0 : (Array{Float,1}) première approximation de la solution cherchée - - options : (Array{Float,1}) - - max_iter : le nombre maximal d'iterations - - Tol_abs : la tolérence absolue - - Tol_rel : la tolérence relative - - epsilon : epsilon pour les tests de stagnation - -#### Sorties: - - xmin : (Array{Float,1}) une approximation de la solution du problème : ``\min_{x \in \mathbb{R}^{n}} f(x)`` - - fmin : (Float) ``f(x_{min})`` - - flag : (Integer) indique le critère sur lequel le programme s'est arrêté (en respectant cet ordre de priorité si plusieurs critères sont vérifiés) - - 0 : CN1 - - 1 : stagnation du xk - - 2 : stagnation du f - - 3 : nombre maximal d'itération dépassé - - nb_iters : (Integer) le nombre d'itérations faites par le programme - -#### Exemple d'appel -```@example -f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2 -gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)] -hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200] -x0 = [1; 0] -options = [] -xmin,fmin,flag,nb_iters = Algorithme_De_Newton(f,gradf,hessf,x0,options) -``` -""" -function Algorithme_De_Newton(f::Function,gradf::Function,hessf::Function,x0,options) - - "# Si options == [] on prends les paramètres par défaut" - if options == [] - max_iter = 100 - Tol_abs = sqrt(eps()) - Tol_rel = 1e-15 - epsilon = 1.e-2 - else - max_iter = options[1] - Tol_abs = options[2] - Tol_rel = options[3] - epsilon = options[4] - end - xmin = x0 - fmin = f(x0) - flag = 0 - nb_iters = 0 - return xmin,fmin,flag,nb_iters -end diff --git a/src/Gradient_Conjugue_Tronque.jl b/src/Gradient_Conjugue_Tronque.jl deleted file mode 100644 index db9e6a5ddb6892f549ef920aaffcbc05f27dcdc3..0000000000000000000000000000000000000000 --- a/src/Gradient_Conjugue_Tronque.jl +++ /dev/null @@ -1,52 +0,0 @@ -@doc doc""" -#### Objet -Cette fonction calcule une solution approchée du problème - -```math -\min_{||s||< \Delta} q(s) = s^{t} g + \frac{1}{2} s^{t}Hs -``` - -par l'algorithme du gradient conjugué tronqué - -#### Syntaxe -```julia -s = Gradient_Conjugue_Tronque(g,H,option) -``` - -#### Entrées : - - g : (Array{Float,1}) un vecteur de ``\mathbb{R}^n`` - - H : (Array{Float,2}) une matrice symétrique de ``\mathbb{R}^{n\times n}`` - - options : (Array{Float,1}) - - delta : le rayon de la région de confiance - - max_iter : le nombre maximal d'iterations - - tol : la tolérance pour la condition d'arrêt sur le gradient - -#### Sorties: - - s : (Array{Float,1}) le pas s qui approche la solution du problème : ``min_{||s||< \Delta} q(s)`` - -#### Exemple d'appel: -```julia -gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)] -hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200] -xk = [1; 0] -options = [] -s = Gradient_Conjugue_Tronque(gradf(xk),hessf(xk),options) -``` -""" -function Gradient_Conjugue_Tronque(g,H,options) - - "# Si option est vide on initialise les 3 paramètres par défaut" - if options == [] - delta = 2 - max_iter = 100 - tol = 1e-6 - else - delta = options[1] - max_iter = options[2] - tol = options[3] - end - - n = length(g) - s = zeros(n) - return s -end diff --git a/src/Lagrangien_Augmente.jl b/src/Lagrangien_Augmente.jl old mode 100755 new mode 100644 index cffadf803e3cb2367ddfcccd78cefd1800ed6434..ebeac8597bb374b99d4e852c05d3359b858bbf62 --- a/src/Lagrangien_Augmente.jl +++ b/src/Lagrangien_Augmente.jl @@ -1,92 +1,75 @@ -@doc doc""" -#### Objet +using LinearAlgebra +include("../src/newton.jl") +include("../src/regions_de_confiance.jl") +""" -Résolution des problèmes de minimisation avec une contrainte d'égalité scalaire par l'algorithme du lagrangien augmenté. +Approximation d'une solution au problème -#### Syntaxe -```julia -xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options) -``` + min f(x), x ∈ Rⁿ, sous la c c(x) = 0, -#### Entrées - - algo : (String) l'algorithme sans contraintes à utiliser: - - "newton" : pour l'algorithme de Newton - - "cauchy" : pour le pas de Cauchy - - "gct" : pour le gradient conjugué tronqué - - f : (Function) la fonction à minimiser - - gradf : (Function) le gradient de la fonction - - hessf : (Function) la hessienne de la fonction - - c : (Function) la contrainte [x est dans le domaine des contraintes ssi ``c(x)=0``] - - gradc : (Function) le gradient de la contrainte - - hessc : (Function) la hessienne de la contrainte - - x0 : (Array{Float,1}) la première composante du point de départ du Lagrangien - - options : (Array{Float,1}) - 1. epsilon : utilisé dans les critères d'arrêt - 2. tol : la tolérance utilisée dans les critères d'arrêt - 3. itermax : nombre maximal d'itération dans la boucle principale - 4. lambda0 : la deuxième composante du point de départ du Lagrangien - 5. mu0, tho : valeurs initiales des variables de l'algorithme +par l'algorithme du lagrangien augmenté. -#### Sorties -- xmin : (Array{Float,1}) une approximation de la solution du problème avec contraintes -- fxmin : (Float) ``f(x_{min})`` -- flag : (Integer) indicateur du déroulement de l'algorithme - - 0 : convergence - - 1 : nombre maximal d'itération atteint - - (-1) : une erreur s'est produite -- niters : (Integer) nombre d'itérations réalisées -- muks : (Array{Float64,1}) tableau des valeurs prises par mu_k au cours de l'exécution -- lambdaks : (Array{Float64,1}) tableau des valeurs prises par lambda_k au cours de l'exécution +# Syntaxe -#### Exemple d'appel -```julia -using LinearAlgebra -algo = "gct" # ou newton|gct -f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2 -gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)] -hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200] -c(x) = (x[1]^2) + (x[2]^2) -1.5 -gradc(x) = [2*x[1] ;2*x[2]] -hessc(x) = [2 0;0 2] -x0 = [1; 0] -options = [] -xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options) -``` + x_sol, f_sol, flag, nb_iters, μs, λs = lagrangien_augmente(f, gradf, hessf, c, gradc, hessc, x0; kwargs...) + +# Entrées + + - f : (Function) la ftion à minimiser + - gradf : (Function) le gradient de f + - hessf : (Function) la hessienne de f + - c : (Function) la c à valeur dans R + - gradc : (Function) le gradient de c + - hessc : (Function) la hessienne de c + - x0 : (Vector{<:Real}) itéré initial + - kwargs : les options sous formes d'arguments "keywords" + • max_iter : (Integer) le nombre maximal d'iterations (optionnel, par défaut 1000) + • tol_abs : (Real) la tolérence absolue (optionnel, par défaut 1e-10) + • tol_rel : (Real) la tolérence relative (optionnel, par défaut 1e-8) + • λ0 : (Real) le multiplicateur de lagrange associé à c initial (optionnel, par défaut 2) + • μ0 : (Real) le facteur initial de pénalité de la c (optionnel, par défaut 10) + • τ : (Real) le facteur d'accroissement de μ (optionnel, par défaut 2) + • algo_noc : (String) l'algorithme sans c à utiliser (optionnel, par défaut "rc-gct") + * "newton" : pour l'algorithme de Newton + * "rc-cauchy" : pour les régions de confiance avec pas de Cauchy + * "rc-gct" : pour les régions de confiance avec gradient conjugué tronqué + +# Sorties + + - x_sol : (Vector{<:Real}) une approximation de la solution du problème + - f_sol : (Real) f(x_sol) + - flag : (Integer) indique le critère sur lequel le programme s'est arrêté + • 0 : convergence + • 1 : nombre maximal d'itération dépassé + - nb_iters : (Integer) le nombre d'itérations faites par le programme + - μs : (Vector{<:Real}) tableau des valeurs prises par μk au cours de l'exécution + - λs : (Vector{<:Real}) tableau des valeurs prises par λk au cours de l'exécution -#### Tolérances des algorithmes appelés +# Exemple d'appel -Pour les tolérances définies dans les algorithmes appelés (Newton et régions de confiance), prendre les tolérances par défaut définies dans ces algorithmes. + f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2 + gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)] + hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200] + c(x) = x[1]^2 + x[2]^2 - 1.5 + gradc(x) = 2*x + hessc(x) = [2 0; 0 2] + x0 = [1; 0] + x_sol, _ = lagrangien_augmente(f, gradf, hessf, c, gradc, hessc, x0, algo_noc="rc-gct") """ -function Lagrangien_Augmente(algo,fonc::Function,contrainte::Function,gradfonc::Function, - hessfonc::Function,grad_contrainte::Function,hess_contrainte::Function,x0,options) +function lagrangien_augmente(f::Function, gradf::Function, hessf::Function, + c::Function, gradc::Function, hessc::Function, x0::Vector{<:Real}; + max_iter::Integer=1000, tol_abs::Real=1e-10, tol_rel::Real=1e-8, + λ0::Real=2, μ0::Real=10, τ::Real=2, algo_noc::String="rc-gct") - if options == [] - epsilon = 1e-2 - tol = 1e-5 - itermax = 1000 - lambda0 = 2 - mu0 = 100 - tho = 2 - else - epsilon = options[1] - tol = options[2] - itermax = options[3] - lambda0 = options[4] - mu0 = options[5] - tho = options[6] - end + # + x_sol = x0 + f_sol = f(x_sol) + flag = -1 + nb_iters = 0 + μs = [μ0] # vous pouvez faire μs = vcat(μs, μk) pour concaténer les valeurs + λs = [λ0] - n = length(x0) - xmin = zeros(n) - fxmin = 0 - flag = 0 - iter = 0 - muk = mu0 - muks = [mu0] - lambdak = lambda0 - lambdaks = [lambda0] + return x_sol, f_sol, flag, nb_iters, μs, λs - - return xmin,fxmin,flag,iter, muks, lambdaks end diff --git a/src/Pas_De_Cauchy.jl b/src/Pas_De_Cauchy.jl deleted file mode 100644 index 83748fe170b333197123ab515ffecf44e7120022..0000000000000000000000000000000000000000 --- a/src/Pas_De_Cauchy.jl +++ /dev/null @@ -1,46 +0,0 @@ -@doc doc""" - -#### Objet -Cette fonction calcule une solution approchée du problème -```math -\min_{||s||< \Delta} s^{t}g + \frac{1}{2}s^{t}Hs -``` -par le calcul du pas de Cauchy. - -#### Syntaxe -```julia -s, e = Pas_De_Cauchy(g,H,delta) -``` - -#### Entrées - - g : (Array{Float,1}) un vecteur de ``\mathbb{R}^n`` - - H : (Array{Float,2}) une matrice symétrique de ``\mathbb{R}^{n\times n}`` - - delta : (Float) le rayon de la région de confiance - -#### Sorties - - s : (Array{Float,1}) une approximation de la solution du sous-problème - - e : (Integer) indice indiquant l'état de sortie: - si g != 0 - si on ne sature pas la boule - e <- 1 - sinon - e <- -1 - sinon - e <- 0 - -#### Exemple d'appel -```julia -g = [0; 0] -H = [7 0 ; 0 2] -delta = 1 -s, e = Pas_De_Cauchy(g,H,delta) -``` -""" -function Pas_De_Cauchy(g,H,delta) - - e = 0 - n = length(g) - s = zeros(n) - - return s, e -end diff --git a/src/Regions_De_Confiance.jl b/src/Regions_De_Confiance.jl index 74274a0521e820fb5d2ab6baa940a9333552a8c9..1dfc2f0cd08d72a88c47386f872fb6715881d151 100644 --- a/src/Regions_De_Confiance.jl +++ b/src/Regions_De_Confiance.jl @@ -1,91 +1,68 @@ -@doc doc""" +using LinearAlgebra +include("../src/cauchy.jl") +include("../src/gct.jl") +""" +Approximation de la solution du problème min f(x), x ∈ Rⁿ. -#### Objet +L'algorithme des régions de confiance résout à chaque itération, un modèle quadratique +de la fonction f dans une boule (appelée la région de confiance) de centre l'itéré +courant. Cette minimisation se fait soit par un pas de Cauchy ou par l'algorithme +du gradient conjugué tronqué. -Minimise une fonction de ``\mathbb{R}^{n}`` à valeurs dans ``\mathbb{R}`` en utilisant l'algorithme des régions de confiance. +# Syntaxe -La solution approchées des sous-problèmes quadratiques est calculé -par le pas de Cauchy ou le pas issu de l'algorithme du gradient conjugue tronqué + x_sol, f_sol, flag, nb_iters, xs = regions_de_confiance(f, gradf, hessf, x0; kwargs...) -#### Syntaxe -```julia -xmin, fxmin, flag, nb_iters = Regions_De_Confiance(algo,f,gradf,hessf,x0,option) -``` +# Entrées -#### Entrées : + - f : (Function) la fonction à minimiser + - gradf : (Function) le gradient de la fonction f + - hessf : (Function) la hessienne de la fonction f + - x0 : (Vector{<:Real}) itéré initial + - kwargs : les options sous formes d'arguments "keywords" + • max_iter : (Integer) le nombre maximal d'iterations (optionnel, par défaut 5000) + • tol_abs : (Real) la tolérence absolue (optionnel, par défaut 1e-10) + • tol_rel : (Real) la tolérence relative (optionnel, par défaut 1e-8) + • epsilon : (Real) le epsilon pour les tests de stagnation (optionnel, par défaut 1) + • Δ0 : (Real) le rayon initial de la région de confiance (optionnel, par défaut 2) + • Δmax : (Real) le rayon maximal de la région de confiance (optionnel, par défaut 10) + • γ1, γ2 : (Real) les facteurs de mise à jour de la région de confiance (optionnel, par défaut 0.5 et 2) + • η1, η2 : (Real) les seuils pour la mise à jour de la région de confiance (optionnel, par défaut 0.25 et 0.75) + • algo_pas : (String) l'algorithme de calcul du pas - "cauchy" ou "gct" (optionnel, par défaut "gct") + • max_iter_gct : (Integer) le nombre maximal d'iterations du GCT (optionnel, par défaut 2*length(x0)) - - algo : (String) string indicant la méthode à utiliser pour calculer le pas - - "gct" : pour l'algorithme du gradient conjugué tronqué - - "cauchy": pour le pas de Cauchy - - f : (Function) la fonction à minimiser - - gradf : (Function) le gradient de la fonction f - - hessf : (Function) la hessiene de la fonction à minimiser - - x0 : (Array{Float,1}) point de départ - - options : (Array{Float,1}) - - deltaMax : utile pour les m-à-j de la région de confiance - ``R_{k}=\left\{x_{k}+s ;\|s\| \leq \Delta_{k}\right\}`` - - gamma1, gamma2 : ``0 < \gamma_{1} < 1 < \gamma_{2}`` pour les m-à-j de ``R_{k}`` - - eta1, eta2 : ``0 < \eta_{1} < \eta_{2} < 1`` pour les m-à-j de ``R_{k}`` - - delta0 : le rayon de départ de la région de confiance - - max_iter : le nombre maximale d'iterations - - Tol_abs : la tolérence absolue - - Tol_rel : la tolérence relative - - epsilon : epsilon pour les tests de stagnation +# Sorties -#### Sorties: + - x_sol : (Vector{<:Real}) une approximation de la solution du problème + - f_sol : (Real) f(x_sol) + - flag : (Integer) indique le critère sur lequel le programme s'est arrêté + • 0 : convergence + • 1 : stagnation du xk + • 2 : stagnation du f + • 3 : nombre maximal d'itération dépassé + - nb_iters : (Integer) le nombre d'itérations faites par le programme + - xs : (Vector{Vector{<:Real}}) les itérés - - xmin : (Array{Float,1}) une approximation de la solution du problème : - ``\min_{x \in \mathbb{R}^{n}} f(x)`` - - fxmin : (Float) ``f(x_{min})`` - - flag : (Integer) un entier indiquant le critère sur lequel le programme s'est arrêté (en respectant cet ordre de priorité si plusieurs critères sont vérifiés) - - 0 : CN1 - - 1 : stagnation du ``x`` - - 2 : stagnation du ``f`` - - 3 : nombre maximal d'itération dépassé - - nb_iters : (Integer)le nombre d'iteration qu'à fait le programme +# Exemple d'appel -#### Exemple d'appel -```julia -algo="gct" -f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2 -gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)] -hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200] -x0 = [1; 0] -options = [] -xmin, fxmin, flag, nb_iters = Regions_De_Confiance(algo,f,gradf,hessf,x0,options) -``` -""" -function Regions_De_Confiance(algo,f::Function,gradf::Function,hessf::Function,x0,options) + f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2 + gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)] + hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200] + x0 = [1; 0] + x_sol, f_sol, flag, nb_iters, xs = regions_de_confiance(f, gradf, hessf, x0, algo_pas="gct") - if options == [] - deltaMax = 10 - gamma1 = 0.5 - gamma2 = 2.00 - eta1 = 0.25 - eta2 = 0.75 - delta0 = 2 - max_iter = 1000 - Tol_abs = sqrt(eps()) - Tol_rel = 1e-15 - epsilon = 1.e-2 - else - deltaMax = options[1] - gamma1 = options[2] - gamma2 = options[3] - eta1 = options[4] - eta2 = options[5] - delta0 = options[6] - max_iter = options[7] - Tol_abs = options[8] - Tol_rel = options[9] - epsilon = options[10] - end +""" +function regions_de_confiance(f::Function, gradf::Function, hessf::Function, x0::Vector{<:Real}; + max_iter::Integer=5000, tol_abs::Real=1e-10, tol_rel::Real=1e-8, epsilon::Real=1, + Δ0::Real=2, Δmax::Real=10, γ1::Real=0.5, γ2::Real=2, η1::Real=0.25, η2::Real=0.75, algo_pas::String="gct", + max_iter_gct::Integer = 2*length(x0)) - n = length(x0) - xmin = zeros(n) - fxmin = f(xmin) - flag = 0 + # + x_sol = x0 + f_sol = f(x_sol) + flag = -1 nb_iters = 0 + xs = [x0] # vous pouvez faire xs = vcat(xs, [xk]) pour concaténer les valeurs - return xmin, fxmin, flag, nb_iters + return x_sol, f_sol, flag, nb_iters, xs end diff --git a/src/algo_newton.ipynb b/src/algo_newton.ipynb deleted file mode 100644 index 452eabd42b868eecf594a75641c9f6e464ffa3e8..0000000000000000000000000000000000000000 --- a/src/algo_newton.ipynb +++ /dev/null @@ -1,152 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "<center>\n", - "<h1> TP-Projet d'optimisation numérique </h1>\n", - "<h1> Algorithme de Newton </h1>\n", - "</center>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Implémentation \n", - " \n", - "1. Coder l’algorithme de Newton local en respectant la spécification ci-dessous (fichier `Algorithme_De_Newton.jl`)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "using LinearAlgebra\n", - "using Documenter\n", - "using Markdown \n", - "include(\"Algorithme_De_Newton.jl\")\n", - "@doc Algorithme_De_Newton" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Vérifier que les tests ci-dessous passent." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "using Test\n", - "\n", - "# Tolérance pour les tests d'égalité\n", - "tol_erreur = sqrt(eps())\n", - "\n", - "## ajouter les fonctions de test\n", - "include(\"../test/fonctions_de_tests.jl\")\n", - "include(\"../test/tester_algo_newton.jl\")\n", - "include(\"../src/Algorithme_De_Newton.jl\")\n", - "\n", - "affiche = false # Mettre affiche = true pour afficher les résultats \n", - "\t\t\t\t# des appels à l'algorithme de Newton. Cela peut vous\n", - "\t\t\t\t# servir pour les réponses aux questions en fin de notebook.\n", - "\n", - "@testset \"Test algo newton\" begin\n", - "\t# Tester l'algorithme de Newton\n", - "\ttester_algo_newton(affiche,Algorithme_De_Newton)\n", - "end;" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#using Pkg; Pkg.add(\"LinearAlgebra\"); Pkg.add(\"Markdown\")\n", - "# using Documenter\n", - "using LinearAlgebra\n", - "using Markdown # Pour que les docstrings en début des fonctions ne posent\n", - " # pas de soucis. Ces docstrings sont utiles pour générer \n", - " # la documentation sous GitHub\n", - "include(\"Algorithme_De_Newton.jl\")\n", - "\n", - "# Affichage les sorties de l'algorithme des Régions de confiance\n", - "function my_afficher_resultats(algo,nom_fct,point_init,xmin,fxmin,flag,sol_exacte,nbiters)\n", - "\tprintln(\"-------------------------------------------------------------------------\")\n", - "\tprintstyled(\"Résultats de : \",algo, \" appliqué à \",nom_fct, \" au point initial \", point_init, \":\\n\",bold=true,color=:blue)\n", - "\tprintln(\" * xsol = \",xmin)\n", - "\tprintln(\" * f(xsol) = \",fxmin)\n", - "\tprintln(\" * nb_iters = \",nbiters)\n", - "\tprintln(\" * flag = \",flag)\n", - "\tprintln(\" * sol_exacte : \", sol_exacte)\n", - "end\n", - "\n", - "# Fonction f0\n", - "# -----------\n", - "f0(x) = sin(x)\n", - "# la gradient de la fonction f0\n", - "grad_f0(x) = cos(x)\n", - "# la hessienne de la fonction f0\n", - "hess_f0(x) = -sin(x)\n", - "sol_exacte = -pi/2\n", - "options = []\n", - "\n", - "x0 = sol_exacte\n", - "xmin,f_min,flag,nb_iters = Algorithme_De_Newton(f0,grad_f0,hess_f0,x0,options)\n", - "my_afficher_resultats(\"Newton\",\"f0\",x0,xmin,f_min,flag,sol_exacte,nb_iters)\n", - "x0 = -pi/2+0.5\n", - "xmin,f_min,flag,nb_iters = Algorithme_De_Newton(f0,grad_f0,hess_f0,x0,options)\n", - "my_afficher_resultats(\"Newton\",\"f0\",x0,xmin,f_min,flag,sol_exacte,nb_iters)\n", - "x0 = pi/2\n", - "xmin,f_min,flag,nb_iters = Algorithme_De_Newton(f0,grad_f0,hess_f0,x0,options)\n", - "my_afficher_resultats(\"Newton\",\"f0\",x0,xmin,f_min,flag,sol_exacte,nb_iters)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interprétation \n", - "\n", - "1. Justifier les résultats obtenus pour l'exemple $f_0$ ci-dessus;\n", - "\n", - "2. Soit \n", - "$$ f_{1} : \\mathbb{R}^3 \\rightarrow \\mathbb{R}$$ $$ (x_1,x_2, x_3) \\mapsto 2 (x_1 +x_2 + x_3 -3)^2 + (x_1-x_2)^2 + (x_2 - x_3)^2$$ \n", - "\n", - "Justifier que l’algorithme implémenté converge en une itération pour $f_{1}$;\n", - "\n", - "3. Soit \n", - "$$ f_{2} : \\mathbb{R}^2 \\rightarrow \\mathbb{R}$$ $$ (x_1,x_2) \\mapsto 100(x_2-x_1^2)^2 + (1-x_1)^2 $$ \n", - "\n", - "Justifier que l’algorithme puisse ne pas converger pour $f_{2}$ avec certains points initiaux.\n", - "\n", - "**Remarque.** Vous pouvez mettre `affiche=true` dans les tests de l'algorithme de Newton pour\n", - "vous aider.\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Julia 1.8.2", - "language": "julia", - "name": "julia-1.8" - }, - "language_info": { - "file_extension": ".jl", - "mimetype": "application/julia", - "name": "julia", - "version": "1.8.2" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/src/lagrangien_augmente.ipynb b/src/lagrangien_augmente.ipynb deleted file mode 100644 index a34e257e3b9470a5d08d7ae1aec8c3c34af47064..0000000000000000000000000000000000000000 --- a/src/lagrangien_augmente.ipynb +++ /dev/null @@ -1,586 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "<center>\n", - "<h1> TP-Projet d'optimisation numérique </h1>\n", - "<h1> Algorithme du Lagrangien Augmenté </h1>\n", - "</center>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Implémentation\n", - "\n", - "1. Implémenter l'algorithme du lagrangien augmenté, en utilisant les différentes méthodes\n", - "qui ont été vues en première partie pour la résolution de la suite de problémes sans\n", - "contraintes (fichier `Lagrangien_Augmente.jl`). La spécification de l'algorithme du Lagrangien augmenté est donnée ci-dessous.\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "\\paragraph{Objet}\n", - "Résolution des problèmes de minimisation avec une contrainte d'égalité scalaire par l'algorithme du lagrangien augmenté.\n", - "\n", - "\\paragraph{Syntaxe}\n", - "\\begin{verbatim}\n", - "xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options)\n", - "\\end{verbatim}\n", - "\\paragraph{Entrées}\n", - "\\begin{itemize}\n", - "\\item algo : (String) l'algorithme sans contraintes à utiliser:\n", - "\n", - "\\begin{itemize}\n", - "\\item \"newton\" : pour l'algorithme de Newton\n", - "\n", - "\n", - "\\item \"cauchy\" : pour le pas de Cauchy\n", - "\n", - "\n", - "\\item \"gct\" : pour le gradient conjugué tronqué\n", - "\n", - "\\end{itemize}\n", - "\n", - "\\item f : (Function) la fonction à minimiser\n", - "\n", - "\n", - "\\item gradf : (Function) le gradient de la fonction\n", - "\n", - "\n", - "\\item hessf : (Function) la hessienne de la fonction\n", - "\n", - "\n", - "\\item c : (Function) la contrainte [x est dans le domaine des contraintes ssi $c(x)=0$]\n", - "\n", - "\n", - "\\item gradc : (Function) le gradient de la contrainte\n", - "\n", - "\n", - "\\item hessc : (Function) la hessienne de la contrainte\n", - "\n", - "\n", - "\\item x0 : (Array\\{Float,1\\}) la première composante du point de départ du Lagrangien\n", - "\n", - "\n", - "\\item options : (Array\\{Float,1\\})\n", - "\n", - "\\begin{itemize}\n", - "\\item[1. ] epsilon : utilisé dans les critères d'arrêt\n", - "\n", - "\n", - "\\item[2. ] tol : la tolérance utilisée dans les critères d'arrêt\n", - "\n", - "\n", - "\\item[3. ] itermax : nombre maximal d'itération dans la boucle principale\n", - "\n", - "\n", - "\\item[4. ] lambda0 : la deuxième composante du point de départ du Lagrangien\n", - "\n", - "\n", - "\\item[5. ] mu0, tho : valeurs initiales des variables de l'algorithme\n", - "\n", - "\\end{itemize}\n", - "\\end{itemize}\n", - "\\paragraph{Sorties}\n", - "\\begin{itemize}\n", - "\\item xmin : (Array\\{Float,1\\}) une approximation de la solution du problème avec contraintes\n", - "\n", - "\n", - "\\item fxmin : (Float) $f(x_{min})$\n", - "\n", - "\n", - "\\item flag : (Integer) indicateur du déroulement de l'algorithme\n", - "\n", - "\\begin{itemize}\n", - "\\item 0 : convergence\n", - "\n", - "\n", - "\\item 1 : nombre maximal d'itération atteint\n", - "\n", - "\n", - "\\item (-1) : une erreur s'est produite\n", - "\n", - "\\end{itemize}\n", - "\n", - "\\item niters : (Integer) nombre d'itérations réalisées\n", - "\n", - "\n", - "\\item muks : (Array\\{Float64,1\\}) tableau des valeurs prises par mu\\_k au cours de l'exécution\n", - "\n", - "\n", - "\\item lambdaks : (Array\\{Float64,1\\}) tableau des valeurs prises par lambda\\_k au cours de l'exécution\n", - "\n", - "\\end{itemize}\n", - "\\paragraph{Exemple d'appel}\n", - "\\begin{verbatim}\n", - "using LinearAlgebra\n", - "algo = \"gct\" # ou newton|gct\n", - "f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2\n", - "gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)]\n", - "hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200]\n", - "c(x) = (x[1]^2) + (x[2]^2) -1.5\n", - "gradc(x) = [2*x[1] ;2*x[2]]\n", - "hessc(x) = [2 0;0 2]\n", - "x0 = [1; 0]\n", - "options = []\n", - "xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options)\n", - "\\end{verbatim}\n", - "\\paragraph{Tolérances des algorithmes appelés}\n", - "Pour les tolérances définies dans les algorithmes appelés (Newton et régions de confiance), prendre les tolérances par défaut définies dans ces algorithmes.\n", - "\n" - ], - "text/markdown": [ - "#### Objet\n", - "\n", - "Résolution des problèmes de minimisation avec une contrainte d'égalité scalaire par l'algorithme du lagrangien augmenté.\n", - "\n", - "#### Syntaxe\n", - "\n", - "```julia\n", - "xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options)\n", - "```\n", - "\n", - "#### Entrées\n", - "\n", - " * algo : (String) l'algorithme sans contraintes à utiliser:\n", - "\n", - " * \"newton\" : pour l'algorithme de Newton\n", - " * \"cauchy\" : pour le pas de Cauchy\n", - " * \"gct\" : pour le gradient conjugué tronqué\n", - " * f : (Function) la fonction à minimiser\n", - " * gradf : (Function) le gradient de la fonction\n", - " * hessf : (Function) la hessienne de la fonction\n", - " * c : (Function) la contrainte [x est dans le domaine des contraintes ssi $c(x)=0$]\n", - " * gradc : (Function) le gradient de la contrainte\n", - " * hessc : (Function) la hessienne de la contrainte\n", - " * x0 : (Array{Float,1}) la première composante du point de départ du Lagrangien\n", - " * options : (Array{Float,1})\n", - "\n", - " 1. epsilon : utilisé dans les critères d'arrêt\n", - " 2. tol : la tolérance utilisée dans les critères d'arrêt\n", - " 3. itermax : nombre maximal d'itération dans la boucle principale\n", - " 4. lambda0 : la deuxième composante du point de départ du Lagrangien\n", - " 5. mu0, tho : valeurs initiales des variables de l'algorithme\n", - "\n", - "#### Sorties\n", - "\n", - " * xmin : (Array{Float,1}) une approximation de la solution du problème avec contraintes\n", - " * fxmin : (Float) $f(x_{min})$\n", - " * flag : (Integer) indicateur du déroulement de l'algorithme\n", - "\n", - " * 0 : convergence\n", - " * 1 : nombre maximal d'itération atteint\n", - " * (-1) : une erreur s'est produite\n", - " * niters : (Integer) nombre d'itérations réalisées\n", - " * muks : (Array{Float64,1}) tableau des valeurs prises par mu_k au cours de l'exécution\n", - " * lambdaks : (Array{Float64,1}) tableau des valeurs prises par lambda_k au cours de l'exécution\n", - "\n", - "#### Exemple d'appel\n", - "\n", - "```julia\n", - "using LinearAlgebra\n", - "algo = \"gct\" # ou newton|gct\n", - "f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2\n", - "gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)]\n", - "hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200]\n", - "c(x) = (x[1]^2) + (x[2]^2) -1.5\n", - "gradc(x) = [2*x[1] ;2*x[2]]\n", - "hessc(x) = [2 0;0 2]\n", - "x0 = [1; 0]\n", - "options = []\n", - "xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options)\n", - "```\n", - "\n", - "#### Tolérances des algorithmes appelés\n", - "\n", - "Pour les tolérances définies dans les algorithmes appelés (Newton et régions de confiance), prendre les tolérances par défaut définies dans ces algorithmes.\n" - ], - "text/plain": [ - "\u001b[1m Objet\u001b[22m\n", - "\u001b[1m -------\u001b[22m\n", - "\n", - " Résolution des problèmes de minimisation avec une contrainte d'égalité\n", - " scalaire par l'algorithme du lagrangien augmenté.\n", - "\n", - "\u001b[1m Syntaxe\u001b[22m\n", - "\u001b[1m ---------\u001b[22m\n", - "\n", - "\u001b[36m xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options)\u001b[39m\n", - "\n", - "\u001b[1m Entrées\u001b[22m\n", - "\u001b[1m ---------\u001b[22m\n", - "\n", - " • algo : (String) l'algorithme sans contraintes à utiliser:\n", - " • \"newton\" : pour l'algorithme de Newton\n", - " • \"cauchy\" : pour le pas de Cauchy\n", - " • \"gct\" : pour le gradient conjugué tronqué\n", - "\n", - " • f : (Function) la fonction à minimiser\n", - "\n", - " • gradf : (Function) le gradient de la fonction\n", - "\n", - " • hessf : (Function) la hessienne de la fonction\n", - "\n", - " • c : (Function) la contrainte [x est dans le domaine des\n", - " contraintes ssi \u001b[35mc(x)=0\u001b[39m]\n", - "\n", - " • gradc : (Function) le gradient de la contrainte\n", - "\n", - " • hessc : (Function) la hessienne de la contrainte\n", - "\n", - " • x0 : (Array{Float,1}) la première composante du point de départ du\n", - " Lagrangien\n", - "\n", - " • options : (Array{Float,1})\n", - " 1. epsilon : utilisé dans les critères d'arrêt\n", - " 2. tol : la tolérance utilisée dans les critères d'arrêt\n", - " 3. itermax : nombre maximal d'itération dans la boucle\n", - " principale\n", - " 4. lambda0 : la deuxième composante du point de départ du\n", - " Lagrangien\n", - " 5. mu0, tho : valeurs initiales des variables de\n", - " l'algorithme\n", - "\n", - "\u001b[1m Sorties\u001b[22m\n", - "\u001b[1m ---------\u001b[22m\n", - "\n", - " • xmin : (Array{Float,1}) une approximation de la solution du\n", - " problème avec contraintes\n", - "\n", - " • fxmin : (Float) \u001b[35mf(x_{min})\u001b[39m\n", - "\n", - " • flag : (Integer) indicateur du déroulement de l'algorithme\n", - " • 0 : convergence\n", - " • 1 : nombre maximal d'itération atteint\n", - " • (-1) : une erreur s'est produite\n", - "\n", - " • niters : (Integer) nombre d'itérations réalisées\n", - "\n", - " • muks : (Array{Float64,1}) tableau des valeurs prises par mu_k au\n", - " cours de l'exécution\n", - "\n", - " • lambdaks : (Array{Float64,1}) tableau des valeurs prises par\n", - " lambda_k au cours de l'exécution\n", - "\n", - "\u001b[1m Exemple d'appel\u001b[22m\n", - "\u001b[1m -----------------\u001b[22m\n", - "\n", - "\u001b[36m using LinearAlgebra\u001b[39m\n", - "\u001b[36m algo = \"gct\" # ou newton|gct\u001b[39m\n", - "\u001b[36m f(x)=100*(x[2]-x[1]^2)^2+(1-x[1])^2\u001b[39m\n", - "\u001b[36m gradf(x)=[-400*x[1]*(x[2]-x[1]^2)-2*(1-x[1]) ; 200*(x[2]-x[1]^2)]\u001b[39m\n", - "\u001b[36m hessf(x)=[-400*(x[2]-3*x[1]^2)+2 -400*x[1];-400*x[1] 200]\u001b[39m\n", - "\u001b[36m c(x) = (x[1]^2) + (x[2]^2) -1.5\u001b[39m\n", - "\u001b[36m gradc(x) = [2*x[1] ;2*x[2]]\u001b[39m\n", - "\u001b[36m hessc(x) = [2 0;0 2]\u001b[39m\n", - "\u001b[36m x0 = [1; 0]\u001b[39m\n", - "\u001b[36m options = []\u001b[39m\n", - "\u001b[36m xmin,fxmin,flag,iter,muks,lambdaks = Lagrangien_Augmente(algo,f,gradf,hessf,c,gradc,hessc,x0,options)\u001b[39m\n", - "\n", - "\u001b[1m Tolérances des algorithmes appelés\u001b[22m\n", - "\u001b[1m ------------------------------------\u001b[22m\n", - "\n", - " Pour les tolérances définies dans les algorithmes appelés (Newton et régions\n", - " de confiance), prendre les tolérances par défaut définies dans ces\n", - " algorithmes." - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "using LinearAlgebra\n", - "using Documenter\n", - "using Markdown \n", - "include(\"Lagrangien_Augmente.jl\")\n", - "@doc Lagrangien_Augmente" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Vérifier que les tests ci-dessous passent." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Avec newton: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:42\u001b[22m\n", - " Expression: isapprox(xmin, sol_fct1_augm, atol = tol_erreur)\n", - " Evaluated: isapprox([0.0, 0.0, 0.0], [0.5, 1.25, 0.5]; atol = 0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:42\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec newton: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:50\u001b[22m\n", - " Expression: ≈(xmin, sol_fct1_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0, 0.0] ≈ [0.5, 1.25, 0.5] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:50\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec newton: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:58\u001b[22m\n", - " Expression: ≈(xmin, sol_fct2_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0] ≈ [0.9072339605110892, 0.82275545631455] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:58\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec newton: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:66\u001b[22m\n", - " Expression: ≈(xmin, sol_fct2_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0] ≈ [0.9072339605110892, 0.82275545631455] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:66\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec gct: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:42\u001b[22m\n", - " Expression: isapprox(xmin, sol_fct1_augm, atol = tol_erreur)\n", - " Evaluated: isapprox([0.0, 0.0, 0.0], [0.5, 1.25, 0.5]; atol = 0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:42\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec gct: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:50\u001b[22m\n", - " Expression: ≈(xmin, sol_fct1_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0, 0.0] ≈ [0.5, 1.25, 0.5] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:50\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec gct: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:58\u001b[22m\n", - " Expression: ≈(xmin, sol_fct2_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0] ≈ [0.9072339605110892, 0.82275545631455] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:58\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec gct: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:66\u001b[22m\n", - " Expression: ≈(xmin, sol_fct2_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0] ≈ [0.9072339605110892, 0.82275545631455] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:66\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec cauchy: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:42\u001b[22m\n", - " Expression: isapprox(xmin, sol_fct1_augm, atol = tol_erreur)\n", - " Evaluated: isapprox([0.0, 0.0, 0.0], [0.5, 1.25, 0.5]; atol = 0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:42\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec cauchy: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:50\u001b[22m\n", - " Expression: ≈(xmin, sol_fct1_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0, 0.0] ≈ [0.5, 1.25, 0.5] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:50\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec cauchy: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:58\u001b[22m\n", - " Expression: ≈(xmin, sol_fct2_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0] ≈ [0.9072339605110892, 0.82275545631455] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:58\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "Avec cauchy: \u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1m/Users/gergaud/git-ENS/optimisation-numerique/projet-optinum/test/tester_lagrangien_augmente.jl:66\u001b[22m\n", - " Expression: ≈(xmin, sol_fct2_augm, atol = tol_erreur)\n", - " Evaluated: [0.0, 0.0] ≈ [0.9072339605110892, 0.82275545631455] (atol=0.0001)\n", - "Stacktrace:\n", - " [1] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:66\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [2] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1226\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [3] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [4] \u001b[0m\u001b[1mmacro expansion\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[90m/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/\u001b[39m\u001b[90;4mTest.jl:1151\u001b[0m\u001b[90m [inlined]\u001b[39m\n", - " [5] \u001b[0m\u001b[1mtester_lagrangien_augmente\u001b[22m\u001b[0m\u001b[1m(\u001b[22m\u001b[90mafficher\u001b[39m::\u001b[0mBool, \u001b[90mLagrangien_Augmente\u001b[39m::\u001b[0mtypeof(Lagrangien_Augmente)\u001b[0m\u001b[1m)\u001b[22m\n", - "\u001b[90m @ \u001b[39m\u001b[35mMain\u001b[39m \u001b[90m~/git-ENS/optimisation-numerique/projet-optinum/test/\u001b[39m\u001b[90;4mtester_lagrangien_augmente.jl:35\u001b[0m\n", - "\u001b[0m\u001b[1mTest Summary: | \u001b[22m\u001b[91m\u001b[1mFail \u001b[22m\u001b[39m\u001b[36m\u001b[1mTotal\u001b[22m\u001b[39m\n", - "Test lagrangien augmente | \u001b[91m 12 \u001b[39m\u001b[36m 12\u001b[39m\n", - " Lagrangien augmenté | \u001b[91m 12 \u001b[39m\u001b[36m 12\u001b[39m\n", - " Avec newton | \u001b[91m 4 \u001b[39m\u001b[36m 4\u001b[39m\n", - " Avec gct | \u001b[91m 4 \u001b[39m\u001b[36m 4\u001b[39m\n", - " Avec cauchy | \u001b[91m 4 \u001b[39m\u001b[36m 4\u001b[39m\n" - ] - }, - { - "ename": "LoadError", - "evalue": "\u001b[91mSome tests did not pass: 0 passed, 12 failed, 0 errored, 0 broken.\u001b[39m", - "output_type": "error", - "traceback": [ - "\u001b[91mSome tests did not pass: 0 passed, 12 failed, 0 errored, 0 broken.\u001b[39m", - "", - "Stacktrace:", - " [1] finish(ts::Test.DefaultTestSet)", - " @ Test /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:913", - " [2] macro expansion", - " @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1161 [inlined]", - " [3] top-level scope", - " @ In[6]:18", - " [4] eval", - " @ ./boot.jl:360 [inlined]", - " [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)", - " @ Base ./loading.jl:1116" - ] - } - ], - "source": [ - "using Test\n", - "\n", - "# Tolérance pour les tests d'égalité\n", - "tol_erreur = sqrt(eps())\n", - "\n", - "## ajouter les fonctions de test\n", - "include(\"../test/fonctions_de_tests.jl\")\n", - "include(\"../test/tester_lagrangien_augmente.jl\")\n", - "include(\"../src/Algorithme_De_Newton.jl\")\n", - "include(\"../src/Pas_De_Cauchy.jl\")\n", - "include(\"../src/Gradient_Conjugue_Tronque.jl\")\n", - "include(\"../src/Regions_De_Confiance.jl\")\n", - "include(\"../src/Lagrangien_Augmente.jl\")\n", - "\n", - "affiche = false\n", - "\n", - "@testset \"Test lagrangien augmente\" begin\n", - "\ttester_lagrangien_augmente(affiche, Lagrangien_Augmente)\n", - "end;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interprétation\n", - "\n", - " 1. Commenter les résultats obtenus, en étudiant notamment les valeurs de $\\lambda_k$ et $\\mu_k$.\n", - " \n", - " 2. Étudier l'influence du paramètre $\\tau$ dans la performance de l'algorithme. Pour cela Vous réaliserez des tests numériques.\n", - " \n", - " 3. **Supplémentaire** : \n", - " Que proposez-vous comme méthode pour la résolution des problèmes avec\n", - " des contraintes à la fois d'égalité et d'inégalité ? Implémenter (si le temps le permet)\n", - " ce nouvel algorithme." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Julia 1.6.6", - "language": "julia", - "name": "julia-1.6" - }, - "language_info": { - "file_extension": ".jl", - "mimetype": "application/julia", - "name": "julia", - "version": "1.6.6" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/src/regions_confiance.ipynb b/src/regions_confiance.ipynb deleted file mode 100644 index f87e1b2f096c0ae9fe5bb4996baa534c7ce73297..0000000000000000000000000000000000000000 --- a/src/regions_confiance.ipynb +++ /dev/null @@ -1,262 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "<center>\n", - "<h1> TP-Projet d'optimisation numérique </h1>\n", - "<h1> Algorithme des Régions de Confiance </h1>\n", - "</center>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Régions de confiance avec Pas de Cauchy \n", - "\n", - "## Implémentation \n", - "\n", - "1. Coder l'algorithme du pas de Cauchy d’un sous-problème de\n", - "régions de confiance (fichier `Pas_De_Cauchy.jl`). La spécification de cet algorithme est donnée ci-dessous." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Pas_De_Cauchy" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "using LinearAlgebra\n", - "using Documenter\n", - "using Markdown \n", - "include(\"Pas_De_Cauchy.jl\")\n", - "# @doc Pas_De_Cauchy" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Ecrire des tests exhaustifs (qui testent tous les cas de figure possibles) pour votre algorithme du Pas de Cauchy. Vous créerez pour cela un fichier `tester_pas_de_Cauchy.jl` dans le répertoire `test` sur le modèle des autres fichiers de tests et vous exécuterez dans la cellule de code ci-après ces tests." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Coder l'algorithme des Régions de Confiance (fichier `Regions_De_Confiance.jl`). Sa spécification est donnée ci-dessous." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "include(\"Regions_De_Confiance.jl\")\n", - "# @doc Regions_De_Confiance" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. Vérifier que les tests ci-dessous passent." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "using Test\n", - "\n", - "# Tolérance pour les tests d'égalité\n", - "tol_erreur = sqrt(eps())\n", - "\n", - "## ajouter les fonctions de test\n", - "include(\"../test/fonctions_de_tests.jl\")\n", - "include(\"../test/tester_regions_de_confiance.jl\")\n", - "include(\"../src/Pas_De_Cauchy.jl\")\n", - "include(\"../src/Regions_De_Confiance.jl\")\n", - "\n", - "affiche = false\n", - "\n", - "@testset \"Test rc avec cauchy\" begin\n", - "\ttester_regions_de_confiance(affiche,Regions_De_Confiance)\n", - "end;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interprétation \n", - "\n", - "<!-- Pour ces questions, des représentations graphiques sont attendues pour corroborer vos réponses. -->\n", - "\n", - "1. Soit $$ f_{1} : \\mathbf{R}^3 \\rightarrow \\mathbf{R}$$ $$ (x_1,x_2, x_3) \\mapsto 2 (x_1 +x_2 + x_3 -3)^2 + (x_1-x_2)^2 + (x_2 - x_3)^2$$ Quelle relation lie la fonction $f_1$ et son modèle de Taylor à l’ordre 2 ? Comparer alors les performances de Newton et RC-Pas de Cauchy sur cette fonction.\n", - "\n", - "2. Le rayon initial de la région de confiance est un paramètre important dans l’analyse\n", - "de la performance de l’algorithme. Sur quel(s) autre(s) paramètre(s) peut-on jouer\n", - "pour essayer d’améliorer cette performance ? Étudier l’influence d’au moins deux de\n", - "ces paramètres. Pour cela vous ferez des tests numériques et donnerez les résultats sous forme de tableaux et de graphiques." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Régions de confiance avec Gradient Conjugué\n", - "## Implémentation \n", - "\n", - "1. Implémenter l’algorithme du Gradient Conjugué Tronqué (fichier `Gradient_Conjugue_Tronque.jl`). Sa spécification est donnée ci-dessous." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "include(\"Gradient_Conjugue_Tronque.jl\")\n", - "# @doc Gradient_Conjugue_Tronque" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Vérifier que les tests ci-dessous passent." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "using Test\n", - "\n", - "# Tolérance pour les tests d'égalité\n", - "tol_erreur = sqrt(eps())\n", - "\n", - "## ajouter les fonctions de test\n", - "include(\"../test/fonctions_de_tests.jl\")\n", - "include(\"../test/tester_gct.jl\")\n", - "include(\"../src/Gradient_Conjugue_Tronque.jl\")\n", - "\n", - "affiche = false\n", - "\n", - "@testset \"Test gct\" begin\n", - "\ttester_gct(affiche,Gradient_Conjugue_Tronque)\n", - "end;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Intégrer l’algorithme du Gradient Conjugué Tronqué dans le code de régions de confiance (fichier `Regions_De_Confiance.jl`).\n", - "\n", - "4. Décommenter les tests avec le gradient conjugué dans `tester_regions_de_confiance.jl` et vérifier que les tests passent." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "using Test\n", - "\n", - "# Tolérance pour les tests d'égalité\n", - "tol_erreur = sqrt(eps())\n", - "\n", - "## ajouter les fonctions de test\n", - "include(\"../test/fonctions_de_tests.jl\")\n", - "include(\"../test/tester_regions_de_confiance.jl\")\n", - "include(\"../src/Pas_De_Cauchy.jl\")\n", - "include(\"../src/Gradient_Conjugue_Tronque.jl\")\n", - "include(\"../src/Regions_De_Confiance.jl\")\n", - "\n", - "affiche = false\n", - "\n", - "@testset \"Test rc avec cauchy et gct\" begin\n", - "\ttester_regions_de_confiance(affiche,Regions_De_Confiance)\n", - "end;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interprétation \n", - "\n", - "1. Comparer la décroissance obtenue avec celle du pas de Cauchy, en imposant la sortie\n", - "dans l’algorithme au bout d’une itération seulement. Vous donnerez ci-après des résultats numériques. \n", - " 1. Que remarquez vous ?\n", - " 2. Comparer la décroissance obtenue avec celle du pas de Cauchy dans le cas général.\n", - "\n", - "3. Quels sont les avantages et inconvénients des deux approches ?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Julia 1.6.6", - "language": "julia", - "name": "julia-1.6" - }, - "language_info": { - "file_extension": ".jl", - "mimetype": "application/julia", - "name": "julia", - "version": "1.6.6" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/test/cacher_stacktrace.jl b/test/cacher_stacktrace.jl deleted file mode 100755 index 658bc0576db1cc935896efa2685bbebdde640506..0000000000000000000000000000000000000000 --- a/test/cacher_stacktrace.jl +++ /dev/null @@ -1,24 +0,0 @@ -using Test -@doc doc""" - -Cacher les traces d'appels des tests erronés ou échoués, pour les remettre, décommentez les lignes 11 et 16. - -""" -function cacher_stacktrace() - Test.eval(quote - function record(ts::DefaultTestSet, t::Union{Fail, Error}) - if myid() == 1 - #printstyled(ts.description, ": ", color=:white) # afficher la description du testset - # ne pas afficher pour les tests interrompus - if !(t isa Error) || t.test_type != :test_interrupted - # print(t) # afficher le resultat et la solution attendu - if !isa(t, Error) - # Base.show_backtrace(stdout, scrub_backtrace(backtrace())) # afficher la trace d'appels - end - end - end - push!(ts.results, t) - t, isa(t, Error) || backtrace() - end - end) -end diff --git a/test/fonctions_de_tests.jl b/test/fonctions_de_tests.jl index d568f43cd1e1282d9c68ff2a6c7eef8cff6b864f..c9b96df6a14eb22b3c393699f7ed34973d3345d6 100755 --- a/test/fonctions_de_tests.jl +++ b/test/fonctions_de_tests.jl @@ -1,8 +1,8 @@ """ Ce fichier contient toutes fonctions utilisés dans les tests des algorithmes : - - L'algorithme de Newton - - Les régions de confiance - - Le Lagrangien augmenté + - L'algorithme de Newton + - Les régions de confiance + - Le Lagrangien augmenté """ # Les points initiaux @@ -97,12 +97,13 @@ grad_contrainte2(x) = [2*x[1] ;2*x[2]] hess_contrainte2(x) = [2 0;0 2] # Affichage les sorties de l'algorithme des Régions de confiance -function afficher_resultats(algo,nom_fct,point_init,xmin,fxmin,flag,sol_exacte,nbiters) - println("-------------------------------------------------------------------------") - printstyled("Résultats de : "*algo*" appliqué à "*nom_fct*" au point initial "*point_init*" :\n",bold=true,color=:blue) - println(" * xsol = ",xmin) - println(" * f(xsol) = ",fxmin) - println(" * nb_iters = ",nbiters) - println(" * flag = ",flag) - println(" * sol_exacte : ", sol_exacte) +function afficher_resultats(algo, nom_fct, x0, x_sol, f_sol, flag, nbiters, solution) + println("-------------------------------------------------------------------------") + printstyled("Résultats de : ",algo, " appliqué à ", nom_fct, ":\n", bold=true, color=:blue) + println(" * x0 = ", x0) + println(" * x_sol = ", x_sol) + println(" * f(x_sol) = ", f_sol) + println(" * nb_iters = ", nbiters) + println(" * flag = ", flag) + println(" * solution = ", solution) end diff --git a/test/new_runtests.jl b/test/new_runtests.jl deleted file mode 100644 index 433737b8990ca22747649e8e3c838f6abf6e276c..0000000000000000000000000000000000000000 --- a/test/new_runtests.jl +++ /dev/null @@ -1,49 +0,0 @@ -using Markdown -using Test -using LinearAlgebra - -include("../src/Algorithme_De_Newton.jl") -include("../src/Gradient_Conjugue_Tronque.jl") -include("../src/Lagrangien_Augmente.jl") -include("../src/Pas_De_Cauchy.jl")# -include("../src/Regions_De_Confiance.jl") - -#include("cacher_stacktrace.jl") -#cacher_stacktrace() - - -# Tolérance pour les tests d'égalité -tol_erreur = sqrt(eps()) - -## ajouter les fonctions de test -include("./fonctions_de_tests.jl") - -include("./tester_algo_newton.jl") - -include("tester_pas_de_cauchy.jl") -# -include("tester_gct.jl") - -include("tester_regions_de_confiance.jl") - -include("tester_lagrangien_augmente.jl") - -affiche = true -println("affiche = ",affiche) -# Tester l'ensemble des algorithmes -@testset "Test SujetOptinum" begin - # Tester l'algorithme de Newton - tester_algo_newton(affiche,Algorithme_De_Newton) - - # Tester l'algorithme du pas de Cauchy - tester_pas_de_cauchy(affiche,Pas_De_Cauchy) - - # Tester l'algorithme du gradient conjugué tronqué - tester_gct(affiche,Gradient_Conjugue_Tronque) - - # Tester l'algorithme des Régions de confiance avec PasdeCauchy | GCT - tester_regions_de_confiance(affiche,Regions_De_Confiance) - - # Tester l'algorithme du Lagrangien Augmenté - tester_lagrangien_augmente(affiche,Lagrangien_Augmente) -end diff --git a/test/tester_algo_newton.jl b/test/tester_algo_newton.jl deleted file mode 100755 index fdaa7244349b7016a471f266f43dee15f471281b..0000000000000000000000000000000000000000 --- a/test/tester_algo_newton.jl +++ /dev/null @@ -1,133 +0,0 @@ -@doc doc""" -Tester l'algorithme de Newton local - -# Entrées : - * afficher : (Bool) affichage ou non des résultats de chaque test - -# Les cas de test (dans l'ordre) - * fct 1 : x011, x012 - * fct 2 : x021, x022, x023 -""" -function tester_algo_newton(afficher::Bool, Algorithme_De_Newton::Function) - max_iter = 100 - Tol_abs = sqrt(eps()) - Tol_rel = 1e-15 - epsilon = 1.0 - options = [max_iter, Tol_abs, Tol_rel, epsilon] - @testset "L'algo de Newton" begin - @testset "Cas test 1 x0 = solution" begin - # point de départ x011 - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct1, grad_fct1, hess_fct1, sol_exacte_fct1, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct1", "x011", x_min, fx_min, flag, sol_exacte_fct1, nb_iters) - end - @testset "solution" begin - @test isapprox(x_min, sol_exacte_fct1, atol=tol_erreur) - end - @testset "itération" begin - @test nb_iters == 0 - end - @testset "flag" begin - @test flag == 0 - end - end - @testset "Cas test 1 x0 = x011" begin - #point de départ x011 - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct1, grad_fct1, hess_fct1, pts1.x011, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct1", "x011", x_min, fx_min, flag, sol_exacte_fct1, nb_iters) - end - @testset "solution" begin - @test isapprox(x_min, sol_exacte_fct1, atol=tol_erreur) - end - @testset "itération" begin - @test nb_iters == 1 - end - @testset "flag" begin - @test flag == 0 - end - end - @testset "Cas test 1 x0 = x012" begin - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct1, grad_fct1, hess_fct1, pts1.x012, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct1", "x012", x_min, fx_min, flag, sol_exacte_fct1, nb_iters) - end - @testset "solution" begin - @test x_min ≈ sol_exacte_fct1 atol = tol_erreur - end - @testset "itération" begin - @test nb_iters == 1 - end - @testset "flag" begin - @test flag == 0 - end - end - @testset "Cas test 2 x0 = solution" begin - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct1, grad_fct1, hess_fct1, sol_exacte_fct1, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct1", "x011", x_min, fx_min, flag, sol_exacte_fct1, nb_iters) - end - @testset "solution" begin - @test isapprox(x_min, sol_exacte_fct1, atol=tol_erreur) - end - @testset "itération" begin - @test nb_iters == 0 - end - @testset "flag" begin - @test flag == 0 - end - end - @testset "Cas test 2 x0 = x021" begin - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct2, grad_fct2, hess_fct2, pts1.x021, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct2", "x021", x_min, fx_min, flag, sol_exacte_fct2, nb_iters) - end - @testset "solution" begin - @test x_min ≈ sol_exacte_fct2 atol = tol_erreur - end - @testset "itération" begin - @test nb_iters == 6 - end - @testset "flag" begin - @test flag == 0 - end - end - @testset "Cas test 2 x0 = x022" begin - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct2, grad_fct2, hess_fct2, pts1.x022, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct2", "x022", x_min, fx_min, flag, sol_exacte_fct2, nb_iters) - end - @testset "solution" begin - @test x_min ≈ sol_exacte_fct2 atol = tol_erreur - end - @testset "itération" begin - @test nb_iters == 5 - end - @testset "flag" begin - @test flag == 0 - end - end - - @testset "Cas test 2 x0 = x023" begin - options[1] = 1 - sol = [-4.99999958629818e9, 8.673617379884035e-19] - x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct2, grad_fct2, hess_fct2, pts1.x023, options) - if (afficher) - afficher_resultats("algorithme de Newton ", "fct2", "x023", x_min, fx_min, flag, sol_exacte_fct2, nb_iters) - end - @testset "solution" begin - @test x_min ≈ sol atol = tol_erreur - end - @testset "flag" begin - @test flag == 3 - end - @testset "itération" begin - @test nb_iters == 1 - end - @testset "exception" begin - options[1] = 100 - @test_throws SingularException x_min, fx_min, flag, nb_iters = Algorithme_De_Newton(fct2, grad_fct2, hess_fct2, pts1.x023, options) - end - end - end -end diff --git a/test/tester_gct.jl b/test/tester_gct.jl index 5549a89285635fa13ca6971b685c203022761367..ea76a6a15264088db356616414bea66024df37c7 100755 --- a/test/tester_gct.jl +++ b/test/tester_gct.jl @@ -1,87 +1,72 @@ -@doc doc""" -Tester l'algorithme du gradient conjugué tronqué +using Test -# Entrées : - * afficher : (Bool) affichage ou non des résultats de chaque test +""" +Tester l'algorithme du gient conjugué tronqué # Les cas de test (dans l'ordre) - * la quadratique 1 - * la quadratique 2 - * la quadratique 3 - * la quadratique 4 - * la quadratique 5 - * la quadratique 6 + + - la quadratique 1 + - la quadratique 2 + - la quadratique 3 + - la quadratique 4 + - la quadratique 5 + - la quadratique 6 + """ -function tester_gct(afficher::Bool,Gradient_Conjugue_Tronque::Function) +function tester_gct(gct::Function) - tol = 1e-7 - max_iter = 100 # Tolérance utilisé dans les tests tol_test = 1e-3 - @testset "Gradient-CT" begin + @testset "Gradient conjugué tronqué" begin # le cas de test 1 - grad = [0 ; 0] - Hess = [7 0 ; 0 2] - delta = 1 - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) + g = [0 ; 0] + H = [7 0 ; 0 2] + Δ = 1 + s = gct(g,H,Δ) @test s ≈ [0.0 ; 0.0] atol = tol_test # le cas de test 2 H definie positive - grad = [6 ; 2] - Hess = [7 0 ; 0 2] - delta = 0.5 # sol = pas de Cauchy - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) - @test s ≈ -delta*grad/norm(grad) atol = tol_test - delta = 1.2 # saturation à la 2ieme itération - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) + g = [6 ; 2] + H = [7 0 ; 0 2] + Δ = 0.5 # sol = pas de Cauchy + s = gct(g,H,Δ) + @test s ≈ -Δ*g/norm(g) atol = tol_test + Δ = 1.2 # saturation à la 2ieme itération + s = gct(g,H,Δ) @test s ≈ [-0.8740776099190263, -0.8221850958502244] atol = tol_test - delta = 3 # sol = min global - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) - @test s ≈ -Hess\grad atol = tol_test + Δ = 3 # sol = min global + s = gct(g,H,Δ) + @test s ≈ -H\g atol = tol_test # le cas test 2 bis matrice avec 1 vp < 0 et 1 vp > 0 - grad = [1,2] - Hess = [1 0 ; 0 -1] - delta = 1. # g^T H g < 0 première direction concave - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) - @test s ≈ -delta*grad/norm(grad) atol = tol_test - grad = [1,0] - delta = 0.5 # g^T H g > 0 sol pas de Cauchy - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) - @test s ≈ -delta*grad/norm(grad) atol = tol_test - grad = [2,1] # g^T H g > 0 sol à l'itération 2, saturation - delta = 6 - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) + g = [1,2] + H = [1 0 ; 0 -1] + Δ = 1. # g^T H g < 0 première direction concave + s = gct(g,H,Δ) + @test s ≈ -Δ*g/norm(g) atol = tol_test + g = [1,0] + Δ = 0.5 # g^T H g > 0 sol pas de Cauchy + s = gct(g,H,Δ) + @test s ≈ -Δ*g/norm(g) atol = tol_test + g = [2,1] # g^T H g > 0 sol à l'itération 2, saturation + Δ = 6 + s = gct(g,H,Δ) @test isapprox(s, [0.48997991959774634, 5.979959839195494], atol = tol_test) || isapprox(s, [-4.489979919597747, -3.979959839195493], atol = tol_test) - - # le cas de test 3 - #grad = [-2 ; 1] - #Hess = [-2 0 ; 0 10] - #delta = 10 - #s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) - #@test s ≈ [9.102342582478453; -4.140937032991381] atol = tol_test - - # le cas de test 4 - #grad = [0 ; 0] - #Hess = [-2 0 ; 0 10] - #delta = 1 - #s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) - #@test s ≈ [0.0 ; 0.0] atol = tol_test # le cas de test 5 - grad = [2 ; 3] - Hess = [4 6 ; 6 5] - delta = 3 - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) + g = [2 ; 3] + H = [4 6 ; 6 5] + Δ = 3 + s = gct(g,H,Δ) @test s ≈ [1.9059020876695578 ; -2.3167946029410595] atol = tol_test # le cas de test 6 - # Le pas de Cauchy conduit à un gradient nul en 1 itération - grad = [2 ; 0] - Hess = [4 0 ; 0 -15] - delta = 2 - s = Gradient_Conjugue_Tronque(grad,Hess,[delta;max_iter;tol]) + # Le pas de Cauchy conduit à un gient nul en 1 itération + g = [2 ; 0] + H = [4 0 ; 0 -15] + Δ = 2 + s = gct(g,H,Δ) @test s ≈ [-0.5 ; 0.0] atol = tol_test end end diff --git a/test/tester_lagrangien_augmente.jl b/test/tester_lagrangien_augmente.jl index ea6cf50b880a4461fb9c0fb903d91ac55929b887..30db9d2aa809635dc4a83683c5dd612b6dddd8e3 100755 --- a/test/tester_lagrangien_augmente.jl +++ b/test/tester_lagrangien_augmente.jl @@ -1,69 +1,85 @@ -@doc doc""" -Tester l'algorithme du Lagrangien augmenté +using Test +include("../test/fonctions_de_tests.jl") -# Entrées : - * affichage : (Bool) affichage ou non des résultats de chaque test +""" +Tester l'algorithme du lagrangien augmenté + +# Entrées + + - afficher : (Bool) affichage ou non des résultats de chaque test # Les cas de test (dans l'ordre) - * Newton - * fct1 : x01, x02 - * fct2 : x03, x04 - * gct - * fct1 : x01, x02 - * fct2 : x03, x04 - * Cauchy - * fct1 : x01, x02 - * fct2 : x03, x04 + + - Newton + • fct1 : x01, x02 + • fct2 : x03, x04 + - gct + • fct1 : x01, x02 + • fct2 : x03, x04 + - Cauchy + • fct1 : x01, x02 + • fct2 : x03, x04 + """ -function tester_lagrangien_augmente(afficher::Bool,Lagrangien_Augmente::Function) +function tester_lagrangien_augmente(LA::Function, afficher::Bool) + + println("Affichage des résultats des algorithmes : ", afficher, "\n") - # initialisation des paramètres - lambda0 = 2 - mu0 = 10 - tho = 2 - epsilon = 1. - tol = 1e-5 - max_iters = 1000 - options = [epsilon, tol, max_iters, lambda0, mu0, tho] # La tolérance utilisée dans les tests tol_erreur = 1e-4 + + # initialisation des paramètres + tol = 1e-5 # tol_abs et tol_rel # Les trois algorithmes d'optimisations sans contraintes utlisés - algos = ["newton", "gct", "cauchy"] + algos = ["newton", "rc-cauchy", "rc-gct"] + + # + f1 = fct1; gf1 = grad_fct1; Hf1 = hess_fct1; c1 = contrainte1; gc1 = grad_contrainte1; Hc1 = hess_contrainte1 + f2 = fct2; gf2 = grad_fct2; Hf2 = hess_fct2; c2 = contrainte2; gc2 = grad_contrainte2; Hc2 = hess_contrainte2 + x01 = pts2.x01 + x02 = pts2.x02 + x03 = pts2.x03 + x04 = pts2.x04 + + @testset "Lagrangien augmenté " begin + + @testset "Avec $algo" for algo in algos - @testset "Lagrangien augmenté " begin - @testset "Avec $algo" for algo in algos # le cas de test 1 - xmin,fxmin,flag,nbiters = Lagrangien_Augmente(algo,fct1,contrainte1,grad_fct1,hess_fct1,grad_contrainte1, - hess_contrainte1,pts2.x01,options) + x0 = x01 + x_sol, f_sol, flag, nb_iters, _ = LA(f1, gf1, Hf1, c1, gc1, Hc1, x0, tol_abs=tol, tol_rel=tol, algo_noc=algo) if (afficher) - afficher_resultats("Lagrangien augmenté avec "*algo,"fonction 1","x01",xmin,fxmin,flag,sol_fct1_augm,nbiters) + afficher_resultats("LA et " * algo, "f1", x0, x_sol, f_sol, flag, nb_iters, sol_fct1_augm) end - @test isapprox(xmin,sol_fct1_augm ,atol=tol_erreur) + @test x_sol ≈ sol_fct1_augm atol=tol_erreur # le cas de test 2 - xmin ,fxmin,flag,nbiters = Lagrangien_Augmente(algo,fct1,contrainte1,grad_fct1,hess_fct1,grad_contrainte1, - hess_contrainte1,pts2.x02,options) + x0 = x02 + x_sol, f_sol, flag, nb_iters, _ = LA(f1, gf1, Hf1, c1, gc1, Hc1, x0, tol_abs=tol, tol_rel=tol, algo_noc=algo) if (afficher) - afficher_resultats("Lagrangien augmenté avec "*algo,"fonction 1","x02",xmin,fxmin,flag,sol_fct1_augm,nbiters) + afficher_resultats("LA et " * algo, "f1", x0, x_sol, f_sol, flag, nb_iters, sol_fct1_augm) end - @test xmin ≈ sol_fct1_augm atol=tol_erreur + @test x_sol ≈ sol_fct1_augm atol=tol_erreur # le cas de test 3 - xmin,fxmin,flag,nbiters = Lagrangien_Augmente(algo,fct2,contrainte2,grad_fct2,hess_fct2,grad_contrainte2, - hess_contrainte2,pts2.x03,options) + x0 = x03 + x_sol, f_sol, flag, nb_iters, _ = LA(f2, gf2, Hf2, c2, gc2, Hc2, x0, tol_abs=tol, tol_rel=tol, algo_noc=algo) if (afficher) - afficher_resultats("Lagrangien augmenté avec "*algo,"fonction 2","x03",xmin,fxmin,flag,sol_fct2_augm,nbiters) + afficher_resultats("LA et " * algo, "f2", x0, x_sol, f_sol, flag, nb_iters, sol_fct2_augm) end - @test xmin ≈ sol_fct2_augm atol=tol_erreur + @test x_sol ≈ sol_fct2_augm atol=tol_erreur # le cas de test 4 - xmin ,fxmin,flag,nbiters = Lagrangien_Augmente(algo,fct2,contrainte2,grad_fct2,hess_fct2,grad_contrainte2, - hess_contrainte2,pts2.x04,options) + x0 = x04 + x_sol, f_sol, flag, nb_iters, _ = LA(f2, gf2, Hf2, c2, gc2, Hc2, x0, tol_abs=tol, tol_rel=tol, algo_noc=algo) if (afficher) - afficher_resultats("Lagrangien augmenté avec "*algo,"fonction 2","x04",xmin,fxmin,flag,sol_fct2_augm,nbiters) + afficher_resultats("LA et " * algo, "f2", x0, x_sol, f_sol, flag, nb_iters, sol_fct2_augm) end - @test xmin ≈ sol_fct2_augm atol=tol_erreur + @test x_sol ≈ sol_fct2_augm atol=tol_erreur + end + end + end diff --git a/test/tester_regions_de_confiance.jl b/test/tester_regions_de_confiance.jl deleted file mode 100755 index efb5eb65781636cd6956fc980662c758e864f3f2..0000000000000000000000000000000000000000 --- a/test/tester_regions_de_confiance.jl +++ /dev/null @@ -1,140 +0,0 @@ -@doc doc""" -Tester l'algorithme des régions de confiance - -# Entrées : - * affichage : (Bool) affichage ou non des résultats de chaque test - -# les cas de test (dans l'ordre) - * avec Cauchy : - - fct 1 : x011,x012 - - fct 2 : x021,x022,x023 - * avec gct : - - fct 1 : x011,x012 - - fct 2 : x021,x022,x023 -""" -function tester_regions_de_confiance(afficher::Bool,Regions_De_Confiance::Function) - - # La tolérance utilisée dans les tests - tol_erreur = 1e-2 - # initialisation des variables de l'algorithme - gamma1 = 0.5 - gamma2 = 2.00 - eta1 = 0.25 - eta2 = 0.75 - deltaMax = 10 - Tol_abs = sqrt(eps()) - Tol_rel = 1e-8 - epsilon = 1 - maxits = 5000 - delta0_1 = 2 - delta0_2 = 2 - options1 =[deltaMax,gamma1,gamma2,eta1,eta2,delta0_1,maxits,Tol_abs,Tol_rel,epsilon] - options2 =[deltaMax,gamma1,gamma2,eta1,eta2,delta0_2,maxits,Tol_abs,Tol_rel,epsilon] - - # l'ensemble de tests - @testset "La méthode des RC " begin - ################################################### - # les tests avec le pas de Cauchy # - ################################################### - # Un premier sous-ensemble de tests - @testset "avec Cauchy " begin - # cas de test 1 - x_min11, fmin11, flag11, nb_iters11 = Regions_De_Confiance("cauchy",fct1,grad_fct1,hess_fct1,pts1.x011,options1) - if (afficher) - afficher_resultats("régions de confiance avec "*"cauchy","fonction 1","x011",x_min11,fmin11, flag11,sol_exacte_fct1,nb_iters11) - end - @test isapprox(x_min11,sol_exacte_fct1 ,atol=tol_erreur) - @test flag11 == 2 - @test nb_iters11 == 26 - - # cas de test 2 - x_min12, fmin12, flag12, nb_iters12 = Regions_De_Confiance("cauchy",fct1,grad_fct1,hess_fct1,pts1.x012,options1) - if (afficher) - afficher_resultats("régions de confiance avec "*"cauchy","fonction 1","x012",x_min12,fmin12, flag11,sol_exacte_fct1,nb_iters12) - end - @test x_min12 ≈ sol_exacte_fct1 atol=tol_erreur - @test flag12 == 2 - @test nb_iters12 == 28 - - # cas de test 3 - x_min21, fmin21, flag21, nb_iters21, = Regions_De_Confiance("cauchy",fct2,grad_fct2,hess_fct2,pts1.x021,options2) - if (afficher) - afficher_resultats("régions de confiance avec "*"cauchy","fonction 2","x021",x_min21,fmin21, flag21,sol_exacte_fct2,nb_iters21) - end - @test x_min21 ≈ sol_exacte_fct2 atol=tol_erreur - @test flag21 == 2 - @test nb_iters21 == 3988 - - # cas de test 4 - x_min22, fmin22, flag22, nb_iters22 = Regions_De_Confiance("cauchy",fct2,grad_fct2,hess_fct2,pts1.x022,options2) - println("iters = ", nb_iters22) - if (afficher) - afficher_resultats("régions de confiance avec "*"cauchy","fonction 2","x022",x_min22,fmin22, flag22,sol_exacte_fct2,nb_iters22) - end - @test x_min22 ≈ sol_exacte_fct2 atol=tol_erreur - @test flag22 == 0 - @test nb_iters22 == 864 - - # cas de test 5 - x_min23, fmin23, flag23, nb_iters23 = Regions_De_Confiance("cauchy",fct2,grad_fct2,hess_fct2,pts1.x023,options2) - if (afficher) - afficher_resultats("régions de confiance avec "*"cauchy","fonction 2","x023",x_min23,fmin23, flag23,sol_exacte_fct2,nb_iters23) - end - @test x_min23 ≈ sol_exacte_fct2 atol=tol_erreur - @test flag23 == 2 - @test nb_iters23 == 3198 - end - - ################################################### - # les tests avec le gradient conjugué tronqué # - ################################################### - # Un deuxième sous-ensemble de tests - #= @testset "avec GCT " begin - # cas de test 1 - x_min11, fmin11, flag11, nb_iters11= Regions_De_Confiance("gct",fct1,grad_fct1,hess_fct1,pts1.x011,options1) - if (afficher) - afficher_resultats("régions de confiance avec "*"gct","fonction 1","x011",x_min11,fmin11, flag11,sol_exacte_fct1,nb_iters11) - end - @test isapprox(x_min11,sol_exacte_fct1 ,atol=tol_erreur) - @test flag11 == 0 - @test nb_iters11 == 1 - - # cas de test 2 - x_min12, fmin12, flag12, nb_iters12 = Regions_De_Confiance("gct",fct1,grad_fct1,hess_fct1,pts1.x012,options1) - if (afficher) - afficher_resultats("régions de confiance avec "*"gct","fonction 1","x012",x_min12,fmin12, flag12,sol_exacte_fct1,nb_iters12) - end - @test x_min12 ≈ sol_exacte_fct1 atol=tol_erreur - @test flag12 == 0 - @test nb_iters12 == 3 - - # cas de test 3 - x_min21, fmin21, flag21, nb_iters21 = Regions_De_Confiance("gct",fct2,grad_fct2,hess_fct2,pts1.x021,options2) - if (afficher) - afficher_resultats("régions de confiance avec "*"gct","fonction 2","x021",x_min21,fmin21, flag21,sol_exacte_fct2,nb_iters21) - end - @test x_min21 ≈ sol_exacte_fct2 atol=tol_erreur - @test flag21 == 0 - @test nb_iters21 == 31 - - - # cas de test 4 - x_min22, fmin22, flag22, nb_iters22 = Regions_De_Confiance("gct",fct2,grad_fct2,hess_fct2,pts1.x022,options2) - if (afficher) - afficher_resultats("régions de confiance avec "*"gct","fonction 2","x022",x_min22,fmin22, flag22,sol_exacte_fct2,nb_iters22) - end - @test x_min22 ≈ sol_exacte_fct2 atol=tol_erreur - @test flag22 == 0 - @test nb_iters22 == 44 - - # cas de test 5 - x_min23, fmin23, flag23, nb_iters23 = Regions_De_Confiance("gct",fct2,grad_fct2,hess_fct2,pts1.x023,options2) - if (afficher) - afficher_resultats("régions de confiance avec "*"gct","fonction 2","x023",x_min11,fmin23, flag23,sol_exacte_fct2,nb_iters23) - end - @test x_min23 ≈ sol_exacte_fct2 atol=tol_erreur - @test flag23 == 0 - @test nb_iters23 == 19 - end =# - end -end