* fichier : mma_04.dgibi ************************************************************************ ************************************************************************ ************************************************************************ * Test de l'opérateur MMA : Méthode des Asymptotes Mobiles * * Application a une fonction a 2 variables avec 5 contraintes * * * * Le problème s'écrit : * * Minimiser : f0(x) = (x1-8)² + (x2-9)² * * sur x * * avec : f1(x) = ((x1-7)/5)² + ((x2-3)/2)² >= 1 (ellipse) * * f2(x) = ( x1/4 )² + ((x2-8)/5)² >= 1 (ellipse) * * f3(x) = (x1-6)² + (x2-7)² >= 1 (cercle) * * f4(x) = (x1-7)² + (x2-10)² >= 1 (cercle) * * f5(x) = (x1-10)² + (x2-7)² >= 1 (cercle) * * 0 <= xi <= 10 pour i=1,2 * * * * La solution (evidente) est : x1 = 8 x2 = 9 * ************************************************************************ * Options itrac = FAUX ; * Procedure pour calculer f0 ainsi que les derivees partielles df0/dx df = 2. * (a - c0) ; dgda . 1 = -2. * (a - c1) / (d1 ** 2) ; dgda . 2 = -2. * (a - c2) / (d2 ** 2) ; dgda . 3 = -2. * (a - c3) / (d3 ** 2) ; dgda . 4 = -2. * (a - c4) / (d4 ** 2) ; dgda . 5 = -2. * (a - c5) / (d5 ** 2) ; FINP f df g dgda ; * Solution de reference x1ref = 8. ; x2ref = 9. ; MESS ; MESS 'Solution de reference' ; MESS ' x1 x2 f0' ; * Choix d'un point initial pour les inconnues * Calcul de f0(x0), df0dx(x0), fval(x0), dfdx(x0) * Initialisation de la table pour la MMA t . 'X' = x0 ; t . 'XMIN' = 0. ; t . 'XMAX' = 10. ; t . 'F0VAL' = f0 ; t . 'DF0DX' = df0dx ; t . 'FVAL' = fval ; t . 'DFDX' = dfdx ; t . 'A0' = 1. ; t . 'MOVE' = 0.01 ; * Iterations de la MMA MESS ; MESS 'Optimisation par MMA' ; MESS 'It x1 x2 f0 kktnorm' ; * Boucle d'optimisation REPE loop 150 ; * Appel a MMA lit = lit ET &loop ; MMA t ; xmma = t . 'X' ; lx1 = lx1 ET x1 ; lx2 = lx2 ET x2 ; * Mise a jour des valeurs des fonctions lf0 = lf0 ET f0 ; t . 'F0VAL' = f0 ; t . 'DF0DX' = df0dx ; t . 'FVAL' = fval ; t . 'DFDX' = dfdx ; * Calcul du residu pour les conditions KKT res kkt2 kktinf = KKT_MMA t ; * Bilan de l'iteration FIN loop ; MESS ; * Verification du resultat MESS errmax ; MESS ; * Évolutions temporelles de f, de l'infaisabilité et des variables * en fonction des iterations d'optimisation SI itrac ; f0msh = ((x - 8.) ** 2) + ((y - 9.) ** 2) ; f1msh = (((x - 7.) / 5.) ** 2) + (((y - 3.) / 2.) ** 2) - 1. ; f2msh = (((x - 0.) / 4.) ** 2) + (((y - 8.) / 5.) ** 2) - 1. ; f3msh = (((x - 6.) / 1.) ** 2) + (((y - 7.) / 1.) ** 2) - 1. ; f4msh = (((x - 7.) / 1.) ** 2) + (((y - 10.) / 1.) ** 2) - 1. ; f5msh = (((x - 10.) / 1.) ** 2) + (((y - 7.) / 1.) ** 2) - 1. ; pdep = x01 x02 ; pfin = x1 x2 ; (annd ET annf) 'TITR' 'Isovaleurs de la fonction objectif F0 et chemin au cours de l''optimisation' ; tl . 2 = 'TIRR' ; tl . 'TITRE' . 1 = 'F0 calculee' ; tl . 'TITRE' . 2 = 'F0 ref.' ; tl . 'TITRE' . 1 = 'Infaisabilite' ; tl . 4 = 'TIRR' ; tl . 'TITRE' . 1 = 'x1 calcule' ; tl . 'TITRE' . 2 = 'x1 ref.' ; tl . 'TITRE' . 3 = 'x2 calcule' ; tl . 'TITRE' . 4 = 'x2 ref.' ; FINSI ; * Sortie en erreur si l'écart aux valeurs de références est trop important SI (errmax > 1.E-2) ; SINON ; MESS 'Cas test passe avec succes !' ; FINSI ; FIN ;
© Cast3M 2003 - Tous droits réservés.
Mentions légales