Télécharger mma_03.dgibi

Retour à la liste

Numérotation des lignes :

  1. * fichier : mma_03.dgibi
  2. ************************************************************************
  3. ************************************************************************
  4.  
  5. ************************************************************************
  6. * Test de l'opérateur MMA : Méthode des Asymptotes Mobiles *
  7. * Reproduction d'un cas test de l'article originel de Svanberg *
  8. * *
  9. * Krister Svanberg: The method of moving asymptotes - a new method *
  10. * for structural optimization *
  11. * International Journal for Numerical Methods in Engineering, *
  12. * vol. 24, 359-373 (1987) *
  13. * https://doi.org/10.1002/nme.1620240207 *
  14. * *
  15. * *
  16. * *
  17. * Optimisation d'une poutre en flexion de section variable *
  18. * *
  19. * |‾‾‾‾‾‾‾‾‾‾‾‾|____________ *
  20. * | | |____________ *
  21. * | | | |____________ *
  22. * | | | | |____________ *
  23. * | | | | | | *
  24. * | 1 | 2 | 3 | 4 | 5 | *
  25. * | | | | |‾‾‾‾‾‾‾‾‾‾‾‾| *
  26. * | | | |‾‾‾‾‾‾‾‾‾‾‾‾ | *
  27. * | | |‾‾‾‾‾‾‾‾‾‾‾‾ | *
  28. * | |‾‾‾‾‾‾‾‾‾‾‾‾ \|/ *
  29. * ‾‾‾‾‾‾‾‾‾‾‾‾ v *
  30. * *
  31. * La poutre est divisée en 5 troncons de même longueur et de sections *
  32. * x1 x2 x3 x4 et x5 qui seront les variables de conception. *
  33. * Elle est encastrée à gauche et soumise à une force verticale à *
  34. * droite. *
  35. * *
  36. * Le problème d'optimisation est le suivant : *
  37. * - Trouver x=(x1 x2 x3 x4 x5) pour minimiser la masse de la poutre *
  38. * - tels que la flèche soit inférieure à une limite donnée *
  39. * *
  40. * Au final, le problème à résoudre se ramène à : *
  41. * Minimiser : f0(x) = c1 * (x1 + x2 + x3 + x4 + x5) *
  42. * sur x *
  43. * *
  44. * avec : f1(x) = 61/x1**3 + 37/x2**3 + 19/x3**3 *
  45. * + 7/x4**3 + 1/x5**3 < c2 *
  46. * 1 < xi < 10 *
  47. * *
  48. * Si on choisit c1 = 0.0624 et c2 = 1, alors la solution est : *
  49. * x1 = 6.0160 x2 = 5.3092 x3 = 4.4943 x4 = 3.5015 x5 = 2.1527 *
  50. ************************************************************************
  51.  
  52. * Options d'affichage
  53. OPTI 'ECHO' 0 ;
  54. itrac = FAUX ;
  55.  
  56. * Procedure pour calculer f0, f1 ainsi que les derivees partielles
  57. * df0/dxi, df1/dxi, df2/dxi pour i=1,2,3,4,5
  58. DEBP FONC a*'LISTREEL' ;
  59. c1 = 0.0624 ;
  60. c2 = 1. ;
  61. f0 = c1 * (SOMM a) ;
  62. df0da = PROG (DIME a)*c1 ;
  63. ld = PROG 61. 37. 19. 7. 1. ;
  64. fval = PROG ((SOMM (ld / (a ** 3))) - c2) ;
  65. dfda = TABL ;
  66. dfda . 1 = -3. * ld / (a ** 4) ;
  67. FINP f0 df0da fval dfda ;
  68.  
  69. * Solution de reference
  70. x1ref = 6.0160 ;
  71. x2ref = 5.3092 ;
  72. x3ref = 4.4943 ;
  73. x4ref = 3.5015 ;
  74. x5ref = 2.1527 ;
  75. xref = PROG x1ref x2ref x3ref x4ref x5ref ;
  76. f0ref df0dxref fval0 dfdxref = FONC xref ;
  77. MESS 'Solution de reference' ;
  78. MESS ' x1 x2 x3 x4 x5 f0' ;
  79. MESS (CHAI 'FORMAT' '(F12.8)' x1ref /4 x2ref /16 x3ref /28 x4ref /40 x5ref /52 f0ref /64) ;
  80.  
  81. * Choix d'un point initial pour les inconnues
  82. x0 = PROG 5. 5. 5. 5. 5. ;
  83.  
  84. * Calcul de f0(x0), df0dx(x0), fval(x0), dfdx(x0)
  85. f0 df0dx fval dfdx = FONC x0 ;
  86.  
  87. * Initialisation de la table pour la MMA
  88. t = TABL ;
  89. t . 'X' = x0 ;
  90. t . 'XMIN' = 1. ;
  91. t . 'XMAX' = 10. ;
  92. t . 'F0VAL' = f0 ;
  93. t . 'DF0DX' = df0dx ;
  94. t . 'FVAL' = fval ;
  95. t . 'DFDX' = dfdx ;
  96. t . 'A0' = 1. ;
  97. t . 'A' = PROG 0. ;
  98. t . 'C' = PROG 1.E5 ;
  99. t . 'D' = PROG 1. ;
  100. t . 'MOVE' = 1. ;
  101.  
  102. * Iterations de la MMA
  103. x01 = EXTR x0 1 ;
  104. x02 = EXTR x0 2 ;
  105. x03 = EXTR x0 3 ;
  106. x04 = EXTR x0 4 ;
  107. x05 = EXTR x0 5 ;
  108. lx1 = PROG x01 ;
  109. lx2 = PROG x02 ;
  110. lx3 = PROG x03 ;
  111. lx4 = PROG x04 ;
  112. lx5 = PROG x05 ;
  113. lit = PROG 0. ;
  114. lf0 = PROG f0 ;
  115. f1 = EXTR fval 1 ;
  116. li = PROG (MAXI 0. f1) ;
  117. MESS 'Optimisation par MMA' ;
  118. MESS 'It x1 x2 x3 x4 x5 f0 kktnorm' ;
  119. MESS (CHAI 'FORMAT' '(F12.8)' 0 x01 /4 x02 /16 x03 /28 x04 /40 x05 /52 f0 /64) ;
  120. * Boucle d'optimisation
  121. REPE loop 10 ;
  122. * Appel a MMA
  123. lit = lit ET &loop ;
  124. MMA t ;
  125. xmma = t . 'X' ;
  126. x1 = EXTR xmma 1 ;
  127. x2 = EXTR xmma 2 ;
  128. x3 = EXTR xmma 3 ;
  129. x4 = EXTR xmma 4 ;
  130. x5 = EXTR xmma 5 ;
  131. lx1 = lx1 ET x1 ;
  132. lx2 = lx2 ET x2 ;
  133. lx3 = lx3 ET x3 ;
  134. lx4 = lx4 ET x4 ;
  135. lx5 = lx5 ET x5 ;
  136. * Mise a jour des valeurs des fonctions
  137. f0 df0dx fval dfdx = FONC xmma ;
  138. lf0 = lf0 ET f0 ;
  139. f1 = EXTR fval 1 ;
  140. li = li ET (MAXI 0. f1) ;
  141. t . 'F0VAL' = f0 ;
  142. t . 'DF0DX' = df0dx ;
  143. t . 'FVAL' = fval ;
  144. t . 'DFDX' = dfdx ;
  145. * Calcul du residu pour les conditions KKT
  146. res kkt2 kktinf = KKT_MMA t ;
  147. * Bilan de l'iteration
  148. MESS (CHAI 'FORMAT' '(F12.8)' &loop x1 /4 x2 /16 x3 /28 x4 /40 x5 /52 f0 /64 kkt2 /76) ;
  149. FIN loop ;
  150. nit = (DIME lf0) - 1 ;
  151.  
  152. * Verification du resultat
  153. errmax = MAXI 'ABS' ((xmma - xref) / xref) ;
  154. MESS 'Erreur relative max (sur x)' ;
  155. MESS errmax ;
  156.  
  157. * Évolutions temporelles de f, de l'infaisabilité et des variables
  158. * en fonction des iterations d'optimisation
  159. SI itrac ;
  160. lit = PROG 0. 'PAS' 1. nit ;
  161. evf0 = EVOL 'ROUG' 'MANU' 'Iteration' lit 'F0' lf0 ;
  162. evfr = EVOL 'ROUG' 'MANU' 'Iteration' (PROG 0. nit) 'F0' (PROG f0ref f0ref) ;
  163. tl = TABL ;
  164. tl . 2 = 'TIRR' ;
  165. tl . 'TITRE' = TABL ;
  166. tl . 'TITRE' . 1 = 'F0 calculee' ;
  167. tl . 'TITRE' . 2 = 'F0 ref.' ;
  168. DESS (evf0 ET evfr) 'TITR' 'Fonction objectif F0(x) VS Iterations' 'LEGE' tl ;
  169. evi = EVOL 'VERT' 'MANU' 'Iteration' lit 'Inf' li ;
  170. tl . 'TITRE' . 1 = 'Infaisabilite' ;
  171. DESS evi 'TITR' 'Infaisabilite VS Iterations' 'LEGE' tl ;
  172. evx1 = EVOL 'ROUG' 'MANU' 'Iteration' lit 'x' lx1 ;
  173. evx1r = EVOL 'ROUG' 'MANU' 'Iteration' (PROG 0. nit) 'x' (PROG x1ref x1ref) ;
  174. evx2 = EVOL 'ORAN' 'MANU' 'Iteration' lit 'x' lx2 ;
  175. evx2r = EVOL 'ORAN' 'MANU' 'Iteration' (PROG 0. nit) 'x' (PROG x2ref x2ref) ;
  176. evx3 = EVOL 'JAUN' 'MANU' 'Iteration' lit 'x' lx3 ;
  177. evx3r = EVOL 'JAUN' 'MANU' 'Iteration' (PROG 0. nit) 'x' (PROG x3ref x3ref) ;
  178. evx4 = EVOL 'JAUN' 'MANU' 'Iteration' lit 'x' lx4 ;
  179. evx4r = EVOL 'VERT' 'MANU' 'Iteration' (PROG 0. nit) 'x' (PROG x4ref x4ref) ;
  180. evx5 = EVOL 'BLEU' 'MANU' 'Iteration' lit 'x' lx5 ;
  181. evx5r = EVOL 'BLEU' 'MANU' 'Iteration' (PROG 0. nit) 'x' (PROG x5ref x5ref) ;
  182. tl . 4 = 'TIRR' ;
  183. tl . 6 = 'TIRR' ;
  184. tl . 8 = 'TIRR' ;
  185. tl . 10 = 'TIRR' ;
  186. tl . 'TITRE' . 1 = 'x1 calcule' ;
  187. tl . 'TITRE' . 2 = 'x1 ref.' ;
  188. tl . 'TITRE' . 3 = 'x2 calcule' ;
  189. tl . 'TITRE' . 4 = 'x2 ref.' ;
  190. tl . 'TITRE' . 5 = 'x3 calcule' ;
  191. tl . 'TITRE' . 6 = 'x3 ref.' ;
  192. tl . 'TITRE' . 7 = 'x4 calcule' ;
  193. tl . 'TITRE' . 8 = 'x4 ref.' ;
  194. tl . 'TITRE' . 9 = 'x5 calcule' ;
  195. tl . 'TITRE' . 10 = 'x5 ref.' ;
  196. DESS (evx1 ET evx1r ET evx2 ET evx2r ET evx3 ET evx3r ET evx4 ET evx4r ET evx5 ET evx5r) 'TITR' 'Valeurs x VS Iterations' 'LEGE' tl ;
  197. FINSI ;
  198.  
  199. * Sortie en erreur si l'écart aux valeurs de références est trop important
  200. SI (errmax > 1.E-4) ;
  201. ERRE 'Erreur dans le calcul d''optimisation' ;
  202. SINON ;
  203. MESS 'Cas test passe avec succes !' ;
  204. FINSI ;
  205.  
  206.  
  207. FIN ;
  208.  
  209.  
  210.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales