Genetic Algorithm Performance With Varying Selection Method

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

ABSTRACT Genetic Algorithm is population based heuristic method extensively used in scheduling actually applied for constraint optimization problem. In Genetic Algorithm we are generating random solutions first called as populations and then try to generate feasible solution with the help of mechanisms selection, crossover and mutation. There are varieties of scheduling problem exist like task scheduling, timetable scheduling, employee scheduling of which solution is variable at variable locations. Scheduling class timetable is common scheduling problem in which set of events are to be arranged in available timeslots along with limited resources and constraints. Selection of solutions is an important aspect in genetic algorithm which decides the quality of offspring generated. Selection is a way to make space for good solution to in and bad solution to out from population. In this project we were worked with small instance of timetable problem which required scheduling 100 events in 45 timeslots. There are various selection suggested to use in genetic algorithm. We used tournament selection 2 and tournament selection 5 to check the quality of offspring generated. We found considerable improvement in solution generated with tournament selection 5.

Keywords: Genetic Algorithm, Timetable, Hard and Soft Constraint, Local Search

1. INTRODUCTION Class Timetable is an important activity for any of educational institute from administration point of view. It is resource and timeline constraint problem. Class timetable concerns all activities with regard to making a timetable. According to Collins Concise dictionary (4th Edition) "a timetable is a table of events arranged according to time when they take place." The events are actually meetings between people at particular location. A timetable must meet requirement of people involved in it with possibilities. Actually timetable is common scheduling problem which can be described allocation of resources for the specific task under predefined constraints [1].

Genetic Algorithm is population based heuristic method largely applied to solve scheduling problems. Genetic Algorithm is search method based on principles of natural selection and genetics [2]. GA encodes decision variable of search problem into finite length of string alphabets of certain cardinality. For example in travelling salesman problem a chromosome will represent a route while gene represents a city.

Shengxiang Yang and Sadaf Jat used local and guided search in genetic algorithm to get feasible solution with minimum soft constraint violation [3]. Rhydian Lewis and Ben Paechter used impirical analysis and shown improved results for timetable [4]. Salwani Abdullah and Hamza Turabeih proposed local search method to solve class timetable [5]. R Sivaraj and Dr. T. Ravichandran had shown effective analysis regarding the selection methods available for genetic algorithm. They also had shown how selection is used to improve the chance of survival of fittest individual. [6]

2. PROBLEM DISCRIPTION Timetabling problem considered here is actually reduction of typical class timetabling problem. According to Rossi-Doria [1] the problem consist of set of events of classes E to be scheduled in available timeslots along with a set of rooms R in which events can takes place and set of student S who can attend these events and set of feature F which is required by events and satisfied by rooms. A feasible timetable is one in which all events have been assigned to room and timeslot so that following hard constraints are satisfied.

No student can attend more than one event at a same time.

The room is big enough to schedule the event and it must satisfy features required by event.

Only one can scheduled in a room at any timeslot.

In addition to this timetable is equally penalized for the occurrences of following soft constraints.

Students are having class in last slot of day.

Students are having more than two classes in row.

Students are having single class on a day.

Note that the soft constraint selected is representative of three different classes; first one checked with no knowledge of rest of timetable; second one checked while building a solution taking into account that events are assigned to nearby timeslots and finally last one checked only when timetable is complete and all events are assigned to timeslots. The main objective here is to minimize number of soft constrain violation while generating feasible solution. A solution is feasible if it not have any hard constraint violation.

3. PROBLEM FORMULATION The problem is to arrange given number of events. We are attempting to find the satisfactory choice when and where to schedule the events given the number of students, number of rooms and features available in each room. An instance of this scheduling problem consist of scheduling number of events E {E1,E2,…..En} with available rooms R{ R1,R2,….Rn } and available students S {S1,S2,….Sn} provided total timeslots T{T1,T2,…..T45} and available features F{F1,F2,….Fn } required by an event. The schedule is then mapping a room along with timeslot which we can express like following

Solution: {(a, b) | a є {T1, T2,….T45} , b є {R1,R2,….Rn} }

Interrelationships between these sets are given by five matrices. The first matrix Ak,n , called Student-Event matrix, shows which event is attended by which students. The second matrix Bn,n , called Event- Conflict matrix, indicates whether two events can be scheduled in the same time slot or not. It helps to quickly identify events that can be potentially assigned to the same time slot. The third matrix Cm,l , called Room-Features matrix, gives the features that each room possesses. The fourth matrix Dn,l , called Event-Features matrix, gives the features required by each event. The last matrix Gn,m, called Event-Room matrix, lists the possible rooms to which each event can be assigned. Through this matrix, we can quickly identify all rooms that are suitable in size and feature for each event. Usually, a matrix is used for assigning each event to a room ri and a time slot ti . Each pair of (ri, ti) is assigned a particular number that corresponds to an event. If a room ri in a time slot ti is free or no event is placed, then "−1" is assigned to that pair.

The generated solution quality is calculated based upon number of soft constraint violations. The solution which is having least soft constraint violation is called feasible solution. For this purpose we have used following objective function [9] f(s) = #hcv * C + # scv where value of C is larger than total soft constraint violations in a solution.

Finding feasible solution is quite simple when number of events is less but it is time consuming when number of events and number of students are sufficiently large. So in such case we are trying to get feasible solution.

4. IMPLEMENTATION STRATEGY A. Genetic Algorithm We are using genetic algorithm to solve class scheduling problem with varying selection methods. Genetic algorithm is population based heuristic method largely applied to solve the scheduling problems. Genetic algorithms (GA’s) are search methods based on principles of natural selection and genetics. The basic working of genetic algorithm is given by following algorithm

Table No 1: Basic Genetic Algorithm Scheme

1

Begin

2

INITIALIZE population with

random candidate solutions

3

EVALUATE each candidate

4

Repeat

5

SELECT parents

6

RECOMBINE pairs of

parents

7

MUTATE the resulting

children

8

EVALUATE children

9

SELECT individuals for the

next generation

10

until TERMINATION-

CONDITION is satisfied

11

End

As stated algorithm GA starts with initializing the population with some random solutions. We can use any method to initialize random solutions. After initialization we are evaluating these random solutions to determine the survival capacity of solution. Selection is an important activity used here to generate an individual called as offspring which improves probability of survival of good solution. We apply crossover and mutation with some probability to generate offspring from selected solutions so called parents and then again evaluate this offspring for its quality. If generated offspring is better than any available solution in population will replace that and make entry of this generated offspring into population. We are repeating this process till termination condition is reached. Termination condition can be total number of times you want to execute this loop activity or a time limit.

B. Solution Representation A solution is simply called as chromosome in Genetic Algorithm. We are representing chromosome as ordered pair of decimal number. The first decimal will represent timeslot and second decimal will represent classroom number while pair itself indicates event number.

( 1 , 3 ) , ( 4 , 5 ) ( 2 , 3 ) , …. ( 11 , 3 ) Gene Chromosome

Timeslot Classroom

C. Initializing of Population

We are initializing 10 solutions randomly so at any point of execution of GA total chromosomes are 10 (As a solution is a chromosome).In initializing the population we simply assigning a timeslot on random basis to all events and then assigning possible rooms to each event by considering the requirements of each events. For generating random timeslot we are using random number in the range 0 to 1.

Timeslot = (integer) (random (0, 1) * 45)

D. Evaluation of every individual in

solution

Evaluation is an important step to carry before passing solutions to GA. In evaluation we are testing fitness of each individual. We are evaluating population by applying local search algorithm to every individual present in population. Local search algorithm [3] basically tries to improve the individual by removing hard constraint violations (HCV) and then by removing soft constraint violations (SCV). It used three neighborhood structures called N1, N2 and N3.

Table No 2: Local Search Algorithm to evaluate and improve individual in Population

1

Begin

2

For Each Event e in E

3

If event e contains some hard

constraint) then

4

If there any untried move left

5

Try to remove HCV using

N1. If N1 fails try to

remove HCV using N2.

If N2 Fails try to remove

HCV using N3.

6

Apply matching algorithm

To assign rooms properly

7

If any of move reduces

HCV then make the move

and repeat if tries left

8

End if

9

End if

10

End if

11

End for

12

If no HCV is present in

individuals then

13

For Each Event e in E

14

If event e is having some SCV

then

15

If there any untried move left

then

16

Try to remove SCV using

N1. If N1 fails try to

remove SCV using N2. If

N2 Fails try to remove

SCV using N3.

17

Apply matching algorithm

to assign rooms properly

and delta evaluate e.

18

If any of move reduces

HCV then make the move

and repeat if tries left

19

End if

20

End if

21

End if

22

End for

23

End if

24

End

The N1, N2 and N3 data structures are different moves we are applying some events present in an individual. N1 is used to assign an event to any random timeslot. N2 used to swap the timeslots of two different events in an individual while N3 used to permute any three events in an individual and produce some different combination. Then use this combination to improve the fitness of an individual. In above algorithm line 1 to 11 is used to remove HCV and line 12 to 24 is used to remove SCV (if possible) from an individual.

After applying local search to all individuals in population, sort it according to their fitness values.

Selection of Parents

Our focus is to have correct selection of individual called parents which are used to generate offspring (child). If selected parents are good and capable to survive then the generated child may have same capability to survive. It means if we select two parents with good fitness then we can have child also with good fitness. So parent selection is an important aspect in GA. In this approach we used 2 selection methods. 1. Tournament Selection 2 2. Tournament Selection 5

First method is going to consider part of solution where second method is going to consider proportion of solution. In tournament selection 2 we are selecting two individual on a random by using following technique and then selecting one of them as parent with the help of fitness associated with individual. Again apply same technique to select second parent.

Table No 3: Selection of parents using Tournament Selection 2

1

Begin

2

Parent 1 = (integer) (random (0, 1)

* Population size)

3

Parent 2 = (integer) (random (0, 1)

* Population size)

4

Compare fitness values of Parent 1

and Parent 2

5

return Parent with best fitness

7

End

Table No 4: Selection of parents using Tournament Selection 5

1

Begin

2

random = (integer) (random (0, 1)

* Population size)

3

Best parent = random

4

For 5 times

5

Parent = (integer)(random (0,1)

* Population size)

6

Compare this Parent with Best

Parent

7

If new Parent is best set this as

Best Parent

8

End for

9

Return Parent with best fitness

10

End

Crossover

We are using custom method to generate offspring from the parents selected using tournament selection. Crossover probability is set to 0.8. So actually we are implementing multipoint crossover and these multipoint are decided by random number we are generating in a range 0 to 1. In crossover we are selecting some timeslots from parent1 and some timeslots from parent2 on random basis. After selecting timeslots for all events we are assigning rooms to each event as per its requirement.

Parent 1 (1 , 3) , ( 2 , 3) , (3 , 4) .....(2, 4) Parent 2 (2 , 3) , ( 4 , 3) , (23, 1)…(12, 4)

Child (1, ?) , (4 , ? ), (3 , ?)….(2, ?) 1 2 1 1 Numbers indicate timeslot is selected from which parent. We are getting events only with timeslots then by applying room assignments we are assigning proper rooms to these events.

Table No. 5 Custom Crossover Algorithm

1

Begin

2

Generate one random number in

range (0 , 1)

3

If (random< 0.8) then

4

For all events e in individual

5

Generate one random

number in range (0 , 1)

6

If (random number <0.5)

7

Assign timeslot of first

parent to child

8

Else assign timeslot of second

parent to child

9

End for

10

End if

11

Make first parent as child

12

End

Mutation

Child generated in crossover is undergone through mutation based on probability <0.5. Mutation is technique which actually changes characteristics of single individual. Here the single individual consists of ordered pair of timeslot and classrooms. In this we are again applying techniques used in local search.

Child (2 , 3) , ( 4 , 3) , (23, 1)…(12, 4) If N1: (5 , 3) , ( 4 , 3) , (23, 1)…(12, 4) By changing timeslot associated with any random event (Here first event selected) Child (2 , 3) , ( 4 , 3) , (23, 1)…(12, 4) If N2: (4 , 3) , ( 2 , 3) , (23, 1)…(12, 4) By swapping timeslots with two successive events (Here first two events are selected.

Child (2 , 3) , ( 4 , 3) , (23, 1)…(12, 4) If N3: (23, 4) , (3 , 4) , (1, 3)…(12, 4) By taking three successive events and permuting them to generate different events than available. (Here first three are used for permutation)

To decide actual move to apply on child we are generating number in a range 1 to 3 by using following technique.

Move = (integer) (random (0, 1) * 3)

Table No. 6 Custom Mutation Operation

1

Begin

2

Generate one random number in

a range 1 to 3

3

If random number generated is 1

Then

4

Apply N1 i.e first move which

assign random timeslot to any

event

5

End if

6

If random number generated is 2

Then

7

Apply N2 i.e second move that

swaps timeslots of two

successive events.

8

End if

9

If random number generated is

not 1 or 2 then

10

Apply N3 i.e Third move which

permutes three events in a row

and generates new events.

11

End if

12

End

Evaluation of offspring generated

Evaluation is actually testing the quality of an offspring generated using crossover and mutations. This generated offspring undergone though local search to improve its fitness. This improved offspring is then compared with available solutions. If offspring is better than any of individuals present in population then we put it in population by replacing less improved individual exist in population.

Repeat if termination condition is not reached

Check termination condition. We use total generations to terminate algorithm. If total numbers of generations are reached to required level; stop the algorithm execution else repeat steps from selection to evaluation. We are sorting the population after each generation. When we end with total number of generations, the topmost individual present in population is the best feasible solution for timetable.

V. EXPERIMENTAL RESULTS We have carried out timetable generation on the small instance of problem solution available. The details of this small instance are as follows

Number of events 100 Number of rooms 5 Number of Features 5 Number of students 80 Approximate Features per room 3 Percentage (%) of Features Used 70 Maximum Number of Students per event 20 Maximum events per student 20

The application was coded in C++ and tested with Visual Studio 2010 professional Edition. The obtained results are slightly different if we change the selection method. All tests are carried out on Intel Core i3 CPU with 2.27 GHz Processor and 3 GB RAM. The environment is Windows 7 Operating system. We used standard benchmarked data set available with WATT -- EURO Working group on Automated TimeTabling. We found difference in the fitness of final result if selection method is changed. Following results were observed with set of 5 problem instance having difference in class room size and maximum student per events. Following parameters are fixed for the execution

Population Size = 10 Crossover Probability < 0.8 Mutation Probability < 0.5 Total number of Generations = 50

Table 7: Experimental result when tested with and without local search

Instance

Without L. S.

With L. S.

Small 1

Infeasible

Fitness = 06

Small 2

Infeasible

Fitness = 14

Small 3

Infeasible

Fitness = 03

Small 4

Infeasible

Fitness = 08

Small 5

Infeasible

Fitness = 06

Table No: 8 Experimental Result when tested with tournament selection2 and selection5

Instance

With T.S. 2

With T.S. 5

Small 1

Fitness : 6

Fitness : 5

Small 2

Fitness : 14

Fitness : 13

Small 3

Fitness : 13

Fitness : 13

Small 4

Fitness : 8

Fitness : 8

Small 5

Fitness : 6

Fitness : 5

Above results shows considerable change when we apply tournament selection5 instead of tournament selection2. It shows that considering proportion of available solutions is better that considering part of solution.

Graph 1: Using tournament selection 2 and 5 evaluations of each problem instance.

X axis: Feasibility Y axis: Problem Instance (s1:small1)

VI. CONCLUSION Selection is the way to make in and exit path for the good and bad solutions respectively. So if we are selecting good parents for taking part in crossover and mutation probability of generating good child or offspring increases. Tournament Selection 2 is considering only two individuals from entire population so sometimes we actually miss to select good parents. If we apply tournament selection 5 the chance to select good parent is increased and so that a change to generate child offspring with good quality also get increased. So selection is an important aspect of GA which can have strong impact on the performance of Genetic Algorithm.

On other hand the local search plays a vital role while generating a solution for a timetable. Actually it is core part of Algorithm that deals with hard constraint removal and soft constraint removal. Sometimes we are getting feasible solution just by applying local search. So by applying local search effectively for each individual you can reduce total number generations required to produce feasible solution.



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now