A . Davydov , D . Sokolov , F . Tsarev Scientific advisor – prof. A . Shalyto 2008

32
ГОСУДАРСТВЕННЫ Й УНИВЕРСИТЕТ Application of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem A. Davydov, D. Sokolov, F. Tsarev Scientific advisor – prof. A. Shalyto 2008

description

Application of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem. A . Davydov , D . Sokolov , F . Tsarev Scientific advisor – prof. A . Shalyto 2008. Automata based programming. Proposed in Russia in 1991 - PowerPoint PPT Presentation

Transcript of A . Davydov , D . Sokolov , F . Tsarev Scientific advisor – prof. A . Shalyto 2008

Page 1: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Application of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting

Mealy Automata in “Artificial Ant” Problem

A. Davydov, D. Sokolov, F. Tsarev

Scientific advisor – prof. A. Shalyto

2008

Page 2: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

2

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Automata based programming

Proposed in Russia in 1991 Software systems are developed

as well as automation of engineering (and other) process

Control system is a system of interacting finite state machines

Control System

Controlled Object

E, X2

Z X1

States Events and input variables Output events Finite state machine System of finite state

machines

Page 3: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

3

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Method advantages

Effective for systems with complicated behavior

Formal and understandable behavior description

Automatic code generation from transition diagrams

Possibility of program verificationProject documentation

Page 4: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

4

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Problem

The general difficulty in automata based programming is automata construction

In a majority of cases automata are designed manually

Heuristic automata construction is often very hard and time-consuming

The solution is to use genetic programming for automatic finite state machines generation

Page 5: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

5

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

“Artificial ant” problem

Torus – 32x32 89 cells with food 200 steps The locations of food

are fixed Goal is to create an ant

which can eat all food in 200 steps

Page 6: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

6

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

What ant can do?

Determine is there food in front of it Do one of these actions in one step:

step forward and eat food if it is in the next cell turn left turn right nothing

Page 7: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

7

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Finite state machine – method of ant description

Automaton with transition’s action (Mealy). Automaton with transition’s action (Moore). System (couple) of automata which interact by nesting

It is easy to create automata with many states

There is Mealy automaton with 5 states which allow to eat 81 units of food

2

3

45

1

F / M

!F / R

F / M

!F / R

!F / R

!F / R

!F / M

F / MF / M

F / M

Page 8: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

8

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Genetic Algorithms – 1

Jefferson D., Collins R., Cooper C., Dyer M., Flowers M., Korf R., Taylor C., Wang A. The Genesys System. 1992.

Coding automata to bit stringAutomaton with 13 states which solves this

problem

Page 9: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

9

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Genetic Algorithms – 2

Angeline P. J., Pollack J. Evolutionary Module Acquisition // Proceedings of the Second Annual Conference on Evolutionary Programming. 1993.

Coding automata to bit string + “freezing”Automaton with 11 states which solves this

problem in 193 steps

Page 10: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

10

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Genetic Algorithms – 3

Chambers L. D. Practical Handbook of Genetic Algorithms, Volume 3, Chapter 26, 6 – Algorithms to Improve the Convergence of a Genetic Algorithm with a Finite State Machine Genome. CRC Press, 1999.

Coding automata to bit string + canonical representation

Automaton with 8 states which solves this problem

Page 11: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

11

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Genetic Algorithms – 4

Tsarev F., Shalyto A. About construction of automata with minimal number of states for “Artificial ant” problem /Proceedings of X international conference of soft compitation and measurement. SPbETU “LETI”. Vol.2, 2007, pp. 88–91. (in Russian)

Genetic programming

Page 12: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

12

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Mealy automaton with 7 states

Two automata with 7 seven were created after exploring over 160 and 230 millions of automata 0

6

!F / R !F / M

F / M

F / M

!F / R

!F / R

F / M

!F / M

!F / M

F / M

F / M

F / M

F / M

!F / L

2

4

3

1

5

Page 13: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

13

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Problem

Only Mealy automata are discussed in all papers

Goal of this work – creating Moore automata and systems of interacting Mealy automata

Page 14: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

14

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Approach proposed – 1

Island genetic algorithmAutomaton = start state + description of

states + internal automatonState = two transitions + action in state (only

for Moore automata)Transitions = number of state to which this

transition leads + action (only for Mealy automaton)

Page 15: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

15

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Approach proposed – 2

class Automaton {

Transition[][] transitions;

int initialState;

Automaton nestedAutomaton;

char[] stateAction; // for Moore automata

}

Page 16: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

16

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Initial generation creation

A predefined number of automata (systems of automata) is randomly generated

All automata consists of the same number of states

Page 17: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

17

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Next generation creation – 1

ElitismFixed part of individuals move to next

generation For other individuals – tournament strategy.

Choose two pairs of individual, mutation or crossover with some probability is applied to best individuals of each pair

Page 18: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

18

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Next generation creation – 2

Evolution on island is independent from other islands

After fixed number of generation islands exchange fixed part of elite individuals

Page 19: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

19

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Moore automaton mutation

Change start stateChange one of state actionsChange the state to which one of the

transitions leadsChange transition condition

Page 20: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

20

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Mealy automata system mutation

Change start stateDelete (insert) transition (only for external

automaton)Change the state to which one of transitions

leadsChange transition action Internal automaton mutation

Page 21: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

21

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Moore automata crossover

Input: two individualsOutput: two individualsParents – P1 and P2Child – S1 and S2Start state: S1.is = P1.is and S2.is = P2.is, or

S1.is = P2.is and S2.is = P1.is

Page 22: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

22

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Transitions crossover

State i «There is food in front of ant» ↔ P1(i, 0)«There is no food in front of ant» ↔ P1(i, 1)Similarly: P2(i, 0), P2(i, 1), S1(i, 0), S1(i,1),

S2(i, 0), S2(i, 1)There are 4 variants for S1(i, 0), S1(i,1), S2(i,

0), S2(i, 1)

Page 23: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

23

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Four variants

i

i

i

i

i

i

i

i

i

i

P1

P2

S1

S2

S1

S1 S1

S2

S2

S2

ИЛИ

Page 24: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

24

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Systems of Mealy automata crossover

External automata – the same way as for Moore automata

Internal automaton – crossover is done with some probability

Page 25: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

25

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Fitness function for Moore automata

F – number of units of food which ant eats in

200 stepsT – number of step when ant eats last unit of

food

200

TF

Page 26: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

26

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Fitness function for systems of Moore automata

F – number of units of food which ant eats in 200

steps T – number of step when ant eats last unit of food Z – number of visited states in external automaton C – coefficient

ZCT

F *200

Page 27: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

27

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Generation mutation

After fixed number of generations there is “big” mutation

“Big” mutation – all individuals either change to mutants or change to randomly generated individuals

Page 28: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

28

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Adjustable parameters of genetic algorithm – 1

Number of islands Population size on an island Time between “big” mutations Part of islands which is destroyed in “big”

mutation Part of individuals which moves to next

generation Time to exchange of individual between islands

Page 29: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

29

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Adjustable parameters of genetic algorithm – 2

Number of exchangeable individualsParameters of small mutationParameters of crossoverRatio of “mutants”, randomly generated

individuals and “children”С – external automaton influence coefficient

Page 30: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

30

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Moore automaton

This automaton allows ant to eat all food in 198 steps

Page 31: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

31

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

System of pair nested automata

This automata system allows ant to eat 87 units of food in 198 steps

Page 32: A .  Davydov ,  D .  Sokolov ,  F .  Tsarev Scientific advisor  –  prof. A .  Shalyto 2008

A. Davydov, D. Sokolov, F. TsarevApplication of Genetic Algorithms for Construction of Moore Automaton and Systems of Interacting Mealy Automata in “Artificial Ant” Problem

32

ГОСУДАРСТВЕННЫЙУНИВЕРСИТЕТ

Thank you!

Thank you!