Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 2 Temi avanzati di Intelligenza Artificiale - Lecture 6 Prof. Vincenzo Cutello Department of Mathematics and Computer Science University of Catania.

Similar presentations


Presentation on theme: "Tutorial 2 Temi avanzati di Intelligenza Artificiale - Lecture 6 Prof. Vincenzo Cutello Department of Mathematics and Computer Science University of Catania."— Presentation transcript:

1 Tutorial 2 Temi avanzati di Intelligenza Artificiale - Lecture 6 Prof. Vincenzo Cutello Department of Mathematics and Computer Science University of Catania

2 Tutorial 2 - Lecture 62 Binary Representation of Real Values  When designing a representation, try to ensure that: 1. Your complete search space is covered 2. Nothing outside your search space is covered 3. All areas of your search space are covered with equal density (no bias) (In order of importance)

3 Tutorial 2 - Lecture 63 Simple code to transform from binary to Real (-10.0..10.0) wordLength = genotype.size() / 2; xMax = (1 << wordLength) - 1; yMax = (1 << wordLength) - 1; for (int i=0; i< wordLength; i++) { xRaw = (xRaw <<1) + (genotype.getBinary(i) ? 1 : 0); } for (int i= wordLength; i< genotype.size(); i++) { yRaw = (yRaw <<1) + (genotype.getBinary(i) ? 1 : 0); } x = (-10.0 + 20.0 * ((double) xRaw) / xMax); y = (-10.0 + 20.0 * ((double) yRaw) / yMax);

4 Tutorial 2 - Lecture 64 Problems with Binary Encoding 1. Hamming Cliffs  Some far points are easier to reach than some close points Hamming Distance is Important  Improvement: Hamming Code Neighbours always have hamming distance one  But: Still not preference for local changes

5 Tutorial 2 - Lecture 65 wordLength = genotype.size() / 2; xMax = (1 << wordLength) - 1; yMax = (1 << wordLength) - 1; invert = false; for (int i=0; i< wordLength; i++) { invert = invert ^ genotype.getBinary (i); xRaw = (xRaw << 1) + (invert ? 1 : 0); } invert = false; for (int i= wordLength; i< genotype.size(); i++) { invert = invert ^ genotype.getBinary (i); yRaw = (yRaw << 1) + (invert ? 1 : 0); } x = (-10.0 + 20.0 * ((double) xRaw) / xMax); y = (-10.0 + 20.0 * ((double) yRaw) / yMax);

6 Tutorial 2 - Lecture 66 Problems with Binary Encoding 2. What Bit-length ?  Too short... .. or too long

7 Tutorial 2 - Lecture 67 Problems with Binary Encoding  Bit-Mutation Probability  Single Mutation... ... or many-bit mutation

8 Tutorial 2 - Lecture 68 Real-valued Representation  Gaussian or Cauchy Mutation Different distributions Very much depens on scaling factor

9 Tutorial 2 - Lecture 69 Implementing Gaussian and Cauchy Mutation  Gaussian distributed random number In Java: mean + deviation * rng.nextGaussian()), or code below. In C, C++ use GSL, or code below.  Cauchy distributed random number In Java: see code below. In C, C++ use GSL, or code below.  Other distributions See references  References Gnu Scientific Library (GSL), http://www.gnu.org/software/gsl/gsl.htmlhttp://www.gnu.org/software/gsl/gsl.html Non-Uniform Random Variate Generation L. Devroye, Springer Verlag, 1986 Computer Generation of Statistical Distributions Richard Saucier, http://ftp.arl.mil/random/ http://ftp.arl.mil/random/

10 Tutorial 2 - Lecture 610 Implementing Gaussian and Cauchy Mutation Code Examples  double Gaussian (double stdev, double median) { assert( stdev > 0. ); double u,v,x; do { u = 2.0 * rng.nextDouble() - 1.0; v = 2.0 * rng.nextDouble() - 1.0; x = u * u + v * v; } while ( x >= 1.0 ); return median + stdev * u * sqrt( -2. * log( x ) / x ); }  double Cauchy (double formFactor, double median) { assert( formFactor > 0. ); double u, v; do { u = 2.0 * rng.nextDouble() - 1.0; v = 2.0 * rng.nextDouble() - 1.0; } while (u*u+v*v>1.0 || (u==0.0&&v==0.0)); if (u!=0) return (median + formFactor * (v/u)); else return(median); }

11 Tutorial 2 - Lecture 611 Exercise Sheet  Goal: Goal of this exercise is to get experience with real-valued based representations and self-adpatation in EC.  Task Write an EA (possibly reusing bits from the previous tutorial), that finds the optimum in one of the test functions shown in last lecture. Use a real-valued representation, with gaussian or cauchy mutation, and self-adaptive mutation parameter. For test functions, use the generalized sphere function of order 4:, and f 8 from last lecture notes.  Hints Each individual in the population will need two genotypes: one for the actual value, and one for the strategy parameter. You will need to mutate both, using the contents of the second genotype to control the mutation of the first. Read Evolutionary Programming made Faster  Question What happens if you do not use a minimum value for the strategy parameter ? For most global optimisation problems, the ranges of variables are usually given (e.g., -10.0 < x i < 10.0). What do you do if a random mutation takes an offspring outside the range ?


Download ppt "Tutorial 2 Temi avanzati di Intelligenza Artificiale - Lecture 6 Prof. Vincenzo Cutello Department of Mathematics and Computer Science University of Catania."

Similar presentations


Ads by Google