shape optimization with adaptive simulated annealing and genetic ...

6
ISEF 2003 - 11th International Symposium on Electromagnetic Fields in Electrical Engineering Maribor, Slovenia, September 18-20, 2003 SHAPE OPTIMIZATION WITH ADAPTIVE SIMULATED ANNEALING AND GENETIC ALGORITHMS Hartmut Brauer 1 , Marek Ziolkowski 1,2 1 Technische Universitaet Ilmenau, Am Helmholtzplatz 2, D-98684 Ilmenau, Germany 2 Technical University of Szczecin, Sikorskiego 37, PL-70313 Szczecin, Poland email: [email protected] Abstract Stochastic methods offer a certain robustness quality to the optimization process. In this paper, the Adaptive Simulated Annealing (ASA) and two Genetic Algorithms (GA) are used for the shape optimization of a shimming magnet pole. The magnetic field is computed using the finite element method in 2D. The aim of optimization is the search for a pole shape geometry which leads to a homogeneous magnetic field in the region of interest. Introduction For optimal performance of electromagnetic devices, it is necessary to perform design optimization of the shape and parameters of their magnetic circuit, size and position of the current windings, magnetic properties of the used magnetic materials, etc. The traditional optimization methods based on trial- and-error procedures are not very suitable, especially for highly complex and multivariable optimization problems because they are very laborious, time consuming and not enough accurate. Therefore, the development of new and more efficient methods for inverse optimization and automation of the entire optimization process are always desired. Optimization methods are usually classified into two categories: the gradient-based (deterministic) search methods and non-gradient-based (stochastic) search methods. While the former ones need computation of the gradient of the objective function, the latter ones work directly with the values of the objective function, and are more convenient in cases where it is difficult or even impossible to compute exactly the gradient of the objective function [1]. In electromagnetic device optimization the problem of obtaining such devices which will result with desired values of the magnetic flux density at several certain points, is a very common problem. However, since the exact expression of the gradient function is impossible, therefore, usage of the deterministic optimization methods is excluded. Consequently, for such optimization problems designers usually utilize stochastic methods. Genetic Algorithm (GA), Simulated Annealing (SA), Evolution Strategy (ES), or Tabu Search (TS) are such stochastic methods which become very popular in the design of electromagnetic devices [2-4]. In this paper, we compare ASA and two different versions of GA to the shape optimization of the pole shape geometry of a simple shimming magnet, where we are searching for the pole shape modifications leading to a homogeneous magnetic flux density in a certain region. Shape Optimization Problem The proposed framework to optimize is presented in Fig. 1. It is a simplified 2D configuration of a shimming magnet where the optimization goal is to obtain a modified magnetic pole shape generating a constant magnetic flux density in a certain part of the central region of the air gap. Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30

Transcript of shape optimization with adaptive simulated annealing and genetic ...

Page 1: shape optimization with adaptive simulated annealing and genetic ...

ISEF 2003 - 11th International Symposium on Electromagnetic Fields in Electrical Engineering

Maribor, Slovenia, September 18-20, 2003

SHAPE OPTIMIZATION WITH ADAPTIVE SIMULATED ANNEALING AND GENETIC ALGORITHMS

Hartmut Brauer 1, Marek Ziolkowski 1,2

1 Technische Universitaet Ilmenau, Am Helmholtzplatz 2, D-98684 Ilmenau, Germany

2 Technical University of Szczecin, Sikorskiego 37, PL-70313 Szczecin, Poland email: [email protected]

Abstract – Stochastic methods offer a certain robustness quality to the optimization process. In this paper, the Adaptive Simulated Annealing (ASA) and two Genetic Algorithms (GA) are used for the shape optimization of a shimming magnet pole. The magnetic field is computed using the finite element method in 2D. The aim of optimization is the search for a pole shape geometry which leads to a homogeneous magnetic field in the region of interest.

Introduction

For optimal performance of electromagnetic devices, it is necessary to perform design optimization of the shape and parameters of their magnetic circuit, size and position of the current windings, magnetic properties of the used magnetic materials, etc. The traditional optimization methods based on trial-and-error procedures are not very suitable, especially for highly complex and multivariable optimization problems because they are very laborious, time consuming and not enough accurate. Therefore, the development of new and more efficient methods for inverse optimization and automation of the entire optimization process are always desired.

Optimization methods are usually classified into two categories: the gradient-based (deterministic) search methods and non-gradient-based (stochastic) search methods. While the former ones need computation of the gradient of the objective function, the latter ones work directly with the values of the objective function, and are more convenient in cases where it is difficult or even impossible to compute exactly the gradient of the objective function [1].

In electromagnetic device optimization the problem of obtaining such devices which will result with desired values of the magnetic flux density at several certain points, is a very common problem. However, since the exact expression of the gradient function is impossible, therefore, usage of the deterministic optimization methods is excluded. Consequently, for such optimization problems designers usually utilize stochastic methods. Genetic Algorithm (GA), Simulated Annealing (SA), Evolution Strategy (ES), or Tabu Search (TS) are such stochastic methods which become very popular in the design of electromagnetic devices [2-4]. In this paper, we compare ASA and two different versions of GA to the shape optimization of the pole shape geometry of a simple shimming magnet, where we are searching for the pole shape modifications leading to a homogeneous magnetic flux density in a certain region.

Shape Optimization Problem

The proposed framework to optimize is presented in Fig. 1. It is a simplified 2D configuration of a shimming magnet where the optimization goal is to obtain a modified magnetic pole shape generating a constant magnetic flux density in a certain part of the central region of the air gap.

Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30

Page 2: shape optimization with adaptive simulated annealing and genetic ...

JJ

J J

J0µ

µ0

µ0

x

y

Fig. 1. Layout of the considered shape optimization problem in a simplified 2D shimming magnet system (left),

and the field problem used for the shape optimization, with iron core, impressed current density J, and boundary conditions (right).

The magnetic flux in the iron core, which is assumed to be linear or nonlinear, is driven by the current density J indicated in Fig. 1. Because of the symmetry only a part of the framework has to be taken into account. This region of interest is indicated by the dashed line. Extracting this region of interest we get the configuration to which the stochastic optimization methods were applied (Fig. 1). A current density of 1 A/mm2 was applied to the coil, and two different cases of magnetic material were considered: a linear one with µr = 100 and a nonlinear one where a material characteristic of steel M19 was assumed. The magnetic fields were computed using the free available finite element software code FEMM (http://femm.berlios.de). The goal of the shape optimization is getting a constant magnetic flux density at y = 0 and 0 ≤ x ≤ 80mm. To develop our idea, first, let us briefly describe the strategy for shape optimization based on the searching techniques employed in our approach. First, we have to define the searching space, and establish several control points along the outline of the device which shape optimization is desired as shown in Fig.2.

y

y1 y1 y2 y3 y4 y5 y6

x

J0µ

Fig. 2. Field problem used for the shape optimization, with positions of the six control points y1, … y6.

> 0.136

0.112 : 0.1240.099 : 0.1120.087 : 0.0990.075 : 0.0870.062 : 0.0750.050 : 0.0620.037 : 0.0500.025 : 0.0370.013 : 0.025< 0.013

0.124 : 0.136

Fig. 3. Finite element mesh (left) and magnetic flux density distribution (right) of the starting configuration

computed with the FEM code FEMM.

Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30

Page 3: shape optimization with adaptive simulated annealing and genetic ...

In this example, we are interested in an optimal shape of the iron core, and for that purpose, we have chosen a set of six control points, indicated by the variables y1 through y6 (Fig. 2). Each point is fixed in the x-coordinate, while it can move freely within the searching space (y-direction), which is defined by the interval of 10mm � yi � 65mm. The control point y1 is doubled which means that the control points at x = 0mm and at x = 50mm can be moved only together. Between the control points no smooth approximation of the core shape has been done. The control points are connected by polygons corresponding to the finite element mesh (Fig. 3, left). The magnetic flux density distribution for this starting configuration is given in Fig. 3 (right).

Optimization using Adaptive Simulated Annealing (ASA)

Annealing is actually a term from metallurgy. If a metal is heated to a very high temperature, the atoms move at high speed. If they are cooled now very slowly, they settle into patterns and structures, rendering the metal much stronger than before. Simulated Annealing (SA) is a stochastic relaxation technique which is based on the analogy to the physical process of metal annealing: at high temperatures the atoms are randomly distributed. With decreasing the temperature they tend to arrange themselves in a crystalline state which minimizes their energy. Using this analogy, the algorithm generates randomly new configurations by sampling from probability distribution of the system. New configurations are accepted with a certain acceptance probability depending on the temperature. It has been shown that the algorithm converges to a global energy minimum if the temperature is reduced slowly enough [8]. In this study we have applied the Adaptive Simulated Annealing (ASA) Code which is a C-language code developed to statistically find the best global fit of a nonlinear constrained non-convex cost function over a N-dimensional space [7]. This algorithm permits an annealing schedule for “temperature” T decreasing exponentially in annealing-time k,

T = T0 exp(-c k1/N).

The introduction of re-annealing also permits adaptation to changing sensitivities in the multi-dimensional parameter space. This annealing schedule is faster than fast Cauchy annealing, where T = T0/k, and much faster than Boltzmann annealing, where T = T0/ln k.

The ASA algorithm consists of three main parts [8]:

Generating probability density function In a N-dimensional parameter space with parameters pi having ranges [Ai, Bi], about the k-th saved point (e.g., a local optima), pi

k, a new point is generated using a distribution defined by the product of distributions for each parameter, gi(yi; Ti) in terms of random variables yi∈[-1,1], where pi

k+1 = pik +

yi(Bi-Ai), and “temperatures” Ti,

Acceptance probability density function The cost functions, C(pk+1) – C(pk), are compared using a uniform random generator, U ∈ [0, 1], in a “Boltzmann” test:

exp[-(C(pk+1) - C(pk))/Tcost] > U,

where Tcost is the “temperature” used for this test. If the above inequality is fulfilled then the new point is accepted as the new saved point for the next iteration. Otherwise, the last saved point is retained.

)/11(ln)(2

1);(

iiii

ii

TTyTyg

+⋅+⋅=

Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30

Page 4: shape optimization with adaptive simulated annealing and genetic ...

Reannealing temperature schedule The annealing schedule for each parameter temperature, Ti from a starting temperature Ti0, is

Ti(ki) = Ti0 exp(-ci ki1/N).

The annealing schedule for the cost temperature is developed similarly to the parameter temperatures. However, the index for re-annealing the cost function, kcost, is determined by the number of accepted points, instead of the number of generated points as used for the parameters. This choice was made because the Boltzmann acceptance criterion uses an exponential distribution which is not as fat-tailed as the ASA distribution used for the parameters. As determined by the selected program options, the parameter “temperature” may be periodically adaptively re-annealed, or increased relative to their previous values, using their relative first derivatives with respect to the cost function, to guide the search “fairly” among the parameters. The re-annealing of the cost temperature resets the scale of the annealing of the cost acceptance criteria as

Tcost(kcost) = T0 cost exp(-ccost kcost1/N).

The new T0 cost is taken to be the minimum of the current initial cost temperature and the maximum of the absolute values of the best and last cost functions and their difference. The new kcost is calculated taking Tcost as the minima of the cost function, constrained not to exceed the current initial cost temperature. This procedure essentially resets the scale of the annealing of the cost temperature within the scale of the current best or last saved minimum.

Optimization using Genetic Algorithms (GA)

Various searching techniques based on the GAs have already been applied for inverse shape optimization of electromagnetic devices, mainly due to their ability to avoid trapping into local optimum of the objective function [1-4]. Genetic Algorithms work with the coded information rather than directly with the optimized functions. Therefore, they can be adjusted to the particular problem relatively easily. In this study we have applied a C++ library of genetic algorithm components (GAlib) developed at the M.I.T. [5]. From the implemented algorithms offered by the GAlib we have chosen the standard, simple genetic algorithm which uses non-overlapping populations, optional elitism and roulette-wheel selection scheme. We have applied the 16 bit binary-to-decimal genome (which converts binary strings to decimal values) and modified the crossover and mutation probabilities for population sizes of 60 individuals. We have also applied the Genetic Algorithm Optimization Toolbox (GAOT) developed at the North Carolina State University [6]. GAOT implements simulated evolution in the Matlab environment using both binary and real representations. Here the crossover and mutation operators were chosen much more sophisticated. Arithmetic, heuristic and simple crossover operators were applied with different frequencies [6]. Table I. Applied frequencies of the crossover operator and the mutation operator in GAOT, where Gmax is the maximum number of generations and b is a certain shape parameter describing the mutation rate.

�����

arithmetic 4 0heuristic 1 3simple 4 0

��Crossover Applied frequency n Mutator Applied G b frequency

max

boundary 1 0 0uniform 1 0 0non-uniform 4 200 2multi non-uniform 4 200 2

Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30

Page 5: shape optimization with adaptive simulated annealing and genetic ...

Optimization results

The aim of the simulation study is the investigation of the effects of modified stochastic operators on the shape optimization process. We minimized the cost function

( )

0

1

20

%100B

BB

CF

N

ii�

=

−=

where B0 is the desired constant magnetic flux density along the symmetry line (0 < x < 80mm; y = 0). With the impressed current density of 1 A/mm2 we defined a value of B0 = 40 mT. The GA simulations were performed for crossover rates of 0.55, 0.65, 0.75, 0.85, and 0.95, and for mutation rates of 0.01, 0.1, and 0.2. The search for the optimal shape was terminated after 100 generations. Fig. 4 shows the results of both GA and ASA optimization, respectively, for the linear case (iron core with µr = 100) and for the nonlinear case (iron core with steel M19). The population contained 60 individuals. The best results were obtained with a mutation probability of 0.01 and crossover probabilities of 0.65 and 0.85 for the linear case and the nonlinear case, respectively. ASA GAOT GAlib

µ =100r

�������

µ =100r

������

µ =100r

�������

M19

������

M19

������

M19

�������

Fig. 4. Results of the optimization for the linear (µr = 100) and the nonlinear problem (steel M19)

Because of the stochastic characteristics of the applied methods it is not sure that we have got the “best” result if the process is terminated by the maximum number of generations, i.e. in some cases we have got lower cost function values for other crossover rates or mutation rates than given here. But in all cases we found that it makes no sense to increase the mutation rate considerably. Usually, a mutation probability of 0.01 is a good choice. Another essential parameter is the population size. We could improve the results if their number was increased (e.g., 30 → 60). Fig. 5 shows the magnetic flux density distribution at the symmetry line for linear and nonlinear problems together with the solution for the start configuration.

0 20 40 60 80 1000.025

0.03

0.035

0.04

0.045

0.05

x [mm]

B [

T]

Start (CF=61.39%)ASA (CF=0.48%)GAlib (CF=0.56%)GAOT (CF=0.47%)

0 20 40 60 80 1000.025

0.03

0.035

0.04

0.045

0.05

x [mm]

B [

T]

Start (CF=72.87%)ASA (CF=0.61%)GAlib (CF=0.56%)GAOT (CF=0.73%)

Fig. 5. Magnetic flux densities at the line of symmetry for the linear case (left), for the nonlinear case (right)

Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30

Page 6: shape optimization with adaptive simulated annealing and genetic ...

The three methods (GA/ASA) have given similar results (CF around 0.5%) although the shapes of the iron core are slightly different. The time of calculations has been also comparable i.e. several minutes on 1GHz Pentium4. The only difference has consisted in the fact that GA demanded more carefully tuning (choosing the adequate population size, the crossover and the mutation probabilities) than ASA which has been applied with the standard options only.

Conclusions

In optimization problems where derivatives of the cost function are not available stochastic methods like Genetic Algorithm or Simulated Annealing can be applied. In this paper both these methods have been used to optimize the pole shape of a simple shimming magnet configuration. Different optimization algorithms (GA, ASA) known from the literature have been combined with the finite element code FEMM to study their performance for shape optimization problems. The true strength of SA lies in its ability to statistically deliver a true global optimum, but there are no theoretical reasons for assuming that it will be more efficient than GA which also can find the global optimum. Thus, a possible comparison of GA and SA must be viewed in the context of “judging” these algorithms only specific to the problem just being tested. It should be expected that there are systems for which one of GA or SA will be better suited than the other. For our problem no one could be preferred. With GAlib we found in both the linear and nonlinear cases exactly the same value of the cost function, whereas GAOT gave the best result in the linear case but the most wrong result in the nonlinear case. On the other hand, ASA is easier to handle and works more robust than the GA codes. In the next future, further modifications of the so far used standard algorithms will show under which conditions these conclusions can be maintained.

References

[1] Rahmat-Samii, Y., E. Michielssen: “Electromagnetic Optimization by Genetic Algorithms”, Wiley, 1999 [2] Lukas, D.: “Shape optimization of homogeneous electromagnets”. In: Lecture Notes in Computational

Science and Engineering, Springer, 2001, vol. 18, pp. 145-152 [3] Zaoui, F., C. Marchand: “Using genetic algorithm for the optimization of electromagnetic devices”.

COMPEL, vol. 17, No. 1/2/3, 1998, pp. 181-185 [4] Yokose, Y., V. Cingoski, K. Kaneda, H. Yamashita: “Performance comparison between gray coded and

binary coded genetic algorithms for inverse shape optimization of magnetic devices”. Proc. 1st Japanese-Bulgarian-Macedonian Joint Seminar on Applied Electromagnetics and Mechanics, Sofia, 1998

[5] Wall, M.: “GAlib: A C++ Library of Genetic Algorithm Components”. V2.4, 1996, http://lancet.mit.edu/ga/ [6] Houck, C.R., J.A. Joines, M.G. Kay: “A genetic algorithm for function optimization: a Matlab

implementation”. North Carolina State University, NCSU-IE TR 95-09, 1995 [7] Ingber, L.: “Adaptive Simulated Annealing (ASA)”. ASA-User Manual, 2003, http://www.ingber.com/ [8] Ingber, L.: “Simulated annealing: Practice versus theory”. Math. Comput. Modelling, vol. 18, No. 11,

1993, pp. 29-57

Computer Engineering in Applied Electromagnetism, Eds: S.Wiak, A.Krawczyk, M.Trlep, Published by Springer,2005, pp. 25-30