1 / 11

Tutorial 2

Tutorial 2. Temi avanzati di Intelligenza Artificiale - Lecture 6 Prof. Vincenzo Cutello Department of Mathematics and Computer Science University of Catania. Binary Representation of Real Values. When designing a representation, try to ensure that:

yin
Download Presentation

Tutorial 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. 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) Tutorial 2 - Lecture 6

  3. 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); Tutorial 2 - Lecture 6

  4. Problems with Binary Encoding1. 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 Tutorial 2 - Lecture 6

  5. 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); Tutorial 2 - Lecture 6

  6. Problems with Binary Encoding2. What Bit-length ? • Too short... • .. or too long Tutorial 2 - Lecture 6

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

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

  9. 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.html • Non-Uniform Random Variate Generation L. Devroye, Springer Verlag, 1986 • Computer Generation of Statistical Distributions Richard Saucier, http://ftp.arl.mil/random/ Tutorial 2 - Lecture 6

  10. Implementing Gaussian and Cauchy MutationCode 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); } Tutorial 2 - Lecture 6

  11. 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 f8 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 < xi< 10.0). What do you do if a random mutation takes an offspring outside the range ? Tutorial 2 - Lecture 6

More Related