genetic algorithm made easy

© All Rights Reserved

8 views

genetic algorithm made easy

© All Rights Reserved

- Bolt Pattern Optimization
- 期末考題_Example
- catia part01
- Genetic Algorithms and the Automatic Generation of Test Data
- Index
- Rotkowitz-when is a Linear Controller Optimal
- 64675
- Sugarcane
- IJETTCS-2013-06-25-150
- A Non-Revisiting Genetic Algorithm for Optimizing Numeric Multi-Dimensional Functions
- 10.1.1.41
- studwall_ga_optim
- 3
- Activity Modes Selection for Project Crashing Through Deterministic Simulation
- 4
- c 0333017026
- Survey on Software Remodularization Techniques
- Portfolio Selection by the Means of Cuckoo
- assaf-ga
- Optimization on Seawater Desulfurization Efficiency

You are on page 1of 20

Study of Matlab

Dr. Somnath Pan

Study of

MATLAB

CONTENT

DC motor armature

control..1-4

Introduction to Genetic

Algorithm4-8

Study of Genetic Algorithm using

MATLAB...9-18

Simulation of DC motor could be simply done in MATLAB. The electrical

and mechanical circuit parameters are fed to the software. Then the transfer

function is written. Once the transfer function is properly written, by using the

syntax, LTIview we could get the graph of the performance of motor. This, we

could simulate the motor on software rather than testing the motor directly with

different parameters for finding desired parameters.

TRANSFER FUNCTION

For controlling the speed of the motor by varying the applied voltage. The

speed vs time graph of feeding the software with a transfer function obtained by

taking the speed as output and applied voltage as input. And the syntax LTIview

is used.

If the change in speed with other variable, the appropriate transfer function

has to be taken with the desired variable as input.

Example:

In this example, Im taking two transfer functions, one with speed as output

and other with position as output, while both of them have applied voltage as input.

>> R=2;

1

>> L=0.5;

>> Fo=0.1;

>> Kb=0.1;

>> Kt=0.2;

>> J=0.02;

>> h=tf(Kt,[L*J (R*J)+(Fo*L) (R*Fo)+(Kt*Kb)

h=

0.2

-----------------------0.01 s^2 + 0.09 s + 0.22

h1 =

0.2

---------------------------0.01 s^3 + 0.09 s^2 + 0.22 s

Continuous-time transfer function.

>> ltiview('step',h,h1)

The blue line in the plot represents the function h(speed as output), while the green line represents the function

h1(position as output).

>> bode(h,h1)

GENETIC ALGORITHM

As early as 1962, John Holland's work on adaptive systems laid the

foundation for later developments.

By the 1975, the publication of the book

Early to mid-1980s, genetic algorithms were being applied to a broad range of

subjects.

In 1992 John Koza has used genetic algorithm to evolve programs to perform

certain tasks. He called his method "genetic programming"(GP).

What is a Genetic Algorithm??

A genetic algorithm (or GA) is a search technique used in computing to find true

or approximate solutions to optimization and search problems.

4

(GA)s are a particular class of evolutionary algorithms that use techniques

inspired by evolutionary biology such as inheritance, mutation, selection, and

crossover (also called recombination).

The evolution usually starts from a population of randomly generated individuals

and happens in generations.

In each generation, the fitness of every individual in the population is evaluated,

multiple individuals are selected from the current population (based on their

fitness), and modified to form a new population.

The new population is used in the next iteration of the algorithm.

The algorithm terminates when either a maximum number of generations has

been produced, or a satisfactory fitness level has been reached for the population.

VOCABULARY

Individual - Any possible solution

Population - Group of all individuals

fitness)

Start with a large population of randomly generated attempted

solutions to a problem

Repeatedly do the following:

Evaluate each of the attempted solutions

(probabilistically) keep a subset of the best solutions

Use these solutions to generate a new population

Quit when you have a satisfactory solution (or you run out of time)

EXAMPLE

Suppose we want to maximize the number of ones in a string of l

binary digits

Is it a trivial problem?

It may seem so because we know the answer in advance

However, we can think of it as maximizing the number of correct answers,

each encoded by 1, to l yes/no difficult questions.

An individual is encoded (naturally) as a string of l binary digits

The fitness f of a candidate solution to the MAXONE problem is the number of

ones in its genetic code

We start with a population of n random strings. Suppose that l = 10 and n = 6.

We toss a fair coin 60 times and get the following initial population:

s1 = 1111010101 f (s1) = 7

s2 = 0111000101 f (s2) = 5

s3 = 1110110101 f (s3) = 7

s4 = 0100010011 f (s4) = 4

s5 = 1110111101 f (s5) = 8

s6 = 0100110000 f (s6) = 3

STEP 1: SELECTION

We randomly (using a biased coin) select a subset of the individuals based on their

fitness:

Suppose that, after performing selection, we get the following population:

s1` = 1111010101 (s1)

s2` = 1110110101 (s3)

s3` = 1110111101 (s5)

6

s5` = 0100010011 (s4)

s6` = 1110111101 (s5)

STEP 2: CROSSOVER

Next we mate strings for crossover. For each couple we first decide (using some

pre-defined probability, for instance 0.6) whether to actually perform the

crossover or not

If we decide to actually perform crossover, we randomly extract the crossover

points, for instance 2 and 5

Crossover result:

Before crossover:

s1` = 1111010101 s2` = 1110110101

After crossover:

s1``= 1110110101 s2`` = 1111010101

STEP 3: MUTATION

The final step is to apply random mutations: for each bit that we are to copy to the

new population we allow a small probability of error (for instance 0.1)

Initial strings

After mutating

s1`` = 1110110101

s1``` = 1110100101

s2`` = 1111010101

s2``` = 1111110100

s3`` = 1110111101

s3``` = 1110101111

s4`` = 0111000101

s4``` = 0111000101

s5`` = 0100011101

s5``` = 0100011101

s6`` = 1110110011

s6``` = 1110110001

In one generation, the total population fitness changed from 34 to 37, thus

improved by ~9%

At this point, we go through the same process all over again, until a stopping

criterion is met

There are many different strategies to select the individuals to be copied over into

the next

Generation

Methods of Selection

1.

2.

3.

4.

5.

Roulette-wheel selection.

Elitist selection.

Fitness-proportionate selection.

Scaling selection.

Rank selection.

Genetic algorithm in

MATLAB

MATLAB has the option of solving problems using different optimization

tools like: bintprog, fgoalattain, fminbnd, fmincon, fminimax, fminsearch,

fminunc, fseminf, fsolve, fzero, and Genetic Algorithm procedures. MATLAB

offers syntaxes as well as tool box for using GA. Every parameter related to the

GA while solving the problem could be set customized, and desired values can be

set. Thought it is well known for its simplicity, GAs can be made even more

effective by and can be made apt for solving various problems by placing suitable

values for parameters like Population, Fitness scaling, Selection, Reproduction,

Mutation, Crossover, Migration, Constraint parameters, Hybrid function, Stopping

criteria, Plot functions, Output function, Display to command window, User

function evaluation.

The

population of

the genetic

algorithm could

be set as desired.

It sould be noted

that high value

of initial

poplation though

helpful for more

accurate

solution, it leads

to too many

calculations. While

low population

leads to very low

accurate solution.

coputer it is not. Because computer runs on progams, it can initialize random

values on its own. Selection option is useful for defining the method by which the

chromozomes for the population should be selected.

10

Sometimes the

fittest solution of

one generation

might be the best solution. By blindly involving it in crossover there may be

wastage of

solution. So to stop

the loss of such

solutions, the

fittest solution in

each generation is

kept aside from crossover. The number of chromosomes that should be spared from

crossover is selected by elite count.

11

12

There are many reason for GA to come to end. We can set few of the

parameters that involve the halting of Genetic Algorithm. We can limit the number

of generations,

time, minimum

fitness required.

plot option. Not just the result but also these parameters are helpful for the analysis

of the result. By observing this data one could get an idea about the status of the

GA and the status

of the result.

13

Examples:

14

For finding the minimum value of a function:

The function should be written in the editor as a function initializing .m file.

The .m file has to be saved in .m files folder, or else the program will not

work.

Open the optimizing toolbox.

Set the solver as genetic algorithm(GA).

The number of variables, lower bound, upper bound have to be

compulsorily filled.

Change other parameters in options if necessary.

And click the start button.

The GA stops and displays the result, when the process comes to a halt.

There could be various reasons for the process to come to a halt.

The value of the function at the result and the reason for the halting of the

process are shown in a dialog.

While the value of the final point comes beneath it.

15

Example:

Feed the software with the function through editor, whose minimum value

has to be identified. Here the function is:

Y = x^2

By setting different values of the GA parameters solution is found out.

16

17

The solution obtained is 0. While the value of the function at final point is

4.33403588142492E-10, and the reason for halting is average change in the fitness

value less than options.

Or the simply the minimum of the function could be found by using the syntax

ga.

Example:

>> [x,fval,exitflag]=ga(@test,1)

Optimization terminated: average change in the fitness value less than

options.TolFun.

x=

0.0122

fval =

1.4972e-04

exitflag =

1

@test is our function. Which should be given through editor.

1 is the number of variables.

x is the indicates the final point.

Fval is the value of the value of function at x.

Exitflag is the reason for the halting of the process.

18

19

- Bolt Pattern OptimizationUploaded byNitin Chandra
- 期末考題_ExampleUploaded byapi-26360835
- catia part01Uploaded bylulu
- Genetic Algorithms and the Automatic Generation of Test DataUploaded byhellboy.exe2970
- IndexUploaded byVageesha Shantha Veerabhadra Swamy
- Rotkowitz-when is a Linear Controller OptimalUploaded byNicolae Marinica
- 64675Uploaded byClaudio Woerle
- SugarcaneUploaded byPoommipat Tangkanjanasri
- IJETTCS-2013-06-25-150Uploaded byAnonymous vQrJlEN
- A Non-Revisiting Genetic Algorithm for Optimizing Numeric Multi-Dimensional FunctionsUploaded byAnonymous lVQ83F8mC
- 10.1.1.41Uploaded byPhani Kumar.b
- studwall_ga_optimUploaded bymlkn59
- 3Uploaded byAhmad Borham
- Activity Modes Selection for Project Crashing Through Deterministic SimulationUploaded byshridharhm
- 4Uploaded bysai101
- c 0333017026Uploaded byinventionjournals
- Survey on Software Remodularization TechniquesUploaded byInternational Journal of Research in Engineering and Technology
- Portfolio Selection by the Means of CuckooUploaded byAnonymous lVQ83F8mC
- assaf-gaUploaded byManoj Badoni
- Optimization on Seawater Desulfurization EfficiencyUploaded byYassine Lemsyeh
- Genetic AlgorithmUploaded byterminator91
- Evolved_to_win - Moshe Sipper - 2011Uploaded byalfiozzz
- i Shibu Chi 2003Uploaded byQazi Kamal
- optimization of friction welding parameters using friction weldingUploaded byNihas Noushad
- Applying Genetic Algorithm to Geometry Design OptimizationUploaded byshipwreckwave
- ets113Uploaded byaksagar22
- Design of a Production System Using Genetic AlgorithmUploaded bytimeking00
- Genetic PptUploaded byS.Durga
- An Optimal Approach for the Second Zone Time and Impedance Setting of Distance Relays- Kavehnia.pdfUploaded byandred
- ics-1327Uploaded byFaisal Akhtar

- Parshall FlumesUploaded byMohd Yasir Pilus
- 11-Es-29 Research Paper (1).PDFUploaded byBilal Shahid
- Household - Samplers - AmericanUploaded byThe 18th Century Material Culture Resource Center
- Tutorial on PSpiceUploaded byifakoya1
- Help With Traffic EngineeringUploaded byedwin_serpas2894
- alfa-laval-tj-tz-74-self-cleaning-version-rotary-jet-head---product-leaflet---ese00325.pdfUploaded byVils Arabadzhieva
- DIY Turntable With Amp Preamp and Buffer in WoodenUploaded bynofunclub
- Preparing And Presenting a Seminar – A Guide.Uploaded byAbhi Sharma
- 20110509 Support Functions Lean FundamentalsUploaded byDenise Cheung
- 19c Latent Heat of FusionUploaded byAndrae Tennant
- [Michael Brady, Robert Berwick] Computational Models of LenguageUploaded byAlgoritzmi
- WPCUploaded bycipte
- ThermE.pdfUploaded byEric Cook
- A Simple and Effective Mind Power TechniqueUploaded bychandrajack
- WIF2003 Team Project Report Guidelines 2019Uploaded byCallme E-one
- Partial Fraction exercise.pdfUploaded byChai Usajai Usajai
- 2013 Co-Op Report Preparation Guide(2)Uploaded byS S Nanthavarman Subramaniam
- Adsb Service LevelUploaded bybfathoni
- Weco Pneumatic Actuator Safety AlertUploaded byRafael Granado
- kupdf.com_kp-system-faq-kp-astrology.pdfUploaded byKetan Pandya
- PulsesUploaded byshani
- Cape Integrated Mathematics - SyllabusUploaded byRobert Edwards
- Java ThreadsUploaded byRupali Misri
- ELSEVIER Carburization of High-temperature Steels - A Simulation-based Ranking of Carburization ResistanceUploaded byMariaF1593
- Newff (Neural Network Toolbox)Uploaded bysouravaech1
- lm5116Uploaded byrmoscibd
- 4 Tcata AresUploaded byErika Jade
- Elec Coaching 1 ( From Villamor)Uploaded byJose Angelo E. Magat
- S88 WhitePaper BeginnersUploaded byikhsan_aeb
- DOC-20190508-WA0001.docxUploaded byhemant

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.