Test-Based Extended Finite-State Machines Induction with - - PowerPoint PPT Presentation

test based extended finite state machines induction with
SMART_READER_LITE
LIVE PREVIEW

Test-Based Extended Finite-State Machines Induction with - - PowerPoint PPT Presentation

NATIONAL RESEARCH UNIVERSITY Test-Based Extended Finite-State Machines Induction with Evolutionary Algorithms and Ant Colony Optimization Daniil Chivilikhin, Vladimir Ulyantsev, Fedor Tsarev St. Petersburg National Research University of


slide-1
SLIDE 1

Test-Based Extended Finite-State Machines Induction with Evolutionary Algorithms and Ant Colony Optimization

Daniil Chivilikhin, Vladimir Ulyantsev, Fedor Tsarev

  • St. Petersburg National Research University of Information

Technologies, Mechanics and Optics GECCO-2012 Graduate Students Workshop July 7, 2012

NATIONAL RESEARCH UNIVERSITY
slide-2
SLIDE 2

2

Overview (1)

  • Part of a bigger project on automated software

engineering and automata-based programming

  • We focus on model driven-development

Specification Model Code

slide-3
SLIDE 3

3

Overview (2)

Specification Model Code

Set of tests EFSM

slide-4
SLIDE 4

4

Automata-based Programming

  • Entities with complex

behavior should be designed as automated controlled

  • bjects
  • Control states and

computational states

  • Events
  • Output actions

Automated Controlled Object O

Controlled Object

A

Finite-State Machine

Z Xo Y

Set of Control States

δ

Transition Function

φ

Actions Function

V

Set of Computational States

fc

Commands

fq

Requests

XE

e1 e2 z1 z3 Events Output actions z2 z4 z2

slide-5
SLIDE 5

5

Definitions

  • EFSM:

– input events – input Boolean variables – output actions

  • Test is a pair of two sequences

– Input sequence of pairs I = <e, f>

  • e – input event
  • f – guard condition – Boolean formula
  • n input variables

– A – reference sequence of output actions

  • EFSM on the picture complies with

– <A, !x>, <A, x> – z2, z1

  • EFSM on the picture does not

comply with

– <A, x> – z2

slide-6
SLIDE 6

6

Example – Alarm Clock (1)

  • Four events

– H – button “H” pressed – M – button “M” pressed – A – button “A” pressed – T – occurs on each time tick

  • Two input variables
  • Seven output actions
slide-7
SLIDE 7

7

Example – Alarm Clock (2)

  • Test 1:

– T – z5

  • Test 2:

– H – z1

  • Test 3:

– A, H – z3

Tests Model

slide-8
SLIDE 8

8

Example – Stack (1)

  • Test 1:

– push, pop – ok, return element

  • Test 2:

– push, pop, pop – ok, return element, error

  • Test 3:

– push, push, pop, pop – ok, ok, return element, return element

Tests Model

Stack is empty Stack is not empty

push/ ok pop [size=1]/ return element pop [size>1]/ return element pop / error

slide-9
SLIDE 9

9

Problems Considered

  • Automated model design
  • Model mining

Specification Model Model Code

slide-10
SLIDE 10

10

Reduction to Automated Model Design

Well-known methods

Set of tests Model Code

slide-11
SLIDE 11

11

Problem Definition

  • Input data:

– Set of tests – Number of states in EFSM (C)

  • Need to find an EFSM with C states

complying with all tests

slide-12
SLIDE 12

12

Precomputations

  • For each pair of guard conditions from tests

compute:

– If they are same as Boolean functions – If they have common satisfying assignment

  • Time complexity:

– O(n222m) where n is total size of tests’ input sequences, m is maximal number of input variables occurring in guard condition (in practice m is not greater than 5)

slide-13
SLIDE 13

13

Evolutionary Algorithms

  • Random mutation hill climber and evolutionary

strategy can be easily used

  • Problem with genetic algorithms – no

meaningful crossover (“it is hard to automatically identify functionally coherent modules in automata”)

– Johnson, C. Genetic Programming with Fitness based on Model

  • Checking. Lecture Notes in Computer Science. Springer Berlin /

Heidelberg, 2007. Volume 4445/2007, pp. 114–124. – Lucas, S. and Reynolds, J. Learning Deterministic Finite Automata with a Smart State Labeling Algorithm. IEEE Transactions on Pattern Analysis and Machine Intelligence. Vol. 27, №7, 2005, pp. 1063– 1074.

  • This problem can be solved with test-based

crossover

slide-14
SLIDE 14

14

Individual Representation

1

A [x] / 0 T / 1 M / 2 T [!x] / 1

{2, 0, {{A, x, 1, 0}, {T, !x, 1, 1}}, {{T, true, 1, 1}, {M, true, 0, 2}}} All EFSMs considered during one of evolutionary algorithm have the same number of states

slide-15
SLIDE 15

15

Transition Labeling Algorithm

  • Applied to each individual before

calculation of fitness function

1 4 3 2

A [x1] / 0 T [x2] / 1 M [x1] / 1 H [x2] / 1 T [x1] / 1

1 4 3 2

A [x1] / T [x2] / z5 M [x1] / z3 H [x2] / z4 T [x1] / z5

slide-16
SLIDE 16

16

Mutation

  • Change of transition

– Final state – Event – Guard condition – Number of output actions

  • Addition of deletion of a transitions
slide-17
SLIDE 17

17

Fitness Function

 

         

T j j j j j

A len O len A O ED T FF

1 1

) ( ), ( max ) , ( 1 1                  1 FF cnt), ( 1 20 1 FF cnt), ( 1 FF 10 FF

1 1 1 2

M M M M

slide-18
SLIDE 18

18

Test-based Crossover

Input sequences of tests EFSM Output sequences Output sequences are compared with reference

10% of tests for which edit distance between output and reference is minimal are selected

Transitions used while processing these tests are marked Marked transitions are kept together in EFSMs

slide-19
SLIDE 19

19

Example (1)

  • Test set contains:

– Test 1:

  • A [x], B [y]
  • z1, z2

– Test 2:

  • A [!x], B [!y]
  • z2, z1

– …

1

A[x] / z1 A [!x] / z1

2

B[y] / z2 B [!y] / z2

1

A[x] / z2 A [!x] / z2

2

B[y] / z1 B [!y] / z1

slide-20
SLIDE 20

20

Example (2)

  • Test set contains:

– Test 1:

  • A [x], B [y]
  • z1, z2

– Test 2:

  • A [!x], B [!y]
  • z2, z1

– …

1

A[x] / z1 A [!x] / z1

2

B[y] / z2 B [!y] / z2

1

A[x] / z2 A [!x] / z2

2

B[y] / z1 B [!y] / z1

slide-21
SLIDE 21

21

Example (3)

A[x] / z1 A [!x] / z1 A[x] / z2 A [!x] / z2 A[x] / z1 A [!x] / z1 A [!x] / z2 A [!x] / z2 A[x] / z1 A[x] / z2

Parents Offsprings

slide-22
SLIDE 22

22

Example (4)

  • Duplicate and contradictory transitions

removal

  • Showing for state 0 of first offspring

A[x] / z1 A [!x] / z2 A[x] / z2

Conflicting pair

A[x] / z1 A [!x] / z2

slide-23
SLIDE 23

23

Example (5)

  • Both offsprings pass both tests

1

A[x] / z1 A [!x] / z2

2

B[y] / z2 B [!y] / z1

1

A[x] / z1 A [!x] / z2

2

B[y] / z2 B [!y] / z1

slide-24
SLIDE 24

24

Ant Colony Optimization

  • Graph:
  • Nodes – finite-state machines
  • Edges – mutations of finite-state machines
  • Graph is too big to be constructed explicitly

Algorithm: 1. Graph G = {random FSM} 2. While (true) Launch colony on graph G Update pheromone values Check stop conditions: if stagnation, restart

slide-25
SLIDE 25

25

Choosing the Next Node

A f(A)=10 А4 f(A4)=9 A3 f(A3)=0 A2 f(A2)=12 A1 f(A1)=8

Mutation

A A4 A3 A2 A1

1  

8  

9  

10  

Transition to best successor “Roulette” method

P = P0 P = 1 - P0

} 4 , 3 , 2 , 1 { A A A A w uw uv Av

p  

slide-26
SLIDE 26

26

Update Pheromone Values

  • Quality of solution (ant path) – max value of f

among all nodes in path

  • New pheromone value on edge:
  • ρ < 1 – evaporation rate
  • – max pheromone value ever added

to the edge (u, v)

best uv

 

best uv uv uv

     

slide-27
SLIDE 27

27

Choosing Start Nodes on Restart

  • Best path – path from some node to a

node with max value of f

  • Start nodes are selected with “roulette”

method from nodes of best path

slide-28
SLIDE 28

28

Experiments (1)

  • Six algorithms:

– a genetic algorithm with traditional crossover (GA-1) – a random mutation hill climber (RMHC) – (1+1) evolutionary strategy (ES) – a genetic algorithm with test-based crossover (GA-2) – GA-2 hybridized with RMHC (GA-2+HC) – ant colony optimization (ACO)

  • Input data: 38 tests for alarm clock

– total length of input sequences 242 – total length of reference sequences 195

  • 1000 runs of each algorithm
slide-29
SLIDE 29

29

Experiments (2)

Algorithm Min Max Avg Median GA-1 855390 38882588 5805943 4588736 RMHC 1150 9592213 1423983 957746 ES 1506 9161811 3447390 856730 GA-2 32830 599022 117977 83787 GA-2+HC 26740 188509 53706 48106 ACO 2440 210971 53944 46293

slide-30
SLIDE 30

30

Experiments (3)

200000 400000 600000 800000 1000000 1200000 2000000 4000000 6000000 8000000 10000000 12000000

RMHC ES GA-2 GA-2+HC ACO

Maximal number of fitness function evaluations Median number of fitness function evaluations

slide-31
SLIDE 31

31

Summary

  • Test-based crossover greatly improves the

performance of GA

  • GA on average significantly outperforms

RMHC and ES

  • ACO outperforms GA-2
  • Difference between average performance
  • f ACO and GA-2+HC is insignificant
slide-32
SLIDE 32

Thank you!

Questions?