MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #15 2/27/02 Bit Manipulation.

Slides:



Advertisements
Similar presentations
Genetic Algorithms Chapter 3. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing Genetic Algorithms GA Quick Overview Developed: USA in.
Advertisements

Biologically Inspired Computing: Operators for Evolutionary Algorithms
Genetic Algorithms for Real Parameter Optimization Written by Alden H. Wright Department of Computer Science University of Montana Presented by Tony Morelli.
MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #33 4/22/02 Fully Stressed Design.
COMP305. Part II. Genetic Algorithms. Genetic Algorithms.
Evolutionary Computational Intelligence
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
Population New Population Selection Crossover and Mutation Insert When the new population is full repeat Generational Algorithm.
Review Two’s complement
COMP305. Part II. Genetic Algorithms. Genetic Algorithms.
Logical & shift ops (1) Fall 2007 Lecture 05: Logical Operations.
MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #16 3/1/02 Taguchi’s Orthogonal Arrays.
COMP305. Part II. Genetic Algorithms. Genetic Algorithms.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #12 2/18/02 Intro to Evolutionary Algorithms.
Chapter 6: Transform and Conquer Genetic Algorithms The Design and Analysis of Algorithms.
each of these is an instantiation of “full_adder”
Universidad de los Andes-CODENSA The Continuous Genetic Algorithm.
Genetic Programming.
Initial Value Problem: Find y=f(x) if y’ = f(x,y) at y(a)=b (1) Closed-form solution: explicit formula -y’ = y at y(0)=1 (Separable) Ans: y = e^x (2)
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to use the bitwise logical operators in programs ❏ To be able to use.
IT-101 Section 001 Lecture #3 Introduction to Information Technology.
Genetic Algorithms CS121 Spring 2009 Richard Frankel Stanford University 1.
1 Homework Turn in HW2 tonight HW3 is on-line already Questions?
SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.
Operators Using Java operators An operator takes one or more arguments and produces a new value. All operators produce a value from their.
Bits and Bytes. BITWISE OPERATORS Recall boolean logical operators in Java… boolean logical operators: &, |, ^ not: ! Show truth tables.
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Hard Problem. Problem  Write a function that adds two numbers. You should not use + or any arithmetic operators.
Dynamical Systems Model of the Simple Genetic Algorithm Introduction to Michael Vose’s Theory Rafal Kicinger Summer Lecture Series 2002.
Lecture-5 Miscellaneous. Random Numbers Can use ‘rand()’ function declared in the stdlib.h header file The seed for random number generation can be set.
Bit-String Flicking.
Logic (continuation) Boolean Logic and Bit Operations.
REGISTER TRANSFER LANGUAGE MICROOPERATIONS. TODAY OUTLINES Logic Microoperations Shift Microoperations.
Bitwise Operators in C. Bitwise operators are used to manipulate one or more bits from integral operands like char, int, short, long.
Genetic Algorithms What is a GA Terms and definitions Basic algorithm.
MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #12 2/20/02 Evolutionary Algorithms.
Chapter 1 Number Systems Digital Electronics. Topics discussed in last lecture Digital systems Advantages of using digital signals over analog. Disadvantages.
D Nagesh Kumar, IIScOptimization Methods: M8L5 1 Advanced Topics in Optimization Evolutionary Algorithms for Optimization and Search.
Function Tables and Graphs. Function A function is when each input (x-value) corresponds to exactly one output (y- value) In other words, when you substitute.
Object Oriented Programming COP3330 / CGS5409.  Class Templates  Bitwise Operators.
Programming Principles Operators and Expressions.
Bit Manipulation in 'C' 'C' bit operators
Do Now Graph both of these functions on the same graph from –2 ≤ x ≤ 2.
Windows Programming Lecture 06. Data Types Classification Data types are classified in two categories that is, – those data types which stores decimal.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Genetic Algorithm. Outline Motivation Genetic algorithms An illustrative example Hypothesis space search.
LOGARITHMIC FUNCTIONS. LOG FUNCTIONS Exact Values Find the exact value of log 3 81 log 3 81 = x 3 x = 81 3 x = 3 4 x = 4 1.Set the equation equal to.
From bits to bytes to ints
Using GA’s to Solve Problems
CSE 220 – C Programming Expressions.
MAE 552 Heuristic Optimization
Boolean Algebra, Bitwise Operations
Overview Register Transfer Language Register Transfer
Introduction to Computer Science - Lecture 6
Logic operations.
Chapter 14 Bitwise Operators Objectives
REGISTER TRANSFER LANGUAGE
Introduction to Programming
Bitwise Operators CS163 Fall 2018.
CS-401 Computer Architecture & Assembly Language Programming
Logic operations.
Genetic Algorithms Chapter 3.
Introduction to Programming – 4 Operators
Bitwise Operators.
C++ Programming Language Lecture 4 C++ Basics – Part II
Biologically Inspired Computing: Operators for Evolutionary Algorithms
Steady state Selection
Presentation transcript:

MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #15 2/27/02 Bit Manipulation

Bitwise operations for use in GA If you decide to use binary encoding!! Bitwise operators: and or xor left, right shift ones compliment

Bitwise operations for use in GA Why “Bitwise”: The operators are carried out individually on each set of bits in the same locus on the two args. We will see examples.

Bitwise operations for use in GA Truth Tables: AND XY& OR XY| XOR XY^ NOT X~ 10 01

Bitwise operations for use in GA Shift Operators ( >): written as: number > n Move all the bits left or right by n places and fill in anywhere necessary with 0’s, truncate in the case of overrun. example: 10 << 2 = 1010 << 2 = ( = 40 ) 10 >> 2 = 1010 >> 2 = 0010 ( = 2 )

Bitwise operations for use in GA Shift Operators ( >): For what we use them for, they are not really needed. We will only use them for moving 1’s back and forth as in: 1 << n which is the same as 2 n.

Bitwise operations for use in GA Example - using and. 28 & 9== & == 8

Bitwise operations for use in GA Example - using or. 28 | 9== | == 29

Bitwise operations for use in GA Example - using xor. 28 ^ 9== | == 21

Bitwise operations for use in GA Example - using not for ones compliment (unary). ~28 == ~ = == 3 ~31 == ~ = == 0

How to use these operators 1)To perform single point crossover (given 2, 8- bit strings) P1 = andP2 = Step 1 – Generate random crossover pt. bet 1 and 7. Let’s choose 4. Step 2 – Develop variables to extract the bits on either side of the crossover point. We’ll plan to use our “and” operator with our extraction variables.

How to use these operators We start by generating a right side extraction variable as follows: rt_op = ( 1 << cp ) – 1 In our case with cp = 4 we will get: ( << 4) – 1 =( ) – 1 =( )

How to use these operators We then move on to generate a left side extraction variable as follows: lt_op = ~rt_op As you can see, our left op is simply the ones compliment of our rt_op. It is then equal to ( )

How to use these operators Now what do we do with our extraction variables? Keeping in mind our goal and recall that I mentioned using the “and” operator with our extraction variables, we can separate the bits on the left and right side of each parent string into temporary bit holder variables. The process for creating a single child is as follows:

How to use these operators temp1 = P1 & rt_op & temp1=

How to use these operators temp2 = P2 & lt_op & temp2=

How to use these operators Now that we have extracted the bits, how do we assemble them into a child? For this, we will use the “or” operator. child 1 = temp1 | temp2; | child 1 =

How to use these operators To create the other child, we apply the exact same steps except that we use the extraction variables in reverse. That is, child 2 will be given by: (P1 & lt_op) | (P2 & rt_op) (recall that child 1 was given by: (P1 & rt_op) | (P2 & lt_op))

How to use these operators Quick Note: Many of the operations presented can be carried out in a single equation and a number of variables used in this example are not explicitly needed in the code (examples, temp1, temp2, lt_op (could use ~rt_op everywhere)).

How to use these operators 1)To perform Bit Mutation on a randomly selected string. We had a child like this: Step 1 – Randomly choose a bit to be mutated. We will mutate the bin in locus 4. Step 2 – Perform the mutation according to the equation: MutatedChild = Child ^ (1 << (mb-1))

How to use these operators So considering our child and bit # 4, we have mc = child ^ (1 << 3) ^ Note that anything xor’ed with 1 negates.