Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review of objects  overview overview. Class of objects  Attributes/ methods.

Similar presentations


Presentation on theme: "Review of objects  overview overview. Class of objects  Attributes/ methods."— Presentation transcript:

1 Review of objects  overview overview

2 Class of objects  Attributes/ methods

3 Object  Instance of an class

4 Method  A function that acts on objects of a class

5 Message passing  Object to object

6 Inheritance  Objects inheriting attributes and methods of superclasses as well as having their own attributes and methods

7 Abstraction  Many to the few

8 Encapsulation  Hide the complexities

9 Polymorphism  Methods of same name can mean different things as they are tied to their own classes

10 GAs

11 Genetic Algorithms  Definition  a computer simulation in which a population of abstract representations (called chromosomes, genotype, or genome) of candidate solutions (called individuals, creatures, or phenotypes) to an optimization problem evolves toward better solutions.  Basics  A genetic representation of the solution domain,  A fitness function to evaluate the solution domain.  Along the way  crossover and mutation  Fitness tests  Until  a solution is found that satisfies minimum criteria

12

13 Interesting  Example Example

14 Karl Sims  Evolved Virtual Creatures  Not an animation  Evolved objects in motion  Encased in various media (water, air, etc.)  With gravity

15 Evolved Virtual Creatures

16 In lisp  Creating a very simple genetic algorithm for producing melodies of a certain type

17 Step 1  1. program a class of objects that have music melodies as attributes

18 Step 2  2. create a whole bunch, say 100, of instances of this object class (initial population)

19 Step 3  3. give the objects a (fitness test) based on overall interval direction, say 9 [stop when fulfilled]

20 Step 4  4. the ones closest survive (selection), the rest are discarded

21 Step 5  5. the remaining ones (mate)

22 Step 6  6. their offspring inherit (crossover) the general shape of the parents combined melodies

23 Step 7  7. maybe a (mutation) creeps in

24 Step 8  8. return to step 3

25  1. program a class of objects that have music melodies as attributes  2. create a whole bunch, say 100, of instances of this object class (initial population)  3. give the objects a (fitness test) based on overall interval direction, say 9 [stop when fulfilled]  4. the ones closest survive (selection), the rest are discarded  5. the remaining ones (mate)  6. their offspring inherit (crossover) the general shape of the parents combined melodies  7. maybe a (mutation) creeps in  8. return to step 3

26 Variables  ;;;variables  (defvar *mutation*  (defvar *allowable-deviation*

27 Object  ;;;class of object with one attribute (a melody)  (defclass individual ()  ((melody :initarg :melody :initform nil :accessor melody))  (:documentation "Our objects in the evolutionary potboiler."))

28 Functions  ;;;functions  (defun melody  (defun fitness  (defun mate  (defun inherit  (defun mutation

29 Top level  ;;;top-level  (defun produce-crossover-melodies

30 MGC  ;;;use MGC to quickly turn into a midi file  (mgc "GA-1.mid" :ontimes '() :pitches '() :durations '() :channels '() :dynamics '())

31  (defvar *mutation*  (defvar *allowable-deviation*  (defclass individual () ((melody :initarg :melody :initform nil :accessor melody)) ((melody :initarg :melody :initform nil :accessor melody)) (:documentation "Our objects in the evolutionary potboiler.")) (:documentation "Our objects in the evolutionary potboiler."))  (setf i-1 (make-instance 'individual))  (defun melody  (defun fitness  (defun mate  (defun inherit  (defun mutation  (defun produce-crossover-melodies  (mgc "GA-1.mid" :ontimes '() :pitches '() :durations '() :channels '() :dynamics '())


Download ppt "Review of objects  overview overview. Class of objects  Attributes/ methods."

Similar presentations


Ads by Google