Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms &...

47
Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij, van, R. A. (1999). Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen. (DCT rapporten; Vol. 1999.027). Eindhoven: Technische Universiteit Eindhoven. Document status and date: Gepubliceerd: 01/01/1999 Document Version: Uitgevers PDF, ook bekend als Version of Record Please check the document version of this publication: • A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website. • The final author version and the galley proof are versions of the publication after peer review. • The final published version features the final layout of the paper including the volume, issue and page numbers. Link to publication General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal. If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement: www.tue.nl/taverne Take down policy If you believe that this document breaches copyright please contact us at: [email protected] providing details and we will investigate your claim. Download date: 26. Jun. 2020

Transcript of Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms &...

Page 1: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

Samenvatting: "Genetic Algorithms & Engineering Design"plus twee toepassingenCitation for published version (APA):Rooij, van, R. A. (1999). Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen.(DCT rapporten; Vol. 1999.027). Eindhoven: Technische Universiteit Eindhoven.

Document status and date:Gepubliceerd: 01/01/1999

Document Version:Uitgevers PDF, ook bekend als Version of Record

Please check the document version of this publication:

• A submitted manuscript is the version of the article upon submission and before peer-review. There can beimportant differences between the submitted version and the official published version of record. Peopleinterested in the research are advised to contact the author for the final version of the publication, or visit theDOI to the publisher's website.• The final author version and the galley proof are versions of the publication after peer review.• The final published version features the final layout of the paper including the volume, issue and pagenumbers.Link to publication

General rightsCopyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright ownersand it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights.

• Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal.

If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, pleasefollow below link for the End User Agreement:www.tue.nl/taverne

Take down policyIf you believe that this document breaches copyright please contact us at:[email protected] details and we will investigate your claim.

Download date: 26. Jun. 2020

Page 2: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

” Samenvatting: Genetic Algorithms Engineering Design” plus twee toepassingen

R.A. van Rooij

6 december 1999

Inhoudsopgave 1 Foundations of Genetic Algorithms 1

2 Constrained optimization problems 7

2.2 Nonlinear programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.3 Stochastic Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.5 Interval Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.1 Unconstrained Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.4 Nonlinear Goal Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3 Combinatorial optimization problems 17

4 Twee toepassingen 18 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.2 Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.3 Crossover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.4 Mutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.5 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.6 Ackley’s function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.7 Valve spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.8 Korte toelichting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

A Matlab Code 22 A.l Ackleys functie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

A. l . l MA1NACKL.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 A.1.2 ACKLEYS.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 A.1.3 CR0SACKL.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 A.1.4 MUTACKL.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 A.1.5 SELACKL.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 A.1.6 PL0TACKL.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

A.2 Valvespring probleem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 k.2.i GEN0PT.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 A.2.2 GEN1NPUT.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 A.2.3 GENSPR1NG.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 A.2.4 CROSS0VER.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 A.2.5 MUTATI0N.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 A.2.6 SELECTI0N.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 A.2.7 PENAL1ZE.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 A.2.8 D1AMETERS.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 A.2.9 WIND1NGS.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

1

Page 3: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

A.2.10 MATPAKM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 A.2.11 BESTDES1GN.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 A.2.12 TAUMAX.M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

1 Foundations of Genetic Algorithms Bij genetische algoritmen wordt altijd uitgegaan van een bepaalde populatie. Zo’n populatie bestaat uit een aantal chromosomen, dit zijn gecodeerde representaties van punten in de oploss- ingsruimte. Deze chromosomen zijn op een random wijze gekozen. Gedurende de succesievelijke iteratie stappen, ook wel aangeduid als generaties, zullen deze chromosomen evolueren naar een bepaalde eindoplossing. Voor iedere generatie worden de chromosomen geëvalueerd m.b.t. hun fitheid (vaak de doelfunctie waarde van de bij het chromosoom behorende punt in de oploss- ingsruimte). De fitheid van een chromosoom is bepalend voor de mate waarin dit choromosoom zich kan voortplanten, de fitheid vormt dan ook de basis voor het selectieproces. Een chromosoom kan zich op twee manieren voortplanten, enerzijds d.m.v. crossover en anderzijds d.m.v. mutatie.

o Crossover: Crossover komt er simpelweg op neer dat men een tweetal chromosomen in stukken knipt waarna de stukken uitgewisseld worden (zie figuur 1). De crossoverrate (p,) is het getal dat de verhouding geeft tussen de hoeveelheid nageslacht (of oflspring) aangemaakt middels het principe van crossover en de oorspronkelijke populatie grootte. Naarmate men de waarde van pc groter maakt zal men een groter gebied van de oplossingsruimte exploreren, er is in dat geval minder kans op voortijdige convergentie naar een lcaal optimum. Een te grote p , leidt echter tot een te grote verspilling van rekentijd en dat dient uiteraard ook vermeden te worden.

children

parrent 2

Figuur 1: Illustratie van de manier waarop crossover tussen twee chromosomen wordt gerealiseerd.

o Mutatie: De meest eenvoudige vorm van mutatie is het eenvoudigweg veranderen van een van de genen (bij chromosomen die gegeven worden door een bitstring is dat dus een O of een 1) van een aantal chromosomen (zie figuur 1). Het doel van mutatie is tweerlei:

- Enerzijds wil men genen die vroegtijdig in het iteratieproces zijn afgevallen tijdens het

- Anderzijds wil men ook gengen aan kunnen maken die in eertste instantie helemaal niet selectie proces opnieuw proberen maar dan in een andere context.

in de populatie voorkomen.

De mutationrate (p,) is het getal dat de verhouding geeft tussen de offspring gegenereerd door middel van mutatie en de oorspronkelijke populatie grootte.

Exploitatie vs. Exploratie Verschillende oplossingsmethoden gebruiken verschillende stukjes informatie m.b.t. functiewaar- den en liggen van een punt. De verschillende strategien die gebruikt worden om een optimum te vinden zijn in twee groepen in te delen. enerzijds de zgn. ”blind strategies” zoals b.v. ran- dom search. Deze strategien maken geen gebruik van beschikbare informatie. Anderzijds zijn

2

Page 4: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

Y mutatie parent

1 0 I O 1 I 1 I O child

Figuur 2: Illustratie van de manier waarop mutatie leidt tot nieuwe chromosomen.

er de heuristische strategien. Deze gebruiken de beschikbare informatie om de meest optimale zoekrichting te bepalen, De beschikbare informatie wordt dus ten volle gebruikt (geexploiteerd). Nadeel van deze laatste manier van aanpak is dat de kans bestaat dat er in een vroegtijdig stadium van het optimalisatie proces convergentie op treedt naar een locaal optimum. De blind strategie , die dus geen gebruik maken van de beschikbare informatie, zij meer exporatief van aard. Zij beschouwen ten alle tijde de volledige oplossingsruimte. Dit laatste biedt als voordeel dat men niet gevangen wordt in een of ander locaal optimum maar het grote nadeel is wel dat het aantal uit te voeren analyses voordat men het optimum bereikt erg groot kan zijn. Genetische algoritmes vormen een soort tussenweg. Bij aanvang van de zoektocht zorgt crossover ervoor dat een groot deel van de oplossingsruimte wordt bestreken, en dus geexproireerd. Echter op het moment dat één van de oplossingen dominant wordt zorgt crossover ervoor dat er intensief wordt gezocht bin- nen een klein gebiedje, dat gebiedje wordt dan dus geëxploiteerd.

Voordelen van Genetische Algoritmen

1. Er worden slechtis in geringe mate eisen gesteld aan de wiskundige beschrijving van de beschouwde problemen, er kan dus een breed scala aan problemen worden beschouwd.

2. Het is mogelijk om met behulp van genetische algoritmen een globaal optimum te vin- den. Door goed instellen van de verschillende proces parameters kan men locale optima ontvluchten.

Selectie vormt de drijvende kracht achter GA's, het is dan ook zaak dat men de selectie procedure goed in de hadnd weet te houden. De twee uitersten, voortijdige convergentie en grote inefficientie, dienen vermeden te worden. Over het algemeen stelt men, met dit doel voor ogen, de selectiedruk in eerste instantie laag in zodat een grooot deel van de oplossingsruimte zal worden geexploireerd. Naar het einde toe laat men de selectiedruk dan toenemen om de meest veelbelovende oplossingen te exploiteren. Er zijn drie onderwerpen van belang als men het heeft over de selectieprocedure.

1. sample space

2. sample mechanisme

3. selection probability

ad i j samp:t: apace: De sampling space wordt gekarakteriseerd door een tweetal factoren namelijk: de grootte en de inhoud (parent of offspring). De populatie grootte wordt aangeduid d.m.v. sp de hoeveelheid offspring wordt gegeven door so. De reguliere sampling space (Regular Sampling Space) heeft grootte sp en bevat alle offspring maar slechts een deel van alle parents. De uitgebreide sampling space (Enlarged Sampling Space) daarentegen bevat zowel alle offspring als alle parents.

o Regular sampling space: Oorspronkelijk werden de ouders afgedankt en direct vervangen door hun nageslacht (gener- ational replacement). Er kunnen ook alternatieve vervangings technieken gebruikt worden

3

Page 5: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

b.v. om t e voorkomen dat parents plaats moeten maken voor minder fitte offspring. Een van die alternatieven is de zgn. Crowding Strategy, hierbij word alleen die parent vervangen die de grootste gelijkenis met de offspring vertoond.

o Enlarged sampling space: Hierbij hebben parents en offspring beiden evenveel kans op over- leven. Twee bekende varianten zijn (p + A) selectie en (p, A) selectie. Bij (p + A)-selectie worden de p parents voor de volgende generatie gekozen uit de p parents in de huideige generatie plus de A offspring. Bij (p,A) selectie gebruikt men alleen de p beste offspring voor de volgende generatie. In het laatste geval moet dus gelden dat p < A. Het grootste voordeel van het gebruik van de uitgebreide sampling space is dat het genetische algoritme beter wordt naarmate men de crssover en mutation rate laat toenemen.

ad 2) Sample Mechanism: T.a.v. het sample mechanisme zijn er 3 verschillende benaderingen bekend:

a - Stochastic sampling

b - Deterministic sampling

c - Mixed sampling

a - Stochastic Sampling: Algemene aanpak is dat er zoiets als een survival probability wordt bepaald op basis van de fitheid (doelfunctie waarde) van het chromosoom. Deze survival probability wordt dan vervolgens ge- bruikt in het selectie proces.

voorbeeld 1 Proportionele of roulette wheel sampling: De survival probability wordt bepaald als:

waarin fk de fitheid van het Le chromosoom voorsteld. M.b.v. de verkrgen waarden voor pk wordt nu een roulette wiel gemaakt waarmee de verschillende chromosomen worden ges- electeerd door het sp keer doen draaien van dit wiel.

voorbeeld 2 Stochastic universal sampling: Hierbij wordt op gelijkaardige manier als in voorbeeld 1 een roulette wiel gecreeerd. In tegenstelling tot voorbeeld 1 geeft men nu niet een keer een zwengel aan het wiel maar doet men dat slechts één keer met constante stapgrootte (27r/sp). De voor ieder chromosoom verwachte waarde is dan eenvoudigweg ek = sp ’ pk

Een belangrijk detail in het selectie mechanisme is het verbod op duplicate chromosomen. Dit verbod is gebaseerd op een tweetal overwegingen:

1. Enerzijds voorkomt men door dit verbod Ret ontstaan van superchromosomen die zouden leiden tot vroegtijdige convergentie.

2. Anderzijds waarborgt men op deze manier de diversiteit van de populatie waardoor meer informatie voor genetic search behouden blijft.

b - Deterministic Sampling: Over het algemeen geldt dat men bij deterministische sampling mechanismes de beste chromo- somen uit een populatie sp selecteerd t.b.v. voortplanting. (p, A) en ( p + A) zijn voorbeelden van een dergelijk mechanisme.

4

Page 6: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

c - Mixed sampling: Bij dergelijke sampling mechanismes worden stochasticsche en deterministische zoekmethoden gecombineerd. Een typisch voorbeeld van zo’n methode is de zgn. tournament selection. Hierbij kiest men op een random wijze een aantal chromosomen uit de populatie. Van de geselecteerde chromosomen kiste men dan vervolgens de beste uit t.b.v. reproductie. De hoeveelheid random getrokken chromosomen per keer noemt men de tournamenet size. Een typische waarde daarvoor is 2. Bij stochastic tournament selection worden de chromosomen die deelnemen aan een toernooi getrokken d.m.v. roulette wheel selection.

ad 3) Selection probability: Tot nu toe hebben we alleen nog maar te maken gehad met proportionele selectie, dat wil zeggen dat de seiection probabiiity voor ieder chromosoom direct gekoppeid werd met zijn ñtheid (doel- functie waarde). Aan een dergelijke manier van bepalen van de selection probability kleven een aantal nadelen. Zo bestaat in het eerste aantal generaties de kan op het ontstaan van superchro- mosomen die het zoekproces zullen gaan domineren. Daar staat dan weer tegenover dat men tegen het einde van het zoekproces als de zaak is geconvergeerd te maken krijgt met nagenoeg random search. Er zijn twee manieren om dergelijke problemen te voorkomen:

a - Scaling: Hierbij schaalt men de bepaalde doelfunctie waarden naar een bepaalde (positieve) waarde. De survival probability wordt vervolgens op deze geschaalde waarde gebaseerd.

b - Ranking: Hierbij kijkt men helemaal niet naar de functie waarden maar slechts naar de rangorde.

a - Scaling: Algemeen geldt dat de geschaalde fitness fk kan worden geschreven als een functie van de oor- spronkelijke fitness f k :

Er worden twee categorien van scaling onderscheiden namelijk:

0 Static scaling

0 Dynamic scaling

Bij die laatste variant kan men dan nog kiezen of men de schalingsparameters aanpast aan de sprei- ding van de fitness values of dat men deze parameters laat verlopen met het aantal beschouwde generaties. In het nuvolgende zullen een aantal verschillende technieken worden beschreven.

I Linear scaling:

fk = a . f k + b (3)

u. en v worden over het algemeer, zdar , ig gekmer, dat eer, ChrGmGsGGm var, gemiUde!de fitheid één opvolger krijgt, een bovengemiddeld fit chromosoom krijgt er meer en een minder dan gemiddeld chromosoom krijgt er minder. Let op! fk < O kan voorkomen.

I1 Dynamic linear scaling:

f k = U . f k + bt

Hierbij hangt de waarde van bt af van de generatie. Een mogelijke keuze is bt = - fmin.

(4)

5

Page 7: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

I11 a-truncation: Doel van deze methode is de linear scaling methode te verbeteren door probleem afhankelijke informatie op te nemen in de mapping:

f; = f k - ( f - c . a ) (5)

c is hierin een kleine integer waarde, a is de standaar deviatie van de populatie en f is de bijbe- horende gemiddelde waarde. Eventuele negatieve waarden voor fi worden op O gesteld. Voordeel van deze aanpak is dat door de schaalfactor te koppelen aan f en a de invloed van extreem slechte chromosomen wordt weggeschaald. Dergelijke chromosomen leiden normaliter tot een grote sprei- ding en derhalve een verlaging van de selectie druk.

IV Power law scaling:

a! is probleem afhankelijk. Voor a 4 O zal de sampling sterk op random search gaan lijken immers alle f k -+ 1. Voor a ~ l zullen de fitte chromosomen sneller de overhand krijgen. (Let op! hierbij is er vanuit gegaan dat f k > OV- of f k < O M . ) Een alternatieve variant is:

Hierbij zijn aannames t.a.v. de waarde van f k overbodig.

V Logarithmic scaling: Speciaal bedoeld voor het mappen van te minimaliseren doelfuncties.

f; = b - l o g ( h )

met b > (log(fk))max.

VI Windo wing : Hierbij wordt een moving baseline fN geintroduceerd:

f; = f k - f w (9)

w is hierin de windowfactor, een integer die ligt tussen de 2 en de 10. fut is de slechtste waarde voor f k uit de w voorgaande generaties. Door deze techniek te gebruiken zou men een meer constante selectie druk moeten kunnen bewerstelligen.

voorbeeld Stek twee chromosomen met fitheid 2 en 1. Het eerste chromosoom heeft in dit geval 2 maal zoveel nageslacht als het tweede. Door nu een constante factor bij deze fitheden op te tellen wordt dit verschil genivelleerd. 2+1=3 en 1+1=2 de verhouding in hoeveelheid nageslacht wordt nu dus 3:2 in plaats van 2:l.

VI1 Normalizing:

f k - fmin -k y fmaz - fmin + Y

f; =

met y een reeel getal ergens tussen de O en 1. doel van y is:

1. Het voorkomen van een nuldeling

2. het mogelijk maken van aanpassingen van het selectie gedrag van proportioneel naar random

Bij minimalisatie problemen dient:

f m a x - f k f y fmax - fmin + y f; =

6

Page 8: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

gebruikt te worden.

VI11 Boltzmann selection:

f k = e T

Naarmate T groeter is is de selectie druk lager.

b - Ranking: Bij ranking is selectie niet direct gekoppeld aan de fitheid van de chromosomen men gaat namelijk uit van de rangorde die heerst. Het meest fitte chromosoom is nummer 1 de slechtste variant is nummer laatst. Stel nu dat q de probability van het beste chromosoom is, linear ranking ziet er dan als volgt uit:

pk = q - ( k - l ) . r (13)

met T = 4-po S,-1 en qo de probabiliteit van het slechtste chromosoom. Behalve linear kent men ook exponential ranking:

pk = q-(l -q)"' (14)

q kan nu vrij gekozen worden. Naarmate men q groter kiste neemt de selction pressure toe. Een alternatieve variant is:

met q N 0.99. Het beste chromosoom krijgt dus een selection probability pk = 0.991-1 = 1 e n de slechtste pk = 0.99sp-1.

ad 4 Selective pressures: Het evolutie proces kan in een drietal categorein worden gescheiden:

1. Stabilizing selection: chromosomen met extreme waarden worden uitgeschakeld.

2. Directional selection: hierbij neemt de gemiddelde waarde van de populatie toe of af.

3. Disruptive selection: waarbij de nadruk komt te liggen op chromosomen met extreme waar- den en die van gemiddelde waarden worden uitgeschakeld.

Een voorbeeld van zo'n dispruptive selection method is de normalized by mean fitness function:

f L = I l fk -711 (16)

Experimenten lieten zien dat deze selectie methode eenvoudig het optimum van een speld in de hooiberg probleem kan vinden.

Behalve de hierboven behandelde "zuivere genetische algoritmes" zijn er ook nog een aantal hybride methoden op de markt. De eerste hybride methode die besproken wordt is Lamarckian optimization. Deze methode is gebaseerd op het idee van ene Jean Lamarck dat organismen zich aanpassen aan veranderende omstandigheden en dat deze aanpassingen door de volgende generatie ook weer overgenomen wor- den, er wordt dus informatie van generatie op generatie overgedragen. Voor genetische algoritmen betekend dit dat men op een of andere manier omgevings informatie van generatie op generatie over wil dragen. De manier waarop men dit heeft bewerkstelligd is door gebruik te maken van locale optimalisaties van chromosomen. Men neemt een chromosoom dat bepaald is door middel van bijvoorbeeld crossover. In plaats van nu simpelweg de bij dit chromosoom behorende func- tiewaarde te bepalen past men een optimalisatie toe, b.v. een lp-algoritme. Vervolgens wordt

7

Page 9: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

het geoptimaliseerde chromosoom weer terug gestopt in het genetische algoritme. Indien men te maken heeft met systeem responsies die een sterk stochastisch karakter bezitten kan men behalve de standaard optimalisatie methoden ook een genetisch algoritme toepassen maar dan op locaal niveau. Het tweede type hybride methode dat ter sprake komt is de memetic algorithms. Deze methode komt erop neer dat er een locale optimalisatie slag wordt toegepast op iedere offspring die ontstaat. In plaats van in een willekeurige populatie gaat men dan dus zoeken in een deelruimte van de totale ontwerpruimte namelijk die ruimte die bestaat uit alle gelocaliseerde locale optima. Combinatie en mutatie van de chromosomen die zich in deze ”geoptimaliseerde” populatie bevinden zal over het algemeen leiden tot offspring die zich niet meer binnen de beschreven deelruimte bevind. De locale optimalisatie methode kan er dan vervolgens voor zorgen de aldus ontstane proto-children worden gerepareerd zodanig dat zij wel weer deel uit gaan maken van de geoptimaliseerde deelruimte.

2 Constrained optimization problems In dit hoofdstuk worden toepassingen van GA’s gegeven op de volgende problemen:

1. unconstrained optimization

2. nonlinear programming

3. stochastic programming

4. goal programming

5. interval programming

2.1 Unconstrained Optimization

De problemen die beschouwd worden zijn allen van de vorm:

min f(z) s.t. 2 E R

Hierin is f de een of andere reeel doelfunctie en R de verzameling toegestane oplossingen (grenswaar- den voor de ontwerp variabelen).

Het punt z* is een locaal minimum voor F in R als er een 6 bestaat die groter is dan O zodanig dat f(z) 2 f(z*) V z E R die zich op een afstand kleiner dan e van z* bevinden. Voor een globaal minimum geldt: f(z) 2 f(z*) V z E s1 De voorwaarden waaraan een punt z moet vol- doen om een locaal minimum te zijn worden beschreven in termen van of(.) en H ( z ) (= V2f(z)).

Om te beschrijven op wat voor manier GA’s gebruikt kunnen worden om unconstrained optimiza- tion problemen aan te pakken wordt gebruik gemaakt van Ackley’s functie. Deze multimodale continue verlopende multimodale functie wordt gegeven door:

+ q + e min f(z) = = c1 . e - C , . d r n - e; .(cos(cs .si)+cos(cs .q))

s.t. -5 5 xj 5 5 j = 1 ,2 (18)

De in het boek aangehouden getalwaarden zijn:

cl = 20, c2 = 0.2, cg = 27r, e N 2.71282 (19)

Een afbeelding van deze functie is te zien in figuur 2.1. De eerste stap bij het gebruik van GA’s is het coderen. In dit geval wordt er gebruik gemaakt van reeele getallen codering (real number

8

Page 10: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

8

6

- 4

2

O 2

Figuur 3: Ackley's function

encoding). Hier is dat heel eenvoudig door simpelweg een kolom (of array) met daarin de ontwerp- parameters (xi en x2) te gebruiken.

Crossover wordt bewerkstelligd door middel van zgn. arithmetic crossover, hierbij worden twee nieuwe chromosomen gevormd uit twee oude door middel van lineaire combinatie.

o; = 211 + ( 1 - X ) - o 2

u; = o2 + (1 - A ) 'o1

waarbij X een random getal tussen de O en 1 is.

Mutaties worden aangebracht middels het principe van nonuniform mutation. Stel een bepaald chromosoom is geselecteerd als mutatie slachtoffer waarbij het ke gen zal worden verandert (er zal dus een o' ontstaan van de vorm o' = [XI 2 2 2 3 ... x; ... E N ] ) . De waarde die door het ke gen aan zal worden genomen wordt gekozen uit:

waarin 2: en 2; respectievelijk de onder- en bovengrens voor xk zijn. De functie A(t, y ) geeft een waarde die ligt tussen de O en y waarbij deze waarde naar O nadert naarmate t stijgt (t is het generatie getal, dus naarmate de generaties toenemen zal mutatie minder invloed krijgen).

A ( t , y ) = y . r . ( l - - ) t b

T

met r een random getal ergens tussen O en 1 en T het maximale aantal generaties dat is toegestaan.

De berekeningen zijn uitgevoerd met de instelling:

sp = 10, T = 1000, p , = 0.1, p , = 0.3 (23)

Het uiteindelijke resultaat was:

x; = - 2 - za = O en f(zT,xa) = -0.005456 (24)

9

Page 11: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

2.2 Nonlinear programming Nonlinear programming (oftewel constrained optimization) houdt zich bezig met problemen van de vorm:

min f(x) s.t. g&) 2 o, i = 1’2’ ...’ mi

hi(%) = O i = ml + i, ..., m (= ml + m2)

x € X (25)

X is het domien waarbinnen gezocht wordt naar dat punt waarvoor f(x) minimaal is en dat vol- doet aan de eisen uit gi (.) en hi (x) .

Het voornaamste probleem bij het toepassen van GA’s op problemen van deze vorm is dat men rekening moet houden met de opgelegde constraints. Omdat GA’s chromosomen aanpassen is het niet (altijd) direct duidelijk wat de gemaakte aanpassing betekend voor de functie waarden gi(x) en hi(.). Een aantal technieken om effectief met dit keuze probleem om te gaan zijn ontwikkeld en zullen nu besproken worden.

1. Rejecting Strategy Deze strategie komt erop neer dat men chromosomen die behoren bij niet-toelaatbare oplossin- gen simpelweg negeert (ofwel verwerpt). Voor convexe problemen werkt deze aanpak nog wel redelijk indien het toelaatbare gebied een groot deel van de totale oplossingsruimte beslaat. Men dient bij deze techniek wel bedacht te zijn op prolbemen die ermee te maken hebben dat (te-) veel oplossingen genegeerd moeten worden.

2. Repairing strategy Hierbij wordt een chromosoom behorende bij een niet-toelaatbare oplossing dusdanig aangepast dat er een wel toelaatbare oplossing ontstaat. Belangrijkste nadeel van deze aanpak is dat men voor elk probleem een nieuwe reparatie techniek moet bedenken. Heeft men die techniek t e pakken dan moet men nog een keuze maken: vervangen of niet vervangen van de oor- spronkelijke ontoelaatbare oplossing. De beste resultaten lijken te worden geleverd door een aanpak waarbij men 15% van de ontoelaatbare oplossingen vervangt door hun gerepareerde compaan.

3. Modifying genetic operator technique Hierbij is het de bedoelling dat men gebruik gaat maken van een of andere probleemafhanke- lijke representatie waarbij het al dan niet toelaatbaar zijn van een chromosoom direct kan worden afgelezen. De genoemde probleemafhankelijkheid is gelijk ook de grootte makke van deze techniek.

4. Penalty strategy De gedachte die achter deze aanpak schuilgaat is dat het zeer wel mogelijk is dat niet- toelaatbare oplossingen meer informatie over de ligging van de optimale wel toelaatbare oplossing bevatten dan toelaatbare oplossingen. Met name bij problemen waarbij het toelaat- bare deel van de oplossingsruimte klein is t.o.v. de (ontoelaatbare) rest kan dit voorkomen. Om deze idormatie niet verloren te laten gaan Eoet men deze ont,oelaat,bare oplossirigen ook mee kunnen nemen in het GA. Hoe deze aanpak verder in zijn werk gaat zal in het nuvolgende beschreven worden.

* Penatly functies in GA’s Zoals hierboven al werd beschreven hebben de penalty functies binnen GA’s een ander doel dan binnen de conventionele opltimalisatie methodieken. In dit geval draait het erom zoveel mogelijk informatie over het optimum te waarborgen binnen de populatie. De vraag is nu hoe moet de penalty functie gekozen worden om ervoor te zorgen dat er voldoende informatie

10

Page 12: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

vastgehouden wordt terwijl tegelijk de selectie druk op peil blijft.

Er zijn twee verschillende manieren om de penalty functie aan te brengen:

I - Sommatie:

ewaZ(x) = f(x) + p ( x )

waarbij:

p ( x ) = O p ( x ) > O voor alle andere gevallen

indien x toegestaan en

p(x) = 1 p(x) > 1 voor alle andere gevallen

indien x toegestaan en

(29)

De penalty functies die men aan kan brengen kunnen worden geclassificeerd op de manier die is weergegeven in figuur 4. Waar het uiteindelijk altijd op neer komt is dat de PF op

Penalty functies (PF)

/ 1 Variabele PF Constante PF / 1

variabele PF-mtio Beboeting van het overschnjden van de constraints / 1

/ Aanpassing op basis van het aantal doorlopen iteratie stappen (Dynamic Penalty)

Aanpassing op bitsis van de mate van overschrijding van de constraints (Naannale de overschrijding groter is zal de penally pressure toenemen)

Figuur 4: Classificatie binnen de aan te brengen penalty functies

één of andere manier de afstand van een ontoelaatbaar punt x tot het toelaatbare gebied in rekening brengt. Deze afstand kan op drie manieren vastgelegd worden:

0 De afstand van één enkele ontoelaatbare oplossing.

o De relatieve afstand van alle in de populatie voorkomende ontoelaatbare oplossingen.

0 De functie van de adaptieve penalty term.

Over het algemeen wordt voor de eerste methode gekozen.

Rehalve de hnvensta,a,nde onderverdeling ka.n er ook nog een onderverdeling in probleem- afhankelijk of niet probleem-afhankelijk gemaakt worden. De meeste PF-methoden zijn probleemafhankelij k.

Als laatste kent men dan nog een onderscheidt tussen parameterische en niet parameterische PF’s. De parameterische PF’s zijn over het algemeen probleem afhankelijk.

In het nuvolgende zullen een aantal veel binnen GA’s gebruikte penalty functie methoden worden besproken.

11

Page 13: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

a -

b -

c -

Homaifar &i & iai’s Method: Het beschouwde prolbeem was van de vorm:

min f (x) s.t. gi(z)>O, i = l , 2 , 3 ,..., m

De te evalueren functie voor dit probleem luidt:

evaZ(z) = f(z) + p ( z )

met:

p ( z ) = O indien z toegestaan en m

p(x) = rigis (z) voor alle andere gevallen (32) i=l

Hierin is ri een variabele penatly coëfficiënt voor de ie constraint. ri varieert met de mate waarin Si(.) = O overschreden wordt. Het is gebleken at de keuze voor ri grote invloed uitoefend op de kwliteite van de oplossing. Indien ri b.v. te groot gekozen wordt zal de gevolgde aanpak sterk op de rejection strategy gaan lijken. Joines & Houck’s method: Beschouwd werd:

min f (XI s.t. Si(.) > O, i = 1,2 ,3 ,..., ml

hi($) = O, i = ml + 1, ..., m (33)

(34)

De te evalueren functie luidde:

evaZ(z) = f(z) + p ( t , z)

waarbij p ( t , z) gegeven wordt door: m

’ p ( t , z ) = Pt” pf<.) (35) i=l

t is hierin het iteratie getyal en a en /3 zijn parameters met behulp waarvan de penalty value geschaald kan worden. De eigenlijke penalty term di(.) wordt gegeven door:

di(.) = O als 3: toelaatbaar = 11gi(z)II indien z ontoelaatbaar 1 5 i 5 ml = llhi(z)II indien z ontoelaatbaar ml + 1 5 i 5 m (36)

pt = C - t (37)

en:

met C een constante. Uit experimente bleek dat (evenals de voorgaande methode) deze methode erg gevoelig was voor de keuze van de 3 parameters (a, ,B en C). Met name de keuze voor C en a is kritisch, kiest men deze waarden te groot dan leidt dat tot te snelle dood van de ontoelaatbare oplossingen en dus tot voortijdige convergentie.

Ook zij beschouwden een probleem van de vorm: Micahlewicz & Attia’s method:

min f (XI s.t. gi(x) 2 O, i = 1,2,3, ..., mi

hi(.) = O, i = ml + 1, ..., m

De bijbehorende te evalueren functie luidde:

eval(z) = f(z) + p ( ~ , z)

12

Page 14: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

met p(r , z ) :

A is de verzameling actieve constraints die bestaat uit alle gelijkheden hi(.) en alle ongelijkheden Si(.) waarvoor geldt Si(.) > S met 6 de één of andere constante waarde. T wordt ook wel de temperatuur van het probleem genoemd. Aan het begin van het iteratie proces heeft r de waarde TO. Naarmate dit proces vordert laat men de temper- atuur geleidelijk dalen tot een "bevriezing~temperatuur'~ rf . Het gebruik van de term temperatuur duidt erop dat deze aanpak wat weg heeft van simulated anealling. De functie &(z) wordt overigens gegeven door:

d - Smith, Tate & Coite's method: Er gaan twee gedachten schuil achter deze aanpak. Om te beginnen zal de penalty func- tie gedurende het iteratie proces dynamisch geschaald worden afhankelijk van de beste oplossing tot dan toe gevonden. De tweede gedachte is dat men een soort band om het toelaatbare gebied legt waarbinnen de oplossingen als warm worden verondersteld. De NFT-waarde (Non Feasability Threshold) is daarbij de afstand die men aanhoudt.

Een en ander resulteerd in de volgende formulering. Beschouwd werd:

max f (XI s.t. gi(z) 5 bi, i = 172,3,...,m

De bijbehorende te evalueren functie luidt:

ewaZ(s) = f(z) + p ( z ) (43)

met:

hierin is a een parameter die bepalend is voor de waarde van de penalty factor. Abi(x) is de waarde van constraint overschrijding i en AbyEF is de bijbehorende NFT waarde. f f *eas is de doelfunctie waarde van de beste toelaatbare oplossing tot nu toe. f z l l is de unpenalized functiewaarde van de beste overall oplossing tot nu toe.

Beschouwd werd hetzelfde probleem als bij punt d, nu wordt echter de volgende functie geevalueerd:

e - Yokota, Gen, Ida & Taguchi's method:

ewaZ(z) = f ( z ) - p ( z ) (45) met:

(46)

en:

Abi(2) = max(O,gi(z) - bi) (47)

Abi(z) is dus wederom de waarde van de constraint overschrijding i. Deze aanpak kan opgevat worden als een speciaal geval van 4 waarbij de NFT voor constraint i gegeven wordt door AbyEF = bi. Dit is een voorbeeld van een niet peparameteriseerde met hode.

13

Page 15: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

f - Gen & Cheng’s method: Stel x is een chromosoom van populatie sp(t) . De maximale constraint overschrijding voor constraint i kan nu worden bepaald door voor elke x alle Abi(x) uit te rekenen en te rangschikken. Hiervan kan gebruik gemaakt worden door in e voor p ( z ) in te vullen:

met:

Abi(x) = max(O,gi(z) - bi) en:

Abyax = max(6, Abi(x)llx E sp( t ) )

(49)

Voordeel van deze aanpak boven e is dat nu de penalty ratio adaptief gewijzigd kan wor- den zodanig dat het behoud van informatie, de selectiedruk voor toelaatbare oplossin- gen, en het voorkomen van over-penalty beter gebalanceerd zijn.

Genetic Operators: Bij toepassing van GA’s op constrained optimization problems wordt vaak gebruik gemaakt van de zgn. real conding technique. Hierbij wordt een oplossing gecodeerd als een vector x bestaande uit reëele getallen. De verschillende genetische operatoren dienen aan deze manier van coderen aangepast t e worden. Een en ander heeft geleid tot drie verschillende klassen van operatoren:

1. Conventionele operatoren.

2. Arithmetical operatoren.

3. Direction Based operatoren.

ad 1) Conventionele operatoren: Deze operatoren zijn feitelijk niet veel meer dan uitgebreide versies van de al eerder beschreven binary operators:

+ Simple crossover: Dit is niet veel meer dan het in stukken hakken van vectoren en die stukken uit te wisselen om ze vervolgens weer aan elkaar te plakken.

-+ Random crossover: Methode 1: (Radcliffe) Flat crossover: Neem twee chromosomen als ouders. Bepaal het nieuwe chromosoom door voor elk gen van dat chromosoom een waarde te nemen die ligt tussen de waarden zoals die bij de ouders voorkomen. Neem hierbij aan dat een uniforme verdeling gevolgd wordt. Methode 2: (Eshelman & Shaffer) Blend crossover: Neem twee punten zodanig dat de twee ouders zich tussen deze twee punten in bevinden en bepaal, gebruik maken van deze punten het nieuwe chromosoom volgens dezelfde manier als in methode 1. De ouders worden in dit geval dus niet direct gebruikt.

+ Mutatie: Mutatie v m een chromosoom ~ a d t UewerksteEgc! U m r rmdem sek t i e ITELTI een 0 - - - 7 vpn 7 w --O .- h. De waarde van dit gen wordt vervolgens gekozen volgens een uniforme verdeling met grenzen xi en z: (de domein grenzen). Deze manier van muteren noemt men uniform mutation. Als men nu xk vervangt door Òf xi Òf x: spreekt men van boundary mutation. Gebruikt men i.p.v. xi en x: andere (arbitrair?) gekozen grenzen [ z k - l , xk+l] dan spreekt men van plain mutation.

ad 2) Arithmetical operators: Bij deze operatoren wordt gebruik gemaakt van het concept van lineaire combinatie van vectoren zoals dat ook wordt gebruikt binnen de convexe verzamelingen theorie.

14

Page 16: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

-+ Crossover: Algemeen geldt dat men het nieuwe chromosoom bepaald als zijnde een lineaire combinatie van de oude, dus:

A1 . 5 1 + A2 . 5 2 (51)

De vraag is nu hoe men de multiplicatoren moet kizen. Er wordt onderscheid gemaakt tussen 3 verschillende varianten.

a convexe combination waarbij:

A1 + x 2 = 1 (A, > 0x2 > O)

X I + A 2 = l ( A 1 , A 2 E R )

A1 +X2,Al ,A2 E R

b affine combination waarbij:

c linear combination waarbij:

Het verschil tussen de verschillende methoden wordt duidelijk gemaakt in figuur 2.2.

x2 1 linear hull = F? oplossingsruimte

fly \ affinehull

( 5 2 )

(53)

(54)

convex huiï >

XI

Figuur 5: Illustratie van het verschil tussen de verschillende vormen van arithmetic crossover

+ Dynamic mutation: Deze manier van mutateren werd reeds beschreven bij het voorbeeld van Ackleys functie.

ad 3) Direction Based operators: Hierbij wordt gebruik gemaakt van een benaderde gradient.

-+ Crossover: Nieuwe chromosomen worden bepaald volgens het volgende principe:

waarbij f(z2) 2 f(x1) indien men een maximalisatie probleem beschouwd en f(z2) 5 f ( ~ 1 )

indien men een minimalisatie probleem beschouwd. r is een random gekozen getal tussen O en 1.

rig htarrow Mutatie: Het nieuwe chromosoom wordt bepaald volgens:

5' = z + r . d

15

Page 17: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

met r een niet negatief random gekozen reëel getal. d is de benaderde zoekrichting bepaald volgens de benaderde gradient:

Indien men een maximalisatie probleem beschouwd gebruikt men de gradient richting zelf. Bij een te minimaliseren prbleem houdt men juist de tegengestelde richting aan.

2.3 Stochastic Programming In sommige gevallen heeft men te maken met random variabelen of parameters die fluctuaties van de doelfunctie tot gevolg hebben. Bij het optimaliseren van problemen waarbij zulke onzekerheden een rol spelen dient men met deze variabiliteit rekening te houden. Voordat we nader ingaan op de manier waarop een en ander in rekening kan worden gebracht vdgt eerst een ictïod-ùctie vâa de wiskundige beschrijving.

Beschouwd worden problemen van de vorm f (x, t), waarin x een vector bestaande uit een reeks van reëele variabelen is en 5 een vector bestaande uit een reeks van stochastische variabelen. Doordat E stochastisch is zal ook f(x, 5 ) stochastisch zijn, het is dan ook onzin om een optimalisatie probleem te formuleren in termen van f(x, E ) zelf, beter is het om gebruik te maken van de verwachte waarde: E [ f ( x , 5 ) ] . Het resulterende optimalisatie probleem luidt nu:

min E[f(x, 511 s.t. E[gi (x ,J )] 2 o, i = 1 , 2 ,..., mi

E[hi(x,5)] = O, i = ml + i ,..., m

Indien nu de verdelings en dichtheids functies van 5 bekend zijn en worden gegeven door respec- tievelijk: +(c) en @(J) dan kunnen de verwachte waarden berekend worden met:

i = 1,2, ..., mi

i = ml + 1, ..., m (59)

Bovenstaande integralen kunnen worden uitgerekend door gebruik te maken van Monte-Carlo simulatie methoden. Die methoden komen er grofweg op neer dat men maar wat doet. Men kiest aan de hand van een bepaalde continue distributie een aantal samplepunten. Voor ieder van die sample punten berekend men de functie waarde. Vervolgens sommeert men al die waarden en deelt het resulterende getal door de waarde van de som kansdichtheidsfunctie in ieder van die punte. Het getalletje wat men dan over houdt is een goede schatting van de waarde van de integraal. Voorbeeld: Stel Y is een random variabele die gegeven wordt door (ü - b)g(X) met X een variabele die zich hoircit aan een continue uniforme verdeling over het interval. [ü, b] gegeven door U ( a , b) . De verwachte waarde van Y is dan:

16

Page 18: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

met fx (x) de kansdichtheidsfunctie behorende bij de uniforme verdeling U(a , b). Voor een enkelvoudige integraal levert deze aanpak niet al teveel voordelen op, sterker nog er zijn legio methoden voorhan- den die op een efficientere manier nauwkeurigere oplossingen zullen opleveren. Als men echter te maken heeft met een probleem van hogere dimensie, d.w.z. een probleem met n ontwerpvariabe- len, dan blijkt de Monte-Carlo simulatie methode helemaal zo gek nog niet. De reden hiervoor schuilt hem in het feit dat de hoeveelheid samplepunten dat beschouwd dient te worden om een bepaalde nauwkeurigheid te halen onafhankelijk is van de dimensie van het probleem. We zijn, nu we deze methode kennen dus in staat om van elke willekeurige functie een schatting van de verwachte waarde te bepalen. De vraag die nu nog rest is hoe kunnen we deze methode inpassen in een genetisch algoritme. Hiervan staat een voorbeeld weergegeven in het boek. Waar het op neer komt is dat men alle functie evaluaties die men tot nu toe uitvoerde door simpelweg de ex- pliciete functies f(z) en g(x) uit te rekenen te vervangen door Monte-Carlo simulaties. Een leuk detail is nog wel de manier waarop men de selectie doorvoert. Dit gebeurt op de volgende manier. Eerst worden alle chromosomen gerangschikt van de slechtste in positie 1 tot de beste in positie n. Vervolgens worden er een drietal preferentie parameters p i , p2 en p3 gedefinieerd waarvoor geldt: (O < p i < pa < p3 < 1). Deze parameters worden gebruikt om de critische chromosomen U I , u2 en u3 te bepalen zodanig dat u1 = p l . popsize, u2 = p~ . popsize en u3 = p3 . popsize. Aan chromosoom u1 kent men vervolgens een fitheid toe die gelijk is aan e-’, chromosoom u2 krijgt een fitheid van 1 en chromosoom u3 krijgt een fitheid die gegeven wordt door 2 - e-’. De fitheid van de overige chromosomen kan worden berekend uit:

2.4 Nonlinear Goal Programming Nonlinear goal programming is een techniek die gebruikt wordt om multiobjective optimization problemen aan te pakken. Men maakt onderscheidt tussen twee typen problemen: de nonpreemp- tive problemen waarbij ieder doel dat gesteld is even zwaar meeweegt en de preemptive problemen waarbij men aan ieder doel een bepaald gewicht toe kent (prolbemen met meer gewicht wegen zwaarder mee). De formulering van een nonlinear goal programming probleem is vaak als volgt:

s.t. fi(x) +d; - d f = b. 2, i = 1 ,2 ,..., mo gi(x) 5 O, i = mo + 1, ..., ml hi(.) = O , i = ml + 1, ..., m

d,i,d: _> O , i = l 1 2 , . . . , m

met P k de ke preemptive voorkeur ( P k >> Pk+1 V k ) , d f de variabele die de overachievement van doel i representeerd, d; representeerd juist de underachievement. w& is het positieve gewicht dat men toekent aan d f voor de ke voorkeur Pk, wií is juist het negatieve gewicht dat men toekent aan dki voor de k“ voorkeur. x is de vector met ontwerpvariabelen, fi is de ie doelfunctie, gi is de ie ongelijkheid, hi is de ie gelijkheid, bi is de voor doel i gestelde waarde. q is het aantal voorkeuren, mo is het aantal doei constraints, ml is het aantal ongelijkheden en m2 is het aantal gelijkheden.

Voor wat betrefd de toepasbaarheid van GA’s op dit type van problemen verandert er niet zoveel in vergelijking met wat we hiervoor allemaal al gezien hebben. Het belangrijkste verschil is dat men nu als doelfunctie:

mo mo

z1 = ( w t í d : + w z d ; ) , ..., zq = (w&df + w s d ; ) i=l i=l

neemt , waarin ”lexmin” staat voor het lexiconografisch minimaliseren van de doelfunctie.

17

Page 19: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

2.5 Interval Programming Dit deel van het boek is dermate onduidelijk uitgelegd dat het onzinnig zou zijn om hier nog een samenvatting van proberen te maken. Het is beter om ergens een goed boek over Inerval Programming vandaan te halen en dat een keer door te lezen. Het idee dat hier gebruikt wordt is dat men op basis van de interval programming techniek een nieuw soort van doelfunctie opsteld waarop men dan weer lustig een GA kan loslaten.

3 Combinatorial optimization problems De in dit hoofdstuk gevolgde aanpak is sterk vergelijkbaar met die in het voorgaande hoofdstuk. Ook hier laat men voor een aantal typische problemen zien hoe men dit probleem wiskundig gezien dient te formuleren en op wat voor manier GA’s gebruikt kunnen worden om oplossingen van dit probleem te Sepden. E e t belmgrijkste vmr het, eigenlijke onderwerp (GA’s) is dat combina- torische optimalisatie problemen heel andere technieken gebruikt worden om crossover en mutatie te realiseren. Was het in het voorgaande hoofdstuk nog mogelijk om chromosomen op lineaire wijze met elkaar te combineren, hier kan dat niet meer omdat er strengere eisen worden gesteld aan de waarde van de verschillende ontwerpvariabelen. Bovendien is het dan ook nog eens zo dat bij een groot aantal van de hier beschouwde problemen moet worden voorkomen dat een bepaalde waarde meerdere keren in de oplossing voorkomt. De problemen zoals ik die zal gaan beschouwen kennen deze vervelende eigenschappen niet (of nauwelijks) en het is dan ook niet zo van belang om deze theorie helemaal te doorgronden. Belangrijkste is de observatie dat toepassen van GA’s op combinatorische optimalisatie problemen heel andere technieken vereist dan wanneer men met continue problemen van doen heeft.

18

Page 20: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

4 Twee toepassingen De hier beschreven toepassingen zijn als opgave gebruikt tijdens de EM-cursus Structural Opti- mization and Reliability zoals die is gegeven op 25, 26 en 27 oktober en l, 2 en 3 november 1999. De volledige matlab code zoals die gebruikt is bij het oplossen van beide problemen kan worden terug gevonden in appendix A.

4.1 Introduction In general one could say that genetic algorithms are stochastic optimization techniques based on principles from evolution theory.

A genetic algorithm starts of with a set of randomly chosen solutions. Such a set of solutions is called a population. Each individual member of the population is called a chromosome and symbolically represents a solution to the problem at hand. These chromosomes evolve through succesive iterations called generations. Each generation, the chromosomes within the population are evaluated resulting in some sort of measure of fitness. New chromosomes are then generated by means of either crossover (merging two chromosomes together) or mutation (random modification of a chromosome). These newly formed chromosomes are called offspring. After evaluating the fitness of the offspring, a new generation is formed by means of selection. This means that some of the chromosomes within the population and offspring are rejected. Wether or not a chromosome is rejected depends on the fitness value associated to it. Bottom line is that the fittest chromosomes are selected to form a new population. After this the process of crossover, mutation and selection starts again. After several generations, the algorithm converges to the best chromosome, which hopefully corresponds to the optimum (or some suboptimal) solution to the problem.

The following topics will be discussed in more detail below: representation, selection, crossover and mutation.

4.2 Representation There are several possible choices for the way in which a chromosome represents a solution. Here we use the so called real number encoding. A solution is simply represented by an array containing the value of the various design variables at hand. Suppose, for example, that one is dealing with an optimization problem with two design variables, in that case a chromosome would look like this:

z = ( 2 : ) Sticking to the rather biological style of nomenclature, each design variable can seen as a gen (hence the term ”genetical algorithm”).

4.3 Crossover The main point of applying crossover is that one wants to exploit knowledge of the solutions that have been obtained so far. The idea is that combining to good solutions together might res& ia an even better solution. Crossover, therefore, is in fact nothing but merging two different chro- mosomes together. The most straightforward way of doing this is illustrated in figure 6. The crossover point is selected randomly. Both chromosomes are cut up at this crossover point and the resulting set of ”heads” and ”tails” are simply merged together.

This way of applying crossover is very suitable if one is dealing with discrete design variables only. However, in case continuous design variables come into play one has to use more advanced methods. The method applied here stems from the field of convex set theory and simply comes

19

Page 21: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

randomIy cho7en crossover point

j parenr#i

[x i x2 x3, x4 x5 x6 x7]

/ i \ M

offspring#l [ x l x2 x3 y4 y5 y6 y71 [ y1 y2 y3 x4 x5 x6 x7 ] offspring#2

[y1 y2 y3 y4 y5 y6 y71

x offspring#l [ x l x2 x3 y4 y5 y2 y3 x4 x5 x6 x7 ] offspring#2

[ Y 1 6 parent #2

Figuur 6: Straightforward crossover.

down to convex combination of the (randomly) selected continuous design variables from both parents to a new one. In formula form this looks like this:

Z ( i ) o f f s p r i n g = W i ) p a r e n t l + (1 - 4 Z ( 4 x z r e n t 2 (65)

The first problem considered here (Ackiey ’s function) has onIy continuous design variables. The second problem (the valve spring) has a mixed design variable set, i.e. continuous as well as discrete design variables have to be dealt with. In the latter case a combination of both crossover strategies will be applied.

4.4 Mutation The main point of mutation is that one wants to prevent premature convergence of the process by continuing to explore the entire design space. The mechanism of mutation is, again, fairly straightforward. A chromosome present within the population at hand is selected. From this chromosome a single gen (or design variable when using real number encoding) is picked for mutation. Mutation is then applied by randomly changing the value of the gen at hand. When dealing with a discrete design variable this means that one randomly picks a value from a list of values allowed. In case one is confronted with a continuous design variable one can simply use a random convex combination of the lower and upper limit value.

4.5 Selection After generating the offspring by means of crossover and mutation, one has obtained an enlarged population (supposing that the offspring has been added to the original population). Selection is the mechanism which cuts down this population to its original size. This means that some of the chromosomes will be rejected from the enlarged population. In order to decide which chro- mosomes have to be rejected from the population one has to have some sort of measure of fitness. For optimization problems, this measure of fittness can be determined by evaluating the objective function using the solutions present within the population. Those solutions that give poor results will be rejected from the enlarged population, whereas the ones that give relativelly good results will stay in. After finishing the process of selection one has obtained a new generation and thing can start all over again, i.e. crossover, mutation, selection etc.

Next two examples will be considered which ought to iiiustrate some of the main characteristics of genetic algorithms. First Ackley’s function will be considered.

4.6 Ackley’s function A 3 D graphical representation of this function can be obtained from matlab by simply typing plotackl. The resulting plot clearly illustrates the multimodal character of this function. Due to this problem characteristic, the chances of premature convergence are rather large when using (more) conventional optimization techniques such as SLP or SQP. Genetic algorithms however,

20

Page 22: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

can deal with this multimodal problem property. In order to prove this just type mainackl in the matlab environment.

Two input values are required now. First of all the crossover rate, this number relates the popu- lation size at hand to the number of offspring to be generated by means of crossover. A crossover rate of 0.1 means that the number of offspring generated by means of crossover will be 10% of the original population size. However, the number of offspring generated in this way always has to be even because of the fact that two parents are combined to two offspring. This means that if one is dealing with a population size 10 and a crossover rate of 0.1 the number of offspring generated will be 2 (1 after all isn’t an option). The second input value required is the mutation rate, this number relates the population size at hand to the number of offspring generated by means of mutation. A mutation rate of 0.1 means that the number of offspring generated by means of mutation will be 10% of the original population size.

Now try several values for both the crossover rate and the mutation rate (for example, O, 0.1, 0.2 and 0.3) and try to figure out what this means for the output of the genetic algorithm. Do however, bear in mind that genetic algorithms are stochastic optimization techniques. This means that two runs of a genetic algorithm do not necessarilly have to result in the same optimal solution.

4.7 Valve spring The second problem considered is the one of the valve spring. In this problem one has to deal with both, continuous as well as discrete, design variables. One of the advantages of genetic algoritms is that this mixed variable character of the problem can be dealt with. In the problem at hand, the mean winding diameter (D), the unloaded spring length (LO) and the spring length at closed valve position are continuous design variables. The remaining three design variables (wire diameter (d), number of active windings (n) and material type (mat)) are all discrete.

Another problem that has to be dealt with is the fact that constraints are present within this problem. When applying genetic algorithms to constrained optimization problems one usually uses penalty functions. The choice of how to apply the penalty has great upon the outcome of the result and is far from straightforward. This subject, however will not be covered here, see [i] for more details on the matter.

By typing the genopt the genetic algorithm is started. Again several input values are required, what these values are and what their meaning is should be clear from the information you get on the screen.

After ending the routine, the best design can be obtained by typing Best-design. The asso- ciated objective function and constraint values are returned when typing F-Best -design and G - B e s t -design respectivelly.

4.8 Korte toelichting De resultaten die men voor beide proefprobiemen vindt inàien men gebruik maakt van het door mij geimplementeerde genetische algoritme vergen enige verklaring om helemaal begrepen te wor- den.

Het doel van de opgave betreffende Ackley’s functie was te laten zien dat de convergentie snel- heid van het genetische algoritme beinvloed wordt door de twee genoemde parameters namelijk de crossover- en mutation-rate. Beide getallen kunnen ingesteld worden, en wat men ziet is dat men bij een hogere waarde van de mutation-rate in het begin van het oplossingsproces sneller zal convergeren. Een hogere crossover-rate zorgt ervoor dat de convergentie aan het eind van het

21

Page 23: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

algoritme sneller zal verlopen. Op zich is dit allemaal vrij logisch.

Bij een hoge mutation-rate gaat het oplossings proces sterk lijken op een zuiver stochastisch zoekproces. Men zal binnen korte tijd de volledige oplossingsruimte geexploreerd hebben. M.a.w. de kans dat men binnen korte tijd al in de buurt van het daadwerkelijke optimum komt is relatief groter bij een hogere mutation-rate.

Bij een hoge crossover-rate probeert men de kennis die men heeft over het probleem te exploiteren. Als men in de buurt van de eindoplossing komt zal men door bij een hoge crossover-rate meer combinaties van oplossingen in de buurt van deze eindoplossing proberen. Hierdoor zal de eindo- plossing sneller bereikt worden.

De opgave betreffende de klepveer had een ander doel namelijk dat men wilde laten zien dat gerietische algeritmen het, stadium dat, men er enkel Mickey Mouse problemen mee te lijf kon gaan zijn ontgroeid. Helaas bleek de fine-tuning van het algoritme dermate beroerd dat er nog een grote toevalsfactor zat in welke eindoplossing men uiteindelijk vond. De hoeveelheid tijd die ik beschikbaar had om deze opgave te bedenken en uit te werken was dermate beperkt dat het niet meer mogelijk was om het oplossingproces te tunen. Hier komt dan ook gelijk een belangrijke beperking van genetische algoritmen naar voren. De dynamica van het oplossingsproces is dermate onduidelijk dat het vaststellen of de ingestelde waarden voor de crossover- en mutation-rate effectief zijn niet op voorhand gedaan kan worden. Wat wel bleek is dat het met genetische algoritmen mogelijk is om mixed integer problemen aan te pakken.

Referenties [i] Gen, M. and Cheng, R., Genetic Algorithms and Engineering Design, John Wiley & Sons,

inc., New York, 1997

22

Page 24: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

A Matlab Code Hieronder volgt een volledig geprinte versie van de matlab code zoals die gebruikt is voor de twee beschreven toepassingen.

A.l Ackleys functie De mainackl . m file is het raamwerk waarbinnen alles plaatsvind, varierend van probleem initiatie tot het bepalen van de eindoplossing. De file ack1eys.m bevat het functionele verband zoals dat voor Ackleys functie geldt. De genetische operatoren (crossover, mutatie en selectie) zijn geimplementeerd d.m.v. een drietal files: crosackl .m, mutackl .m en selackl .m. M.b.v. de file plotackl .m kan men een 3d grafiek aanmaken die het functionele verband zoals dat door Ackleys functie wordt vastgelegd weergeeft.

A. 1.1 MAINACKL .M

% R. A . van Rooij , Sat Oct 23 1999 7 ................................ % filename: MAINACKL-M % objective: Implementation of the genetical algorithm as described by % Gen and Cheng in ’Genetic Algorithms and Engineering Design’ % for optimization of Ackleys function.

I ------

7 -------_------------------------ o ...........................

rand(’state’,sum(lOO*clock)); % sets the random number % generator to be used.

% Initiation of various relevant parameter values. xi= [I ; x2= [I ; exp= Cl ; noise-level=O; popsize=lOO; maxgen=500; b=1/16; disp(’ ’) disp(’ disp(’ cr=input ( ’> ; disp(’ ’) disp(’ disp(’ mr=input ( ’ ’ ; rrgion=le2; PL=region* [-i i

What crossover rate ought to be used ?’> Pick a value somewhere between O and I.’)

What mutation rate ought to be used ?’) Again, pick a value somewhere between O and I.’)

-1 11;

x1= Cl ; x2= [I ; F=CI; for i=l:l

P=region* (2*rand (2 , popsize) -1) ; for i=l:popsize

P(3 , i)=ackleys(P(l:2,i) ,noise-level) ;

23

Page 25: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

end P=sortrows (P y ,3) ; xi= CP(1,I) 1 ; x2= CP (2,2) 1 ; f unc= [P (3,l) 1 ; for gennum=l:maxgen

Oc=crosackl (P, cr) ; Om=mutackl(P,PL,mr,maxgen,gennum,b) ; P=selackl(P,Om,Oc,noise-level); xl=Cxl P(1,l)I; x2=cx2 P(2,l)l; func=[func P(3,I)l;

end xi= [Xi ;xi! ; x2= cx2 ; x21 ; F= [F; f uncl ;

end

% Grafica1 output xI=mean(Xi, I) ; x2=mean (X2, i> ; f unc=mean (F, I) ; f igure(1) semiïogy(l:size(func,2) ,abs(func)) ,grid xlabel ( y generat ion number y ) ylabel( >minimal function value ’) figure (2) subplot (2,1,1) semilogy(l:size(xl,2) ,abs(xl)) ,grid xlabel ( y generat ion number ) ylabel( >maximal absolute value of XI ) subplot (2,1,2) semilogy(1 :size(x2,2) ,abs(x2)) ,grid xlabel ( y generat ion number ’ ) ylabel( >maximal absolute value of x2 )

A.1.2 ACKLEYS.M

% % % % % % % % % % % % % % % %

R . A van Rooij , Sat Oct 23 1999

Filename: ACKLEYS.M objective: Determine the function values from Ackley’s function.

-___--___--___--__----__----_- -___--___---__---_----__----_-

Ackley’s fumtion is a continuous multimodal function in two variables, XI and x2. This function is described in more detail in the book by Gen and Cheng (“Genetic algorithms m d engineering design“) where it is use& to iliustrate the applicabillity of genetic algorithms for unconstrained optimization

~~

problems.

input: x =

noise-level=

A column containing the two coordinates that label a point in the design space. The relative noise level applied to the output values. A noise-level of 0.1 means that 10% noise is added to the output.

24

Page 26: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% Definition of the various constant values within Ackley's function. cl=20; c2=0.2; c3=2*pi ; e=exp(l) ;

% Calculating the output value. xi=x(l) ;x2=x(2) ; y=-cI*exp(-c~*sqrt((x~~~+x~~~)/~))-exp((cos(c~*x~)+cos(c~*x~))/~)+cI+e; r?~ise=noiss_level*rindn*y; y=y+noise;

A.1.3 CR0SACKL.M

% filename: % objective: % % % % % % input: % P = A 3*sp % % % %

CR0SACKL.M Function file associated to ACKLEYS.M. Objective of the function is to perform crossover on the given population. In this case so called arithmetic crossover is applied, this means that the offspring is generated by linear combination of two parents.

sized matrix columnwise containing the entire population of size sp. From this population parents will be picked. The third row of this matrix contains the calculated function values. Rows I and 2 contain the the actual coordinates.

% cr= The crossover rate. This number determines how much % offspring will be generated by means of crossover for a % given population size. The actual number of offspring % generated by means of crossover is the manifold of two % closest to cr*popsize.

% Oc= A matrix of size 2*"number of offspring" which columnwise % % % function call: % Oc=crosackl(P,cr) y . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

functioo [ûc]=crosackl(P, cr)

% output:

contains all offspring generated by means of crossover.

% Determine the population size form the input and calculate the number of % offspring to be generated. popsize=size (P, 2) ; offsize=ceil(cr*popsize/2); % The value for offsize determined here is half if off size"=O % of the number that is finally generated.

% Choose the parents in a random manner. parents=ceil(popsize*rand(2,off size)) ;

25

Page 27: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% Because each offspring needs two different parents, one has to check that % two different parents have been chosen. check=l ; while check"=O for i=l:offsize

check=O ;

parents (2, i)=ceil (lO*rand( I)) ; check=l ;

if parents(i,i)-parents(2,i)"=û

else

end end

ecc?

% Generating the offspring. This loop also includes a check upon wether or not % the generated offspring is a duplicate of a offspring that has already been % generated.

for i=l:offsize lambda=rand ; off l=P (I : 2 ,parents (1 , i)) + (I-lambda) *P (I : 2, parents (2, i) ) ; off 2=P (I : 2,parents (2, i>)+( 1-lambda) *P (I: 2,parents (1, i)) ; removel=0;remove2=0; for j=1: size(ûc,2)

removel=j

oc= c1 ;

if isequal (off i, Oc ( : , j) ) ==i

end if isequal(off 2,Oc( : ,2) )==i

end remove2=j

end if removel"=O & remove2"=0 if removel"=remove2

else

end

Oc ( : , [removei , remove21 )=[I ;

Oc(: ,removei)=[] ;

end oc=coc off1 off21 ;

end end

A.1.4 MUTACKL.M

% R.A. va0 Rooij, S2t Oct 23 1999

% filename: MüTACKL.M % doel: % % % % % boundary.

% .............................. ..............................

Function associated to ACKLEYS.M. Objective of this function is to perform mutation on the given population. In this case so called nonuniform mutation is applied, this means that the new value of the gen that's being mutated is randomly picked from the interval set by the lower and upper

26

Page 28: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% input: % P = A 3*sp sized matrix columnwise containing the entire % population of size sp. From this population parents will % be picked. The third row of this matrix contains the % calculated function values. Rows 1 and 2 contain the % the actual coordinates. % % % % mr= The mutation sate. This number determines how much % % given population size. % % % etc. etc.). % b= Non-unif ormity parameter. % % output:

PL= A 2*2 sized matrix containing the limit values of both design variables. Column 1 contains the lower boundary values and column 2 contains the upper boundary values.

offspring will be generated by means of mutation for a

magen= The maximum number of generations. gennw= The gelieration number (i = generation one, 2 = generation 2

% Om= A matrix of size 2*"number of offspring" which columnwise % % function call: % Om=mutackl(P,PL,mr,maxgen,gennum,b) % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . function [Om] =mutack1 (P , PL ,mr ,magen , gennum, b)

contains all offspring generated by means of mutation.

% Determine the population size from the input and calculate the number of % offspring to be generated by means of mutation. popsize=size(P,2) ; off size=ceil (mr*popsize) ; if off size"=O

% Choose the parents in a random manner. parents=ceil(popsize*rand(l,offsize));

% Generating the offspring. This loop also includes a check upon wether or not % the generated offspring is % generated. Om= [I ; for i=l:offsize gen=round (rand) 91 ; % r=rand; %

% lowup=round(rand) ; %

% off=~(I: 2,parents(i)) ; % if lowup==O

a duplicate of a offspring that has already been

randomly picking the gen to be mutated (1 or 2). Random factor determining the magnitude of mutation to be applied. Random selection for the mutation direction (towards the lower or the upper boundary). Picking the parent used for mutation

off (gen)=off (gen)-(off (gen)-PL(gen, i))*ranCi*(I-gennum/maxgen)^b;

off (gen)=off (gen)+(PL(gen,L)-off (gen))*rand*(l-gennum/maxgen)-b; else

end remove=O ; for j =i : size (Om, 2)

remove= j ; if isequai(off ,Om(: , j)>==i

end

27

Page 29: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

end if remove"=O

end Om=COm off1 ;

Om(: ,remove)=[I;

end end

A.1.5 SELACKL.M

% R.A. van Rooij, Sat Oct 23 1999 % _____________________----___--- % filename: SELACKL.M

% % % % crossover and mutation. % % input: % P = A 3*sp sized matrix columnwise containing the entire % population of size sp. From this population parents will % be picked. The third row of this matrix contains the % calculated function values. Rows 1 and 2 contain the % the actual coordinates. % % % % % % output: % % % function call: % P=selackl(P,Om,Oc,noise-level) y _____________________---___---_ function P=selackl(P,Om,Oc,noise_level)

-__--____-_______--_-----------

objective: L ~ n c t i m file zssociated to WCKLEYS.M. Objective of this function is to select the best chromosomes from the original population and the offspring generated by crossover and mutation. The selected chromosomes will serve as the population for the oext cycle of

Om= A matrix of size 2*(mr*popsize) containing the offspring

Oc= A matrix of size 2*(cr*popsize) containing the offspring generated by means of mutation.

generated by means of crossover. noise-level= The noise level as applied to the ackleys function.

P = A 3*sp sized matrix containing the new population.

_________________--___---_ o

popsize=size (P , 2) ; offspring= [Om Ocl ; for i=i: size(off spring,2)

end P= [P off spring] ; P=sortrows (P ) ,3) ) : P=P(: ,í:popsize);

offspring(3,i)=ackleys(offspring(l:2,i),noise~level~;

A. i .6 PL0TACKL.M

% R.A. van Rooij, Sat Oct 3 1 99 y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

% filename : PLOTACKL . M % objective: Generate a 3-D graph showing Ackleys function in a certain % subspace of its two design variables.

28

Page 30: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

noise-level=O; X1=-5:0.1:5; X2=-5:0.1:5; F=O ; for i=i:size(Xi,2) xl=Xl (i) ; for j=i:size(X2,2) x2=X2 (j ; F (i, j 2 =ackleys ( [xi j x2] ,aaoise-level) ;

end end

figure(i), surf(X2,Xl,F),title('Ackleys function') xlabel('x2') ,ylabel( '~1') ,ylabel( 'function value')

A.2 Valvespring probleem De opbouw van de opgave over de klepveer binnen matlab lijkt sterk op die van Ackleys functie. Ook hier is sprake van een mainfile die alles vanaf de initiatie tot en met de grafische weergave van het verloop van het oplossings proces in zich herbergt, genopt .m. Bij de probleem initial- isatie moeten een aantal parameters vastgelegd worden, deze waarden zijn verzameld in de file geninput .m. De respons van de klepveer (zowel voor wat betrefd de verschillende doelfuncties als voor de verschillende constraints) kan worden bepaald m.b.v. de file genspring.m. De ver- schillende operatoren zoals die binnen een genetisch algoritme voorkomen (in dit geval behalve crossover, mutation en selection ook penalization (constraint probleem!)) zijn ook nu weer vast- gelegd in de vorm van afzonderlijke files, namelijk: crossover .m, mutation.m, se1ection.m en pena1ize.m. De files diameters .m, windings.m en matpar.m zijn drie data files waar relevante info aangaande de mogelijke diameters, wikkelingen en materiaal parameters in zijn opgeslagen. De file bestdesign.m zorgt er continu voor dat de best bepaalde oplossing ook daadwerkelijk be- waard blijft. Tot slot is er dan nog de file taumax .m die gebruikt wordt om de maximale spanning in het materiaal uit te rekenen.

A.2.1 ~~~~~~~M

% % % % % % % % % % %

%

filelime: gen0pt.m f iletype : main objective: Main f i l e to be used f o r optimization of the valve spring problem as presented in the EM-course "Structural Optimization and Reliability".

Throw away all old data clear all

29

Page 31: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% I n i t i a l i s a t i o n of t h e problem disp(’ ’) disp( ’>>>> I n i t i a l i s a t i o n <<<<’) d i s p ( > ’> disp( d i s p o disp(’ 2 -> material weight (kg) ’) d i sp (> d isp( ’ d i sp( ’ disp(’ disp(’ d i sp( ’ 8 -> Shear stress (N/m-2>’) Ftype=input ( ’ ) ; geninput ; disp(’ ’1 disp(’ ’> disp( ’ Enter t h e number of offspr ing t o be generated by mutation: ’) mutnum= input ( ’ ’ ) ; disp(’ ’1 disp(’ The number of of fspr ing t o be generated by means of crossover ’) disp(’ should always be an even number s ince combinations have t o be ’1 disp( ’ made. Now en te r t h e number of offspr ing t o be generated by ’) disp( ’ means of crossover: ’) crossnum=input ( ’ ) ;

What goal funct ion do you want t o be used f o r optimization: ’ ) 1 -> spring material volume (m-3)’)

3 -> bui ld i n volume = pi/4*D^2*LI (m^3)>) 4 -> projected bui ld i n area = D*LI (m-2)’) 5 -> material cos t of spr ing (euro)>> 6 -> manufacturing cost of spr ing (euro)’) 7 -> a x i a l s t i f f n e s s (N/m)>)

% Analysis of t h e i n i t i a l population d isp( ’> diSP(’>>>> Analysis of i n i t i a l population <<<<’) disp(’ ’> F=C1; G=C1; f o r i = l : p s

[f y g] =genspring (p ( i y : ) y Ft ype y Dv y h y p l y ph y nm y ncamf ac) ; F=[F;f] ; G=CG;gI ;

end index=f ind (F>O) ; Fnorm=min (F ( index) ) ; F=F/Fnorm;

% Penal iz ing cons t ra in t v io la t ions disp!’ ’) d i sp ( ’ >>>> Penal izat ion <<<< ’ ) disp( ’ ’> pen=penalize (F y G) ; Fpen=F+pen;

% Determining t h e bes t design d isp( ’ ’) diSP(’>>>> Determining which is the bes t design <<<<’) disp( ’ ’> Best-design= [I ;

30

Page 32: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

FwBest-design=le99; G-Best-design= [I ; [Best-design,F-Best-design,G-Best-design]=bestdesign(pen,F,G,p,Best-design,F-Best-designyG-:

BD= [I ; FB= [I ; GB= [I ; it erat ion=l ; % MAIN LOOP

while iteration<=5Q00 % Selection % disp(’ ’) X % disp(> ’)

----

disp(’>>>> Selection of the best designs <<<<>)

[p, F , G ,Fpen, pen] =selection(p ,F ,G ,Fpen, pen) ;

% Crossover % disp(> ’) % disp(>>>>> Crossover <<<<’) % disp(> ’>

cross-off=crossover(p,crossnum);

% Mutation % disp(> ’) % disp( ’>>>> Mutation <<<<’) % disp(> ’)

mutate-of f =mutation(p y vlb, vub ,mutnum) ;

% Analysis of the offspring % disp(’ ’> % % disp(’ ’)

off spring=[cross-off ;mutate-off1 ; Foff=[] ; Gaff=[] ; for i=i : size (off spring, i)

disp(’>>>> Analysis of the offspring <<<<’)

[f of f , gof f] =genspring(of f spring(i , : ) ,Ftype ,Dv, h ,pl ,ph,m,ncamfac) ; Foff=[Foff ;foff] ; Goff=[Goff ;goff] ; % index=f ind(Fof f > O ) ; % Fof f =Fof f (index) ; % Goff=Goff (index, :) ; % offspring=offspring(index,:);

end Foff=Foff/FnorIn;

% Penalizing constraint violations of the offspring % disp(> ’) % disp( ’>>>> Penalization <<<<>) % disp(> ’)

pen-off=penalize(Foff,Goff); Foffpen=Foff+pen-off;

31

Page 33: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% Adding the offspring t o the population F=[F;Foff] ; G= [G;Goff I ; pen= [pen; pen-of fl ; Fpen= [Fpen; Fof f pen] ; p=[p;offspringl ;

% Determining the best design % disp(’ ’) % % disp(’ ’)

diSP(’>>>> Determining which is the best design <<<cy)

[Best~design,F~Best~design,G~Best_design~=bestdesi~(pen,F,G,p,Best~design,F~Best~design,G~

BI= [ni;Best-desigli! ; FB=[FB;F-Best-design1 ; GB= [GB; G-Best-design] ;

it er at ion=it er at ion+l ; % Raising the iteration number with 1

end %FB=FB*Fnorm; F-Best-design=F-Best-design*Fnorm;

figure ( 1 ) semilogy(FB(5:size(FB,l)), ’O-’)

figure (2) subplot (2,3,1) ,plot (GB (5 : size (GB, 1) ,I> , ’O-’) ,title ( ’gl ’ subplot (2,3,2) ,plot (GB (5 : size (GB , 1) ,2) , o- ’ ) ,title ( ’g2’) subplot (2,3,3) ,plot (GB(5 : size (GB, 1) ,3), ’0- ’ ) ,title( ’g3’ ) subplot (2,3,4) ,plot (GB(5: size(GB, 1) ,4), ’O-’) ,title( ’g4’) subplot (2,3,5) ,plot (GB(5: size (GB, I) ,5), ’o- ’),title( ’g5 ’ ) subplot (2,3,6) ,plot (GB(5: size (GB, 1) ,SI, ’O-’ ) ,title( ’ge ’ )

A.2.2 GEN1NPUT.M

% Program geninput.m % Input for valve spring problem. rand(’state’,sum(IOO*clock));

ps = 10;

if Ftype ==1

elseif Ftype == 2

elseif Ftype == 3

elseif Ftype == 4

elseif Ftype == 5

elseif Ftype == 6

elseif Ftype == 7

% sets the random number % generator to be used.

% specifies the population size % Fixed design parameters:

disp(’ F = sprvol : spring material volume (m-3) ’)

disp( ’ F = mspsisg: material weight (kg) ’1

disp(’ F = bldvol : build in volume = pi/4*D*2*LI (m-3)’)

disp(’ F = bldarea: projected build in area = D*Ll (m-2)’)

disp(’ F = matcost: material cost of spring (euro)’)

disp(’ F = mancost: manufacturing cost of spring (euro)’)

disp(’ F = k : axial stiffness (N-m)’)

Page 34: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

e l s e i f Ftype == 8

end; d i sp ( ] F = Tau2 : Shear s t r e s s (N/m-2)’)

% disp( ’ Dv: Nominal valve diameter (m) ]) Dv = 0.032; % . . . . . . . . . . . . . . . . . . . . . . . . .

% disp( ’ h: L i f t of valve (m) ’) h = 0.008; % . . . . . . . . . . . . . . . . . . . . . . . . .

% d i s p ( ] p l : Minimum equivalent valve pressure at closed valve (N/m^2)]) p l = 0.8*100000; % <<<<<<<<<<<<<<<<<<<

disp(] ph: Minimim eqi i ivahnt valve pressure a t half opened valve (N/m^2)]) ph = 3.0*100000; % <<<<<<<<<<<<<<<<<<<

% d i s p ( ] nm: Motor speed (revolut ions per second)]) nm = 80; % <<<<<<<<<<<<<<<<<<<

% d i s p ( ] ncamfac: Ratio spr ing eigen freqency t o cam frequemcy (-1’) ncamfac = 13; % <<<<<<<<<<<<<<<<<<<

% Design varables: % D (= x(1)) : Mean winding diameter (m) . % d (= x(2)) : Wire diameter (m). % LO(= x(3)) : Unloaded spr ing length (m). % n (= x(4)) : Number of ac t ive windings (-). % % mat(= x(6)) : Code f o r material type (-).

L1(= x(5)) : Spring length a t closed valve posi t ion (m).

% d i sp ( ’ Lower bounds design va r i ab le s : ] ) v lb = cO.025 0.001 0.020 2.5 0.020 I] ] ; % <<<<<<<<<<<<<<<

% d i sp ( ’ Upper bounds design var iab les : ’ ) vub = c0.050 0.008 0.120 19.5 0.060 4 1 7 ; % <<<<<<<<<<<<<<<

% d i sp ( I n i t i a l population: ’) p=zeros(ps,6) ; f o r i = l : p s

p ( i , l ) = vlb(l)+rand*vub(l); p ( i , 2) = diameters (rand) ; p ( i , 3) = vlb (3) +rand*vub (3) ; p ( i , 4) = windings (rand) ; p ( i , 5 ) = vlb(5)+rmd*vub(5); p ( i , 6 ) = ceil(4*rand);

%end input sp r . m end

A.2.3 GENSPR1NG.M

% Function genspring.m funct ion [F ,g] =genspring (x ,Ftype ,Dv , h, p l , ph , nm,ncamf ac) ; % Computes object ive function and cons t ra in ts fo r valve spr ing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

33

Page 35: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% SI-Units: m, N(ewtons), s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Input: % x : Vector of design var iab les . % % Fixed design parameters:

For meaning see under l o c a l var iab les .

% Ftype: Code f o r type % % % % % %

%

% h : % p i : % % % ph: % % % % nm:

Y < Y

% Dv:

=1: F = sprvol : =2: F = mspring: =3: F = bldvol : =4: F = bldarea: =5: F = matcost: =6: F = mancost: =7: F = k =8: F = Tau2 :

of object ive funct ion (-). spring mater ia l volume (m-3). material weight (kg). bui ld i n volume = pi/4*De2*Ll (m-3). projected bui ld i n area = D*L1 (m-2). mater ia l cost of spr ing (euro). manufacturing cost of spring (euro). axial s t i f f n e s s (bJ-asi).

shear s t r e s s (N/m^2) Nominal valve diameter (m). L i f t of valve (m). Minimum equivalent valve pressure at closed valve (N/m^2). Minimum spring force required t o prevent leakage and t o reduce bouncing of valve on the seat. Minimum equivalent valve pressure at half opened valve (N/m^2). A t about half opened valve valve accelerat ion is maximum. Minimum spring force is necessary t o enforce t h e rocker t o fol low t h e cam. Maximum motor speed (revolutions per second).

% % %

% F : Value object ive function ( sca l a r ) . % g : Vector of constraint values.

ncamfac: Factor at which lowest eigenfrequency of spr ing must be above cycle frequency of valve t o avoid excessive v ibra t ion (-). Note t h a t speed of cam shaf t is half motor speed.

% output:

% Local va r i ab le names: % % % % % % % % % % % % x % % % % % % % %

Design varables: D (= x(1) ) : Mean winding diameter (m). d (= x(2) ) : Wire diameter (m). LO(= x (3) ) : Unloaded spr ing length (m). n (= x(4) ) : Number of ac t ive windings (-). Li(= x(5) ) : Spring length a t closed valve posi t ion (m). mat(= x(6)) : Code f o r material type (-).

E : Young’s modulus (N/m-2). G : Shear modulus (N/M^2). ne: Number of ex t r a windings f o r spr ing ends. matprice: Pr ice wire material (euro/kg). bldprice: Pr ice pes un i t bui ld i n volume (=bidvol) (euro/m^3) sprvol : Spring material volume (m-3). mspring: Material weight (kg). bldvol : Build i n volume = pi/4*D^2*Ll (m-3). bldarea: Projected bui ld i n area = D*L1 (m-2). matcost: Material cost of spr ing (euro). mancost : Manufacturing cost of spr ing (euro).

k : axial spr ing s t i f f n e s s (N/m).

Further l o c a l var iables:

.....

34

Page 36: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% % Sa: Total free length (m) between windings at maximum spring compression. % This length is necessary to avoid nonlinear spring behaviour at % end of compression, and to allow some extra dynamic deflections % of the windings due to impact loading. % % L2: length of spring at opened valve position (m). % AV: Nominal valve area (m-2). % F1: Spring force at closed valve position (N) . % % Fh: Spring force at half open valve (N). % % F2: Spring force at fully opened valve (N). % Tzu1 : Actual shear stress at closed valve ( W m - 2 ) - % Tau2 : Actual shear stress at fully opened valve (N/m-2). % Taul2max : Upper limit of shear stress for infinite fatique % live at Tau1 as lowest shear stress during cycle (N/m̂ 2). % w % Wahlfac: Factor to account for non-uniform shear stress due to % curvature of wire. % freql: First eigenfrequency of spring (Hz). % freqlb: Lower bound of first eigenfrequency (Hz). % hcrit: % u : (=G/E) Ratio of shear and Young’s moduli (-).

Lb: blocking length of spring (m).

Lmin: minimum length of spring at maximum compression (m).

Flmin: Minimum needed spring force at closed valve (N).

Fhmin: Minimum needed spring force at half opened valve (N).

: Winding ratio D/d (-).

Critical valve lift with respect to buckling of spring (m).

% Assignment of design variable names: D=x(l) ; d=x(2) ; LO=x(3) ; n=x(4) ; Ll=x(5) ; mat=x(6) ;

% Some material dependent parameters of wire material: [E ,G ,ne ,matprice, bldprice] =matpar (mat ,d) ;

% Spring material volume (m-3): sprvol = pi*D*pi/4*d̂ 2*(n+ne);

% Material (stee1)weight (kg) : mspring = sprvol*7850;

% Build in volume (m-3): bldvol = pi/4*De2*L1;

% Projected build in area = D*Ll (m-2). bldarea = D*L1;

% Material cost of spring (euro). matcost = mspring*matprice;

% Manufacturing cost of spring (euro). mancost = matcost + bldvol*bldprice;

% Axial spring stiffness: k=G*d-4/ (8*D̂ 3*n) ;

% Blocking length of spring: Lb = (n + ne)*l.O2*d; % wire may be 2% above nominal value

35

Page 37: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% Total f r e e length between windings [??I: Sa = 1.5*(0.0015*D^2/d + O.l*d)*n;

% Minimum length of spring: Lmin = Lb + Sa;

% Spring length at f u l l opened valve: L2 = L 1 - h ;

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Scaled cons t ra in t with respect t o spring length:

g ( i ) = Lmin/L2 - 1 ; ., . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Nominal valve area:

AV = Dv^2*pi/4;

% Minimum needed spr ing force at closed valve: Flmin = Av*pl;

% Actual spr ing force at closed valve: F 1 = (LO - Ll)*k;

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Scaled cons t ra in t with respect t o spring force at % closed valve:

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . g(2) = Flmin/Fl - 1 ;

% Minimum needed spr ing force at half opened valve: Fhmin = Av*ph;

% Actual spr ing force a t half opened valve: Fh = (LO - L 1 + h/2)*k;

% Actual spr ing force at f u l l y opened valve: F2 = (LO - L 1 + h)*k;

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Scaled cons t ra in t with respect t o spr ing force at % half opened valve:

g(3) = Fhmin/Fh - 1 ; % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

% Winding r a t i o : w = D/d;

% W a h l f a c t o r Wahlfac = 1 + 5/(4*w) + 7/ (8*~-2) + l/w^3;

% Shear stress at closed valve: Tau1 = Wahlf ac*S*Fl*D/ (pi*d^3) ;

36

Page 38: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

% Shear s t r e s s a t f u l l y opened valve: Tau2 = Wahlf ac*8*F2*D/ (pi*d-3) ;

% Upper l i m i t of shear stress: Taul2max = taumax(mat , Taul, d) ;

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Scaled cons t ra in t with respect t o maximum shear s t r e s s

g(4) = Tau2/Taul2max - 1; % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

% F i r s t eigenfrequency of spr ing; formula is va l id f o r :J steel compression spr ings with f ixed ends E??] :

f r e q l = 363*d/ (n*D-2) ;

% Lower bound of eigenfrequency: f r eq lb = ncamfac*nm/Z;

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Scaled cons t ra in t with respect t o f i r s t eigenfrequency

g(5) = 1 - f r eq l / f r eq lb ; % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % It is assumed t h a t buckling does not occur. The spr ing % diameter - unloaded length r a t i o s tays f a r from c r i t i c a l . % For t h i s reason buckling w i l l not be considered. % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Constraint r e l a t i n g t h e spr ing length i n the unloaded and % closed valve pos i t ion t o one another.

g(G)=Ll/LO-l; % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % Defini t ion of object ive function:

i f Ftype == 1 F = sprvol ;

e l s e i f Ftype == 2 F = mspring;

e l s e i f Ftype == 3 F = bldvol;

e l s e i f Ftype == 4 F = bldarea;

e l s e i f Ftype == 5 F = matcost;

e l s e i f Ftype == 6 F = mancost;

e l s e i f Ftype == 7 F = k ;

e l s e i f Ftype == 8 F=Tau2 ;

37

Page 39: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

end ; % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . %end of fspring1.m

A .2.4 CRO SS0VER.M

% R . A . van Rooij 19-Oct-1999 y -_________________--______ % % filename: crossover.m % fiìetype: function file % objective: Combining the selected designs to new designs. % % Input: p e l : Selected population members for crossover and % mutation.

% output: cross-off: Offspring generated via crossover.

* -___________-______-______

%

% . . . . . . . . . . . . . . . . . . . . . . . . . .

function cross-off=crossover(psel,crossnum);

popsize=size(psel,i); cross-of f = Cl ; for i=l:crossnum/2

pickl=psel(ceil(O. 5*popsize*rand), :) ; pick2=psel(ceil(0.5*popsize*rand), :) ; while pickl==pick2

end crosspoint=ceil(6*rand); if crosspoint==l

pick2=psel(ceil(0.5*popsize*rand),:);

lambda=O .25 ; off springl= [lambda*pickl (i)+( l-lambda) *pick2(1) pickl (2: 6)] ; off spr ing2= [ lambda*pick2 ( 1) + ( 1-lambda) *pick1 ( 1) pick2 (2 : 6) 1 ;

elseif crosspoint==2 offspringl=[pickl(l:2) off spring2= [pick2 (1 : 2)

lambda=0.25; off springl=[pickl(l:2) off spring2= [pick2 (1 : 2)

off springl= [pickl (I : 3) off spring2= [pick2 (I : 3)

lambda=O. 25 ; off springl= [pickl (I : 4) off spring2= [pick2 (1 : 4)

off springl=[pickl(l:5) off spring2= [pick2(1:5)

elseif crosspoint==3

elseif crosspoint==4

elseif crosspoint==5

else

end out l=O ; out2=0;

pick2 (3 : 611 ; pickl (3 : 611 ;

lambda*pickl(3)+(l-lambda)*pick2(3) pick2(4:6)] ; lambda*pick2(3)+(l-lambda)*pickl(3) pick1(4:6)] ;

pick2(4:6)] ; pickl (4:6)1 ;

lambda*pickl(5)+(l-lambda)*pick2(5) pick2(6)] ; lambda*pick2(5)+(l-lambda)*pickl(5) pickl(6)l;

pick2(6)] ; pickl (611 ;

38

Page 40: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

for j=l:popsize if off springi==psel (j , : )

end if off spring2==psel (j , : )

end

outl=l;

out 2=1;

end if size(cross-off , i ) > O ;

for j=l:size(cross-off,I) if off springi==cross-of f (j , : )

outl=l; end if off spring2==cross_of f (j , : 1

end out2=1;

end end if offspringl==offspring2

end if outl==O

end if out2==0

end

out 1=1;

cross-off = [cross-of f ; off spring11 ;

cross-off = [cross-of f ; off spring21 ;

end

A.2.5 MUTATI0N.M

% R.A. van Rooij 19-Oct-1999 y . . . . . . . . . . . . . . . . . . . . . . . . . .

% % filename : mutat ion. m % filetype: function file % objective: Mutating the selected designs to new designs. % % input: psel: Selected population members for crossover and % mutation. % % % output: mutate-off: Offspring generated via crossover. y . . . . . . . . . . . . . . . . . . . . . . . . . .

mutnum: Number offspring to be generated by mutation.

function mutate-oÏÏ=mu.t;a.tion(psei,v~D,vub,mutnumj;

popsize=size (psei, 1) ; mutate-of f = [I ; for i=l:mutnum

pick=psel(ceil(0.5*popsize*rand),:); mutpoint=ceil(6*rand) ; if mutpoint==l

lambda=rand ;

39

Page 41: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

of €spring= [lambda*vlb(l)+( 1-lambda) *vub(l) pick(2: 6)l; elseif mutpoint==Z

1 ambda=r and ; offspring=[pick(l) diameters(1ambda) pick(3:6)1;

elseif mutpoint==3 lambda=rand ; offspring=[pick(l:2) lambda*vlb(3)+(l-lambda)*vub(3) pick(4:6)] ;

elseif mutpoint==4 lambda=rand ; offspring=[pick(l:3) windings(1ambda) pick(5:6)1;

elseif mutpoint==5 lambda=rand ; offspring=[pick(l:4) lambda*vlb(5)+(l-lambda) *vub(5) pick(6)I ;

elseif mntpoint==6 lambda=r and ; offspring=[pick(l:5) ceil(4*lambda)] ;

end out=0; for j =I : popsize

if off spring==psel (j , : )

end out=l;

end if size (mutate-off , i)-=O

for j=í:size(mutate-off,i) if off spring==mutate-of f (j , : )

end out=l;

end end if out==O mutate-off-[mutate-off; offspring] ;

end end

A.2.6 SELECTI0N.M

% R.A. van Rooij 19-Oct-1999 y . . . . . . . . . . . . . . . . . . . . . . . . . .

% % filename: se1ection.m % f iletype: function f iìe % objective: Performing selection on t--e popu-ation of designs % as obtained each iteration of the gen0pt.m file.

% input: p: Population of designs. % Fpen: Vector containing the penalized function values. % pen: Penalty factors. % % output: psel: Selected members of the population that will % be used for crossover and mutation.

%

y . . . . . . . . . . . . . . . . . . . . . . . . . .

function [p , F , G , Fpen ,pen] =select ion (p , F, G , Fpen, pen)

40

Page 42: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

popsize=lO;

index=f ind(F>O) ; p=p (index, : ) ; F=F (index, : ) ; G=G (index, : ) ; pen=pen (index, : ) ; Fpen=Fpen (index, : ) ;

index=f ind (pen>O) ; Fpen(index)=Fpen(index)*le20;

[Fgen index] =sort (Fpen) J

p=p (index, : ) ; F=F (index, : ) ; G=G (index, : ; pen=pen (index, : ;

if size(F, 1) >popsize p=p(l:popsize, :); F=F(l:popsize,:); G=G(l:popsize,:); pen=pen(l:popsize,:); Fpen=Fpen(l:popsize,:);

end

A.2.7 PENAL1ZE.M

% % % % % % % % % % % % % % x % x % % % % %

filename: pena1ize.m filetype: function file objective: Penalizing valve spring designs that result in constraint violations. This function is called by the gen0pt.m file, and is associated to the valve spring optimization problem presented in the EM-course "Structural Optimization and Reliability".

input: F: Vector containing the objective function values for each of the designs in the considered population.

G: Matrix containing the constraint values for each of the designs in the considered populat ion.

output: pen: Penalty function value.

function [pen]=penalize(F,G)

41

Page 43: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

if size(F,l)"=O r=lOOO*ones (6 y 1) ; % [i00 1 10 1000 100000 100001 ; for i=l : size (G y I)

pen( i , i) =O ; for j=1:6

if G(i, j > > O

end pen( i, l)=pen(i, l)+r ( j ) *G(i, j) - (1/4) ;

end end

pen= i1 ; else

end

A.2.8 D1AMETERS.M

% R.A. van Rooij 19-Oct-1999 y . . . . . . . . . . . . . . . . . . . . . . . . . .

% % filename : diameters .m % fiïetype: function file % objective: To be used in combination with mutati0n.m. This function returns % the value of the wire diameter based on the randomly chose value % of 'number'.

% input: number: Random value between O and I.

% output: d: The wire diameter related to 'number>.

%

%

% y . . . . . . . . . . . . . . . . . . . . . . . . . .

function d=diameters (number)

options=ie-3* [i .O 1.1 1.25 1.4 1.6 1.8 2.0 2.25 2.5 2.8 3.2 3 . 6 4.0 4.5 5.0 5.6 6.3 7.0 8.01; d=options(ceil(number*size(options,l)));

42

Page 44: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

A.2.9 WPN3DINGS.M

% R.A. van Rooij 19-Oct-1999 y . . . . . . . . . . . . . . . . . . . . . . . . . .

% % filename : windings .m % filetype: function file % objective: To be used in combination with mutati0n.m. This function returns % % ' number ' . % % input: number: Random value between O and I. % % output: n: The number of windings related to 'number'. % y . . . . . . . . . . . . . . . . . . . . . . . . . .

the number of windings based on the randomly chosen value of

function n=windings(number)

options= [2 : 191 '+O. 5; n=options(ceil(number*size(options,l)));

A.2.10 MATPAR.M

% Function matpar.m

% Input: % % = 1: Bild 7.30a (not shot-peened) [i]. % = 2: Bild 7.30b (shot-peened) [i]. % = 3: Bild 7.31a (not shot-peened) [i]. % = 4: Bild 7.31a (shot-peened) [i].

% [l] W. Steinhilper, R. Roeper: Maschinen- und Konstruktions- % elemente, Vo1.3, Springer-Lehrbuch, 1994. % d : Spring wire diameter (m).

% % G : Shear modulus (N/m-2), see Roloff/Matek, Table 10.1 % ne: Number of end windings % matprice: material price (euro/kg); estimated standard price for % 10 mm wire; price for 1 mm wire is 5 times higher; in

function [E, G ,ne ,matprice ,bldprice] = matpar (matcode , d) ;

matcode: code for material type (all cold winded springs):

. . . . . . . . . . . %

% output: E : Young's modulus (N/m-2), see Roloff/Matek, Table 10.1

% between values % bldprice: price per unit % t2max: Maximum allowable

are linearly interpolated. build in volme (euro/m"3); fancy price! shear stress for infinite fatique life (N/m̂ 2).

if matcode ==1 E = 0.206E+12; G = 0.0815E+12; ne = 2; matprice = 12; matprice = matprice*(l + (10 - 1000*d)*4/9) ; bldprice = 100000;

% standard for cold winded springs. % estimated price for 10 mm wire (euro/kg).

% interpolated price. % fancy price: 100 euro/liter build in volume.

elseif matcode ==2

43

Page 45: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

E = 0.206E+12; G = 0.0815E+12; ne = 2; matprice = 14; matprice = matprice*(l + (10 - 1000*d)*4/9); bldprice = 100000;

elseif matcode ==3 E = 0.206E+12; G = 0.0815E+12; ne = 2; matprice = 8; matprice = matprice*(l + (10 - 1000*d)*4/9); bldprice = 100000;

elseif matcode ==4 E = 0.206E+12; G = 0.0815E+12; me = 2; matprice = 10; matprice = matprice*(l + (IO - 1000*d)*4/9); bldprice = 100000;

% standard for cold winded springs. % estimated price for 10 mm wire (euro/kg).

% interpolated price. % fancy price: 100 euro/liter build in volume.

% standard for cold winded springs. % estimated price for 10 mm wire (euro/kg).

% interpolated price. % fancy price: 100 euro/liter build in volume.

% standard for cold winded springs. % estimated price for 10 mm wire (euro/kg).

% interpolated price. % fancy price: 100 euro/liter build in volume.

end ;

%end of function matpar.m

A.2.11 BESTDES1GN.M

% R.A. van Rooij 19-Oct-1999 y . . . . . . . . . . . . . . . . . . . . . . . . . .

% % filename: bestdesign.m % filetype: function file % objective: determinating the best design present obtained % by the genetic algorithm.

% input: pen: Vector containing the penalty terms for each % design within the population as obtained from % the penalize function. % F: Vector containing the function values associated % to the designs in the current population. % p: Matrix containing the current population. % Best-des: The best design found so far. % F-Best-des: Function value belonging to Best-design.

% output: Best-des: The best design found so far. This vector % % % current popuìat ion. % F-Best-des: Function value belonging to the Best-design. % y . . . . . . . . . . . . . . . . . . . . . . . . . .

%

%

changes only in case a better design compared to the input value aas been detecteà within the

if size(pen, i)-=O

44

Page 46: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

index=f ind(pen==O) ; if size (index , 1) ==O

[f -Best-des , index-best-des] =min(pen) ; f-Best-des=f-Best-des*le20;

if f-Best-des < F-Best-des

% This transformation ought to prevent % over feasible designs.

Best-des=p(index-best-des, :) ; F-Best-des=f-Best-des;

G-Best-des=G(index-best-des,:); end

F=F (index , : ) ; p=p(index, :); G=G(ilidex, :> j

[f -Best-des, index] =min(F) ; if f-Best-des < F-Best-des

Best-des=p(index,:); F-Best-des=f-Best-des;

else

G-Best-des=G(index, :) ; end

end end

A.2.12 TAUMAX.M

% Function taumax.m

% Input: % % = 1: Bild 7.30a (not shot-peened) [ll. % = 2: Bild 7.30b (shot-peened) cl]. % = 3: Bild 7.31a (not shot-peened) [i]. % = 4: Bild 7.31a (shot-peened) [i].

% [i] W. Steinhilper, R . Roeper: Maschinen- und Konstruktions- % elemente, Vo1.3, Springer-Lehrbuch, 1994. % % d : Spring wire diameter (m).

%

function[t2max] = taumax(matcode, taul, d);

matcode: code for material type (all cold winde springs):

% ...........

taul: Lowest shear stress during dynamic loding cycle (N/m-2).

% output: t2max: Maximum allowable shear stress for infinite fatique life (N/m-2).

% Method: interpolation in given tabel (extracted from given graphs).

if matcode ==I dvec = [I 2 3 5 8 101; % wire diameter in mm t0vec = [490 450 417 386 336 3141; t2mvec = [1120 1010 917 806 708 6581; dh = 1000*d; % wire diameter dh in mm tl = tau1/1000000; tO = interpol(dh, 6, dvec, t0vec); t2m = interpol(dh, 6, dvec, t2mvec); t2 = tO + t1*(1200-490)/955; if t2 > t2m, t2 = t2m; end; t2max = t2*1000000; % max. shear stress in N/m-2

% stress vaiues in N/mm^2 % stress values in N/mm^2

% stress value ti in N/mm^2 % stress value tO in N/mm^2 % stress value t2m in N/mm^2

% stress value t2 in N/mm^2

% infeas:

45

Page 47: Samenvatting: Genetic Algorithms & Engineering Design plus ...Samenvatting: "Genetic Algorithms & Engineering Design" plus twee toepassingen Citation for published version (APA): Rooij,

e l s e i f matcode ==2 dvec = [i 2 3 5 8 101; % wire diameter i n mm t0vec = E584 544 500 464 422 3951; t2mvec = Cl128 1018 920 808 708 6583;

% s t r e s s values i n N/mm-2 % s t r e s s values i n N/mm 2̂

dh = 1000*d; ti = tau1/1000000; t O = interpol(&, 6 , dvec, t0vec); t2m = interpol(dh, 6, dvec, t2mvec); t 2 = t O + tl*(1200-584)/815; i f t 2 > t2m, t 2 = t2m; end; t2max = t2*1000000;

dvec = [i 2 3 5 81; t0vec = 1368 345 330 295 2651; t2mvec = [883 813 770 714 6421; dh = 1000*d; ti = tau1/1000000; t O = interpol(&, 5, dvec, t0vec); t2m = interpol(dh, 5 , dvec, t2mvec) ; t 2 = t O + t1*(1000-368)/835; i f t 2 > t2m, t 2 = t2m; end; t2max = t2*1000000;

dvec = [i 2 3 5 81; tûvec = [474 444 415 385 3641; t2mvec = [890 822 770 708 6501; dh = 1000*d; ti = tau1/1000000; t O = interpol(&, 5, dvec, t0vec); t2m = interpol(&, 5 , dvec, t2mvec) ; t 2 = t O + t1*(1000-474)/684; if t 2 > t2m, t 2 = t2m; end; t2max = t2*1000000;

e l s e i f matcode ==3

e l s e i f matcode ==4

end ;

% wire diameter dh i n mm % s t r e s s value tl i n N/mm-2 % s t r e s s value t O i n N/mm 2̂ % s t r e s s value t2m i n N/mm-2

% s t r e s s value t 2 i n N/mm 2̂ % max. shear stress i n N/m^2

% wire diameter i n mm % s t r e s s values i n N/mm 2̂ % s t r e s s values i n N/mm-2 % wire diameter dh i n mm % s t r e s s value ti i n N/mm 2̂ % s t r e s s value t O i n N/mm 2̂ % s t r e s s value t2m i n N/mm 2̂

% s t r e s s value t 2 i n N/mm 2̂ % max. shear stress i n N/m^2

% wire diameter i n mm % s t r e s s values i n N/mm 2̂ % s t r e s s values i n N/mm 2̂ % wire diameter dh i n mm % s t r e s s value ti i n N/mm-2 % s t r e s s value t O i n N/mm-2 % s t r e s s value t2m i n N/mm 2̂

% s t r e s s value t 2 i n N/mm-2 % max. shear stress i n N/m-2

%end of funct ion taumax.m

46