CEE 509/COM S 572 Heuristic Methods for Optimization

advertisement
CEE 509/COM S 572 Heuristic Methods for Optimization
Professors: C. Shoemaker, B. Selman
Assignment 3: Simple Binary Genetic Algorithm and Satisfiability
Date assigned: Friday February 14, 2003
Date due: Friday February 21, 2003
TA: Abbas Kermani, Office hours: Wednesday 1-2pm, 328C Upson Hall
NOTE: check the newsgroup and website regularly for hints or corrections, if any.
website: http://www.cs.cornell.edu/courses/cs572/
newsgroup: cornell.class.cs572
Reading: Genetic Algorithms are discussed in Chapter 3 of the text. Reading for this
assignment is from pages 109 to 119. We will not cover pp 120 to 129 at this time.
1. This homework will cover the optimization of a simple cost function using binary
representation with Genetic Algorithms. You will be graded on the neatness and
conciseness of your submission as well -- please keep the number of pages handed in to a
minimum.
Fitness Function
Consider the following cost function J(s) , where s is a two-dimensional vector s = [s1,
s2] such that s1, and s2 are both integers between 0 and 31:
F(s1,s2) = 10^6-(625-(s1-25)^2) *(1600-(s2-10)^2)*sin((s1)*pi/10)*sin((s2)*pi/10)
The goal is to maximize F(s). Since they each take on values from 0 to 31, the input
variables s1 and s2 can be represented by 5 binary variables each. Hence the domain of
this cost function can be represented by a 10-dimensional binary vector as well, s = [sb1,
sb2, ... sb10], where the first five elements form the binary representation of s1 and the last
five bits represent s2. i.e.
 s1 = sb1*24 + sb2*23 + sb3*22 + sb4*21 + sb5, and
 s2 = sb6*24 + sb7*23 + sb8*22 + sb9*21 + sb10
Note: You may find that plotting F(s1,s2) is helpful in terms of understanding the
behavior of your genetic algorithm (i.e. landscape of the function F(s1,s2),
locations of local and global maxima).
i. (5pts) Write a MATLAB function to implement a Genetic Algorithm GA.m that has
the header line
function solution= GA(Xinitial, maxGen, parameters)
Let M be the size of the population.. Then Xinitial is a binary matrix of size Mx10, with
each row corresponding to a randomly generated initial point in the search space.
maxGen is the total number of generations that the algorithm is to be run. The third input,
parameters, is a vector that contains values for parameters such as the probability of
mutation and crossover. You will need to write functions that implement the following
as well: fitness.m to calculate the fitness of the members of a given population:
selection.m which takes a population and generates parents from it using fitness
proportional selection: crossover.m, which performs crossovers at randomly generated
points; and mutation.m, which takes a given population and mutates each member of it.
Submit code for all five files.
ii.(3 pts) Run GA 30 times with a population size of 5, for 10 generations, on the fitness
function describe above. You will have to perform some initial experiments (sample
runs) to pick suitable parameters. Submit a plot showing the average fitness of the fittest
member of the population at each generation (averaged over all 30 runs). Indicate if and
how often you were able to obtain the global optimum in these 30 runs.
iii.(1 pts) The fitness function in this problem is always non-negative. What problem
might you encounter if the fitness function could take on negative values? How can this
be corrected?
iv.(1pt) Do you think the implementation of the crossover step could be improved
possibly for this particular problem? Give one idea you might consider and explain why
you think it might be helpful for this problem. (You do not need to implement
computationally new crossover ideas at this time.)
2. .Boolean Satisfiability Encodings. Consider the addition of two numbers, X and Y, in
decimal form. X and Y each have two digits. So,
x2 x1
y2 y1 +
==========
z3 z2 z1
Provide a Boolean satisfiability problem that captures the notion of adding X and Y,
storing the result in Z (which has three digits).. Your formula should use Boolean
variables such as v2,5 denoting x2 has value 5. You will also need to introduce variables
that capture the carry-over.
a) Specify the variables needed. How many?
b) Specify the clauses that are needed.
c) Now consider a specific addition with X = 57 and Y = 52. Show what clauses to add
to the formula obtained in a) and b) to capture this specific addition. (Note that a clause
can consist of a single Boolean variable or its negation.) What does a satisfying
assignment of this new formula correspond to? How many satisfying assignments are
there?
d) Consider the “all False” assignments, A, to the Boolean variables (i.e. a string [0 0 0 0
0 ... 0 0] ). What is the objective function value given assignment A and the satisfiability
problem obtained in c)? (The value of the objective function equals the number of
satisfied clauses. This is the number we're trying to maximize.)
e) What is the optimal value of the objective function? (You do not need to do a heuristic
optimization computation to answer this question.)
Download