IEEM 5119 Genetic Algorithms

applesfloristAI and Robotics

Oct 24, 2013 (3 years and 9 months ago)

73 views


1

IEEM 511
9

Genetic Algorithms


Mid
-
Term Exam

(
Nov. 1
0
,

200
5
)


Total
:



c
lose books,
c
lose neighbo
r
ho
o
d, and
o
pen mind

ID
:




Name
:






1.







(
3
0
%)



2.








(
40
%)



3.







(
8
%)



4.







(
8
%)



5.








(
7
%)

6.







(
7
%)


30% (3% each)

1.

(1
-
1)
Generational replacement



In Holland

s original genetic algorithm, parents are replaced by their offspring soon after
they give birth. This is called
by generational replacement.


(1
-
2)
Replacement strategies




The
strategy of replacing parents with his offspring.

Possible strategies are: Directly replacement, Random replacement, Fitness
-
based
replacement.


(1
-
3)
Crowding strategies




In the crowdi
ng model, when an offspring was born, one parent was selected to die. The
dying parent was chosen as that parent who most closely resembled the new offspring,
using a simple bit by bit similarity count to measure resemblance.


(1
-
4)

(


+

) selection





(


+

) selection

is a typical case of enlarged s
am
pling space selection.


With this strategy,


parents and


offspring compete for survival and the


best out of
offspring
s

and old parents

are selected as parents of the next generation.


(1
-
5)
(

,

) s
election




(

,

) selection

selects the


best
out of
offspring
s

as parents of the next generation

(


<

).



2

(1
-
6)
Sampling Mechanism



Sampling mechanism concerns the problem of how to select chromosomes from
sampling space. Three basic approaches
have been used to sampling chromosomes:

1.

Stochastic sampling

2.

Deterministic sampling

3.

Mixed sampling


(1
-
7)
Elitist selection



Elitist selection ensures that the best chromosomes is passed onto the new generation if it
is not selected through another proc
ess of selection.


(1
-
8)
Stochastic tournament selection



Stochastic tournament selection was suggested by Wetzel. In this method, selection
probabilities are
calculated normal
ly and successive pairs of chromosomes are drawn
using roulette wheel selecti
on. After drawing a pair, the chromosome with higher fitness
is inserted in the new population. The process continues until the population is full.


(1
-
9) Hybrid genetic algorithm



Hybrid genetic algorithms is to incorporate local optimization as an add
-
on extra to the
simple genetic algorithm loop of recombination and selection.


(1
-
10)
Flat crossover

operation for non
-
linear programming problem.



Flat crossover produces an offspring by uniformly picking

a value for each gene from the

range formed by

the values of two corresponding parents


genes.


















3

40% (4% each)

2.
(
2
-
1)
Assume that
each value in [

1
.
0
,
4
.
1
]
is
encode
d

as a
binary representation

with

precision to
three

decimal places.

Find the binary representation

of 1.234.


The quant
ity of binary to cover the range
[

1
.
0
,
4
.
1
]

is 1
3
.(
)





(
2
-
2)
C
onstruct a spanning tree
f
or the given Prüfer sequence (
7, 5
, 5,
3
, 4, 3)
.


Step

1.

Let P be the original
Prüfer number

and let P


be t
he set of all vertices not included
in P, which designates as eligible vertices for consideration in building a tree.

Step

2.

Let
i
be the eligible vertex with the smallest label. Let j be the leftmost digit of P.
Add the edge from i to j into the tree. Re
move i from P


and j from P. If j does not
occur anywhere in P, put it into P

. Repeat the process until no digits in P.

Step

3.

If no digits remain in P, there are exactly two vertices, r and s, still eligible for
consideration. Add edge from r to s into

the tree and form a tree with n
-
1 edges.




P: 7, 5, 5, 3, 4, 3


P

: 1, 2, 6, 8


Connect 1
-
7


Connect 2
-
5


Connect 6
-
5


Connect 5
-
3


Connect 7
-
4


Connect 4
-
3


Connect 3
-
8











1

2

3

4

5

6

7

8


4

(
2
-
3)
How to construct

a directional
-
based crossover operation
?



Direction
-
based crossover uses the values of objective function in determining the
direction of genetic search. The operator generates a single offspring
x


from two
parents
x
1

and
x
2

according to the following rule:




x


= r(x
2
-
x
1
)

+

x
2



where r is a random number between 0 and 1. It also assumes that the parent
x
2

is not
worse than
x
1
; that is
f(x
2
)

>=
f(x
1
)

for maximization problems and
f(x
2
)

<=
f(x
1
)

for
minimization problems.


(
2
-
4)
How to construct a
directional
-
based mutation

operation?




Directional
-
based mutation is given by Gen, Liu, and co
-
workers. Let
d

be the
approximate direction determined by this method; the offspring after mutation would be










x


= x + rd



where
r

is a rand
om nonnegative real number, which is selected in such a way that the
offspring is a feasible solution.


(
2
-
5
)
Give one
a
rithmetical
crossover

o
perat
ion for non
-
linear programming problem.



Generally, the weighted average of two vectors
x
1

and
x
2

is cal
culated as follows:









1
x
1

+

2
x
2



If the multipliers are restricted as




1

+

2

= 1,

1

> 0,

2

> 0



the weighted form is known as convex combination. If the nonnegativity condition on
the multipliers is dropped, the c
ombination is known as an affine combination. Finally,
if the multipliers are simply required to be in real space
E
1
, the combination is known
as a linear combination.







5

(2
-
6) What is
scramble mutation
? Perform scramble mutation for the following chromo
some.


v

3

8

1

4

6

5

7

2

9



Davis proposed the scramble mutation, which randomly perturbes the elements between
two randomly chosen cut points in the parent. The distance of the cut points should be
at least 2 and is usually bounded by an upper limit i
n order to prevent producing too
many changes in the offspring.




v

3

8

1

4

6

5

7

2

9


v

3

8

4

5

1

7

6

2

9


(
2
-
7
) Perform
a
lternate edges crossover


Parent 1

v
1

3

8

1

4

6

5

7

2


3

5

8

1

6

7

4

2

P a r e n t 2

v
2

1

3

8

4

5

2

6

7





A starting ed
ge (i, j) is selected at random in one parent. Then, the tour is extended by
selecting the edge (j, k) in the other parent. The tour is progressively extended in this
way by alternatively selecting edges from the two parents . When an edge introduces a
cyc
le, the new edge is selected at random.
.




Edge
(1, 3)

is first randomly selected in parent 1.


Edge
(3, 8)

is selected in parent 2.


Edge
(8, 2)

is selected in parent 1.


Edge (2, 3) is selected in parent 2. (Cycle,
possible
: (2, 4), (2,
5), (2, 6), (2, 7))


Edge
(2, 5)

is randomly selected.


Edge
(5, 6)

is selected in parent 1.


Edge
(6, 2)

is selected in parent 2. (Cycle,
possible
: (6, 4), (6, 7))


Edge
(6, 7)

is randomly selected.


Edge (7, 7) is randomly selected. (
Cycle,
possible
: (7, 4))


Edge
(7, 4)

is selected.


Edge
(4, 1)

is selected.



The offspring is
3, 5, 8, 1, 6, 7, 4, 2





6


(
2
-
8) Give two scaling methods. Why do we need a scaling method?



Scaling methods map raw objective function values t
o some positive real values, and
the survival probability for each chromosome is determined according to these values.
Scaling has a twofold intension:


1.
To maintain a reasonable differential between relative fitness ratings of chromosomes.


2.
To pr
event a too
-
rapid takeover by some super chromosomes in order to meet the
requirement to limit competition early on, but to stimulate it later.




Ex

1.

Linear scaling



f
k


= a*f
k

+ b



where a and b are normally selected so tha
t average chromosomes receive one
offspring copy on average, and the best receives the specified number of copies.



Ex

2.

Dynamic linear scaling



f
k


= a*f
k

+ b
t



where parameter
b
t
varies with generation.


(
2
-
9) Give two ranking me
thods. Why do we need a ranking method?





For most scaling methods, scaling parameters are problem
-
dependent. Fitness
ranking has a similar effect as the fitness scaling

(maintain diversity, prevent super
chromosome)
, but avoids the need for ext
ra scaling parameters.



Ex

1.

Linear ranking




p
k

= q


(k
-
1)*r




where param
e
ter
q

is the probability for the best chromosome. Let
q
0

is the
probability for the worst chromosome; the parameter
r

can be determined as
fol
lows:




r = (q


q0)/(pop_size
-
1)



Intermediate chromosomes


fitness values are decreased from
q

to
q
0

proportional to the rank.


7


Ex

2.

Exponential ranking



p
k

= q(1
-
q)
k
-
1



A larger value of q implies stronger

selective pressure.


(
2
-
1
0)

For the following flow
-
shop permutation problem, construct a heuristic solution using NEH

s
heuristic algorithm.


Job
i
:

1

2

3

4

5

6

t
i
1

5

4

1

5

7

5

t
i
2

2

2

2

6

2

1

t
i
3

3

2

5

6

4

2

t
i
4

1

6

3

4

3

4


11

14 11 21 16 12


Step 1.

Order the
n

jobs by decreasing the sums of processing times on the machines

as below(Call this job list):




Job 4(21) > Job 5(16) > Job 2(14) > Job 6(12
) > Job 1(11)

> Job 3(11)



Step

2.

Take the first two jobs and schedule them in order to minimize the partial

makespan as if there were only these two jobs.


First two jobs are
4
,
5
. Possible arrangements are
4
-
5(24)
,
5
-
4(28)
.
Select

4
-
5




Step 3.

Pick the job that is in the next p
osition in the job list and find the best sequence

by placing it in all possible position in the partial sequence developed so far.


Next job in the job list is 2
.

Possible arrangements are 4
-
5
-
2

(30)
, 4
-
2
-
5

(30)
, 2
-
4
-
5

(28)
.

Select

2
-
4
-
5


Next job in t
he job list is 6
.

Possible arrangements are 6
-
2
-
4
-
5 (33), 2
-
6
-
4
-
5 (33), 2
-
4
-
6
-
5 (32), 2
-
4
-
5
-
6 (32).


Select

2
-
4
-
5
-
6

or

2
-
4
-
6
-
5


Next job in the job list is 1
.

Possible arrangements are 1
-
2
-
4
-
5
-
6 (36), 2
-
1
-
4
-
5
-
6 (37), 2
-
4
-
1
-
5
-
6 (35), 2
-
4
-
5
-
1
-
6
(34), 2
-
4
-
5
-
6
-
1 (33).

Select

2
-
4
-
5
-
6
-
1





8

Next job in the job list is 3
.

Possible arrangements are 3
-
2
-
4
-
5
-
6
-
1(34), 2
-
3
-
4
-
5
-
6
-
1(34), 2
-
4
-
3
-
5
-
6
-
1(38),
2
-
4
-
5
-
3
-
6
-
1(38), 2
-
4
-
5
-
6
-
3
-
1(36), 2
-
4
-
5
-
6
-
1
-
3(39).

Select

2
-
3
-
4
-
5
-
6
-
1

or

3
-
2
-
4
-
5
-
6
-
1

with

completion

time

3


8
%

3
. (
3
-
1)
Perform

the
heuristic

mutation

operation
for
v

with
λ
=
3
.


three selected position














v

3

8

1

4

6

5

7

2

9


nodes

1

2

3

4

5

6

7

8

9

1

0

2

2

1

2

4

3

6

1

2


0

4

2

3

3

3

1

3

3



0

3

3

4

6

5

2

4




0

5

5

2

2

7

5





0

3

2

5

5

6






0

4

2

3

7







0

6

3

8








0

1

9









0



Origin
al cost =
30


Possible arrangement:


(1)
3
, 8, 1, 4, 6,
2
, 7,
5
, 9 with cost = 5 + 6 + 1 + 5 + 3 + 3 + 2 + 5 + 2 = 32


(2)
5
, 8, 1, 4, 6,
3
, 7,
2
, 9 with cost

= 5 + 6 + 1 + 5 + 4 + 6 + 3 + 3 + 5 = 38


(3)
5
, 8, 1, 4, 6,
2
, 7,
3
, 9

with cost
= 5 + 6 + 1 + 5 + 3 + 3 + 6 + 2 + 5 = 36


(4)
2
, 8, 1, 4, 6,
3
, 7,
5
, 9

with cost = 1 + 6 + 1 + 5 + 4 + 6 + 2 + 5 + 3 = 33


(5)
2
, 8, 1 ,4, 6,
5
, 7,
3
, 9

with cost = 1 + 6 + 1 + 5 + 3 + 2 + 6 + 2 + 3 = 29




The best is 2, 8, 1 ,4, 6, 5, 7, 3,

9 with cost =29.


9

(
3
-
2
) Perform edge recombination crossover.


Parent 1

v
1

3

7

1

4

6

5

2

8










P a r e n t 2

v
2

1

8

6

4

5

2

3

7





C
ity 1 has edges to : 4, 7, 8


C
ity 2 has edges to : 3, 5, 8


C
ity 3 has edges to : 2, 7, 8


C
ity 4 has edges to : 1, 5, 6


C
ity 5 has edges to : 2, 4, 6


C
ity 6 has edges to : 4, 5, 8


C
ity 7 has edges to : 1, 3


C
ity 8 has edges to : 1, 2, 3, 6

Assume that city 7 is selected as the starting city. The edge map is updated as be
low.



C
ity
1

has edges to : 4, 8


C
ity 2 has edges to : 3, 5, 8


C
ity
3

has edges to : 2, 8


C
ity 4 has edges to : 1, 5, 6


C
ity 5 has edges to : 2, 4, 6


C
ity 6 has edges to : 4, 5, 8


C
ity 8 has edges to : 1, 2, 3, 6



Possible candidates are city 1, 3. City 1 is selected(Lowest index). The edge map is

updated as below.




C
ity 2 has edges to : 3, 5, 8


C
ity 3 has edges to : 2, 8


C
ity
4

has edges to : 5, 6


C
ity 5 has edges to : 2, 4, 6



C
ity 6 has edges to : 4, 5, 8


C
ity
8

has edges to : 2, 3, 6


10


Select city 4. The edge map is updated as below.



C
ity 2 has edges to : 3, 5, 8


C
ity 3 has edges to : 2, 8


C
ity
5

has edges to : 2, 6


C
ity
6

has edges to :
5, 8


C
ity 8 has edges to : 2, 3, 6



Possible candidates are city 5, 6. City 5 is selected(Lowest index). The edge map is

updated as below.



C
ity
2

has edges to : 3, 8


C
ity 3 has edges to : 2, 8


C
ity
6

has edges to : 8


C
i
ty 8 has edges to : 2, 3, 6




Select city 6. The edge map is updated as below.



C
ity 2 has edges to : 3, 8


C
ity 3 has edges to : 2, 8


C
ity
8

has edges to : 2, 3,



Select city 8. The edge map is updated as below.



C
ity
2

has edges to : 3


C
ity
3

has edges to : 2


Possible candidates are city 2, 3. City 2 is selected(Lowest index)
. Final select city 3.





Final tour: 7, 1, 4, 5, 6, 8, 2, 3


11

8
%

4.
(4
-
1)
What is the
longest common subsequence

of two per
mutations.


(4
-
2)
How to construct crossover operation by using the concept of longest common subsequence?


(4
-
3)
What is the advantage by
using

the concept of longest common subsequence?



(4
-
1)


Given two sequence of items, find the longest common s
ubsequence between them. A
subsequence is a sequence that appears in the same relative order, but not necessarily
contiguous. For example, in the string abcdefg, "abc", "abg", "bdf", "aeg" are all
subsequences.



Ex:


P
arent 1: 7, 8, 1, 3, 2, 4, 5, 6


P
arent 2: 6, 8, 1, 2, 4, 3, 5, 7



longest common subsequence is 8, 1, 2, 4, 5.



(4
-
2)


Keep the longest common subsequence in one parent, then fill the numbers not included
in the LCS according to the other parent

s order. Ex:




P
arent 1: X,
8
,
1
, X,

2
,

4
,
5
, X


P
arent 2: 6,
8
,
1
,

2
,
4
, 3,
5
, 7



Fill the numbers 6, 3, 7 into parent 1 as below.



Offspring:
6
, 8, 1,
3
, 2, 4, 5,
7




(4
-
3)


By using the
longest common subsequence
s of good solutions
(
common characteristics of
good solutions
)
, we can
base on that
, then do some perturbation on it
, try to find better
solutions.


12

7
%

5
. Construct
an
appropriate penalty function
with two control parameters
for the following problem.




Ex:






where
r
i

and
β

are control parameters. Depending on the level of violation,
r
i
varies
accordingly

Normalization

.
β

is used to adjust the scale of penalty value.


7
%

6
. (
6
-
1) What is the
quadratic minimum spanning tree

problem?

(
6
-
2) How to design a genetic algorithm f
or this problem?



(6
-
1)


The quadratic minimum spanning tree problem takes two types of costs into consideration:
direct cost and interactive cost. Direct cost is the cost associated with each edge.
Interactive cost was introduced by Xu to capture the f
act that a cost occurs due to a pair of
edges selected simultaneously within a tree. The objective function is no longer linear so
interactive costs have to be considered. Let
c
ik

denote the interactive cost due to a pair of
edges(
e
i
,
e
k
). Thus the
problem is formulated in the following form:




The minimum spanning tree problem with quadratic objective function above is denoted
as the quadratic minimum spanning tree problem.


(6
-
2)


Ex:


Population initialization: Rand
om


Chromosome encoding: Prufer number


Crossover and mutation: uniform crossover, random perturbation mutation


Evaluation :

1. Convert a chromosome into a tree







2. Calculate the total costs of the tree.


Selection: (
μ
+
λ
) selection


Termination criterion: Predetermined generations