MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

43
MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for Learning Finite-State Machines Daniil Chivilikhin and Vladimir Ulyantsev National Research University of IT, Mechanics and Optics St. Petersburg, Russia Evolutionary and Combinatorial Optimization Track @ GECCO 2013 July 8, 2013

Transcript of MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Page 1: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

MuACOsm – A New Mutation-Based

Ant Colony Optimization Algorithm

for Learning Finite-State Machines

Daniil Chivilikhin and Vladimir Ulyantsev

National Research University of IT, Mechanics and Optics

St. Petersburg, Russia

Evolutionary and Combinatorial Optimization Track @ GECCO 2013

July 8, 2013

Page 2: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Motivation: Reliable software

• Systems with high cost of failure

– Energy industry

– Aircraft industry

– Space industry

– …

• We want to have reliable software

– Testing is not enough

– Verification is needed

ACO for Learning FSMs 2

Page 3: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Introduction (1)

• Automated software engineering

• Model-driven development

• Automata-based programming

Software

specificationModel Code

ACO for Learning FSMs 3

Page 4: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Introduction (2)

Software

specificationModel Code

Finite-state

machine

ACO for Learning FSMs 4

Page 5: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Finite-State Machine

• S – set of states

• s0 ∈ S – initial state

• Σ – set of input events

• Δ – set of output actions

• δ: S×Σ→S – transition function

• λ: S×Σ→Δ – actions function

Example:

• two states

• events = {A, T}

• actions = {z1, z2, z3, z4}

2

A/z2

T/z1

1

A/z3

T/z3

ACO for Learning FSMs 5

Page 6: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Automated-controlled object

Finite-state

machine

Controlled

objectActions

Events

Automata-based programming

Design programs with

complex behavior as

automated-controlled

objects

e1

e2

z1

z3

EventsOutput

actions

z2

z4

z2

ACO for Learning FSMs 6

Page 7: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Automata-based programming:

advantages • Model before programming code, not vice

versa

• Possibility of program verification using

Model Checking

• You can check temporal properties (LTL)

Model Code

Finite-state machine

ACO for Learning FSMs 7

Page 8: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Issues

• Hard to build an FSM with desired

structure and behavior

• Several problems of learning FSMs were

proven to be NP-hard

• One of the solutions – metaheuristics

ACO for Learning FSMs 8

Page 9: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Software

specification

Test

examples

Modeling

environment

Fitness function

f: X → R

Learning finite-state machines with

metaheuristics

• Nstates – number of states

• Σ – input events

• Δ – output actions

• X = (Nstates, Σ, Δ) –

search space

ACO for Learning FSMs 9

Page 10: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Approaches to learning FSMs

• Greedy heuristics

– problem-specific

• Reduction to SAT and CSP problems

– fast

– problem-specific

• Evolutionary algorithms (general)

– slow

ACO for Learning FSMs 10

Page 11: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Proposed approach

• Based on Ant Colony Optimization (ACO)

• Non-standard problem reduction

• Modified ACO algorithm

ACO for Learning FSMs 11

Page 12: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Solution representation

Transition table Output table

δ Event λ Event

State A T State A T

1 1 2 1 z1 z2

2 2 1 2 z2 z3

ACO for Learning FSMs 12

Page 13: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Canonical” way to apply ACO

• Reduce problem to finding a minimum cost path in some complete graph

• Vertices – FSM transitions:

– <i ∈ S, j ∈ S, e ∈ Σ, a ∈ Δ>

• Each ant adds transitions to its FSM

ACO for Learning FSMs

1→1 [T/z1] 1→2 [A/z2]

13

Page 14: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Canonical” ACO: example

• 2 states

• 2 events

• 1 action

ACO for Learning FSMs 14

Page 15: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Canonical” ACO: issues

• Number of vertices in the construction

graph grows as (Nstates)2×|Σ|×|Δ|

• No meaningful way to define heuristic

information

• Later we show that “canonical” ACO is

ineffective for FSM learning

ACO for Learning FSMs 15

Page 16: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Proposed algorithm: MuACOsm

• Mutation-Based ACO for learning FSMs

• Uses a non-standard problem reduction

• Modified ACO

ACO for Learning FSMs 16

Page 17: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Problem reduction: MuACOsm

vs. “canonical” • “Canonical” ACO

– Nodes are solution components

– Full solutions are built by ants

• Proposed MuACOsm algorithm

– Nodes are full solutions (FSMs)

– Ants travel between full solutions

ACO for Learning FSMs 17

Page 18: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

FSM Mutations

2

A/z2

T/z1

1

A/z3

T/z3

2

A/z2

T/z1

1

A/z1

T/z3

2

A/z2

T/z1

1

A/z3

T/z3

Change

transition action

Change transition

end state

ACO for Learning FSMs 18

Page 19: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

MuACOsm problem reduction

• Construction graph

– nodes are FSMs

– edges are mutations of FSMs

• Example

ACO for Learning FSMs 19

Page 20: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Real search space graph

ACO for Learning FSMs 20

Page 21: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Part of real search space (1)

ACO for Learning FSMs 21

Page 22: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Part of real search space (2)

ACO for Learning FSMs 22

Page 23: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Heuristic information

u vηuv = max(ηmin, f(v) – f(u))

Finite-state machines

ACO for Learning FSMs 23

Page 24: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

ACO algorithm

A0 = random FSM

Improve A0 with (1+1)-ES

Graph = {A0}

while not stop() do

ConstructAntSolutions

UpdatePheromoneValues

DaemonActions

ACO for Learning FSMs 24

Page 25: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Constructing ant solutions

• Use a colony of ants

• An ant is placed on a

graph node

• Each ant has a limited

number of steps

• On each step the ant

moves to the next node

ACO for Learning FSMs

A

A4

A3

A2

A1

25

Page 26: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Ant step: selecting the next node

Go to best mutated FSM

Probabilistic selection

P = Pnew

P = 1 – Pnew

}4,3,2,1{ AAAAw

uwuw

uvuv

Avp

A

f(A)=10

А4

f(A4)=9

A3

f(A3)=0

A2

f(A2)=12

A1

f(A1)=8Mutation

A

A4

A3

A2

A1

ACO for Learning FSMs 26

Page 27: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Pheromone update

• Ant path quality = max fitness value on a path

• Update – largest pheromone value

deployed on edge (u, v)

• Update pheromone values:

• – pheromone evaporation rate

best

uvτ

best

uvuvuvτ+τρ=τ )1(

0,1ρ

ACO for Learning FSMs 27

Page 28: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Differences from previous work

• Added heuristic information

• Changed start node selection for ants

• Coupling with (1+1)-ES

• More experiments (later)

• More comparisons with other authors

• Harder problem

ACO for Learning FSMs 28

Page 29: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Simple” problem: Artificial Ant

• Toroidal field N×N

• M pieces of food

• smax time steps

• Fixed position of food and the ant

• Goal – build an FSM, such that the ant will eat all food in K steps

Field example: John Muir Trail

ACO for Learning FSMs 29

Page 30: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Artificial Ant: Fitness function

max

lastmaxfood

1

s

ssnf

• nfood – number of eaten food pieces

• smax – max number of allotted steps

• slast – number of used steps

f

eaten food

used time steps

ACO for Learning FSMs 30

Page 31: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Simple” problem: Artificial Ant

• Two fields:

– Santa Fe Trail

– John Muir Trail

• Comparison:

– “Canonical” ACO

– Christensen et al. (2007)

– Tsarev et al. (2007)

– Chellapilla et al. (1999)

ACO for Learning FSMs

Santa Fe Trail

31

Page 32: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Canonical” ACO

“Canonical”

ACO

MuACOsm

State

count

Success

rate, %

Success

rate, %

5 18 87

10 10 91

ACO for Learning FSMs 32

Page 33: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Santa Fe Trail (Christensen et

al., 600 steps)

5000

7000

9000

11000

13000

15000

17000

19000

21000

5 7 9 11 13 15

Fit

ness e

valu

ati

on

co

un

t

Number of FSM states

MuACOsm Christensen et al

ACO for Learning FSMs 33

Page 34: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

John Muir Trail (Tsarev et al.,

2007): 200 steps

• MuACOsm is 30 times faster for FSMs with 7 states

0

5

10

15

20

25

30

35

40

45

50

8 9 10 11 12 13 14 15 16

Fit

neess e

valu

ati

on

co

un

t

×106

Number of FSM states

MuACOsm Genetic algorithm

ACO for Learning FSMs 34

Page 35: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

“Harder” problem: learning Extended

Finite-State Machines (1)

ACO for Learning FSMs 35

Page 36: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Input data:

• Number of states C and sets Σ and Δ

• Set of test examples T

• Ti =<input sequence Ij, output sequence Oj>

NP-hard problem: build an EFSM with C

states compliant with tests T

“Harder” problem: learning Extended

Finite-State Machines (2)

ACO for Learning FSMs 36

Page 37: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Learning EFSMs: Fitness

function • Pass inputs to EFSM, record outputs

• Compare generated outputs with references

• Fitness = string similarity measure (edit

distance)

ACO for Learning FSMs 37

Page 38: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Experimental setup

1. Generate random EFSM with C states

2. Generate set of tests of total length C×150

3. Learn EFSM

4. Experiment for each C repeated 100 times

5. Run until perfect fitness

6. Record mean number of fitness evaluations

ACO for Learning FSMs 38

Page 39: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Learning random EFSMs

ACO for Learning FSMs 39

Page 40: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Conclusion

• Developed new ACO-based algorithm for

learning FSMs and EFSMs

• MuACOsm greatly outperforms GA on

considered problems

• Generated programs can be verified with

Model Checking

ACO for Learning FSMs 40

Page 41: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Future work

• Better FSM representation to deal with

isomorphism

• Use novelty search

• Employ verification in learning process

Fitness

Function

Model

Checking

MuACOsm

ACO for Learning FSMs 41

Page 42: MuACOsm A New Mutation-Based Ant Colony Optimization Algorithm for

Acknowledgements

• We thank the ACM for the student travel

grants

ACO for Learning FSMs 42