0% found this document useful (0 votes)
3 views50 pages

Soft Computing Module 4

Easy notes

Uploaded by

nimrably2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views50 pages

Soft Computing Module 4

Easy notes

Uploaded by

nimrably2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

• Genetic Modelling

• Extends concepts of:


• Encoding
• Fitness function
• Selection
• Focus: creating new solutions (offspring)

• Key Idea
• After reproduction:
• A mating pool is formed
• Contains good chromosomes
• No new solutions are created yet
• Need for Genetic Modelling
• Reproduction only selects existing solutions
• To improve solutions, we need:
• Inheritance operators
• These create new and better solutions

• Goal of Inheritance Operators


• Explore search space
• Generate new chromosomes
• Preserve good features from parents
• Balance:
• Exploration (new solutions)
• Exploitation (good existing solutions)
• Basic Genetic Operators
• A simple GA uses:
• Reproduction (Selection)
• Crossover (Recombination)
• Mutation
• These are most important

• Role of Basic Operators


• Reproduction → selects best individuals
• Crossover → combines parent genes
• Mutation → introduces variation
• Low-Level Genetic • Sharing
Operators • Mating
• More advanced operators
include: • Key Concept
• Inversion • GA mimics natural genetics
• Dominance • Good solutions survive and
• Deletion evolve
• Duplication • Based on Darwin’s survival
• Translocation of the fittest
• Segregation
• Speciation
• Migration
• Important Insight
• Parent chromosomes contain useful information
• Operators must:
• Preserve good traits
• Create better offspring

• Conclusion
• Genetic modelling focuses on:
• Creating new solutions
• Improving population quality
• Achieved using genetic operators
• Crossover in Genetic Algorithm
• Applied after reproduction
• Works on mating pool
• Main goal:
• Create new offspring
• Improve solutions
• Recombines parent chromosomes

• Why Crossover is Needed


• Reproduction only copies solutions
• No new solutions are created
• Crossover introduces new combinations
• Purpose of Crossover
• Explore search space
• Combine good features of parents
• Preserve useful information
• Leads to better offspring

• Basic Steps of Crossover


• Select two parent chromosomes
• Choose a crossover point randomly
• Swap parts of strings
• Generate two new offspring
Single-Site Crossover
• Only one crossover point
• Most commonly used method
• Split and exchange parts
Two-Point Crossover
• Two random crossover sites are
chosen.
• The segment between these sites
is exchanged between two parent
chromosomes.
• Example: Sites at 3 and 6 → genes
between positions 3 and 6 are
swapped.
• Preserves contiguous blocks of
information.
Multi-Point Crossover
• Multiple crossover sites are
chosen.
• Even number of sites:
• Chromosome treated as a ring.
• Information between alternate
pairs of sites is exchanged.
• Odd number of sites:
• An additional crossover point is
assumed at the beginning.
• Information between alternate
pairs is exchanged.
• Provides higher mixing than
two-point crossover.
Uniform Crossover
• Each gene is selected from
either parent with probability
0.5.
• Often implemented using a
crossover mask:
• Mask bit = 1 → gene from parent 1.
• Mask bit = 0 → gene from parent 2.
• A new mask is generated for
each pair of parents.
• Average effective crossing
points ≈ L/2, where L =
chromosome length.
• Produces offspring with a
mixture of genes from both
parents
Matrix (Two-Dimensional)
Crossover
•Traditional representation:
chromosomes as 1-D strings.
• Matrix crossover: chromosomes
represented as 2-D arrays.
• Two random sites chosen along
row and column.
• This divides the chromosome into
rectangular regions (up to 9).
• Information in selected regions is
exchanged between parents.
• Provides more extensive search in
genetic space compared to
single-point crossover.
• Choice of crossover operator
depends on problem; no universally
optimal operator (Deb, 1995).
Crossover Rate
• Denoted as 𝑃𝐶 , the probability of crossover.
• Range: 0 to 1.
• Defined as:
Number of pairs to be crossed
𝑃𝐶 =
Population size
• Typical values: 0.5 to 1 for population sizes of 30–200.
• Not all strings undergo crossover:
• 100
• → copied directly to next generation.
• Purpose:
• Crossover explores new solutions.
• Reproduction ensures good strings survive even if crossover is detrimental.
• Balance between exploration (new strings) and exploitation (preserving
good strings).
• Crossover Rate
• Given:
• Population size = 6 chromosomes
• C1, C2, C3, C4, C5, C6
• Crossover rate:
• 𝑃𝐶 = 0.5

• Calculate number of pairs for crossover


Number of pairs to be crossed
• 𝑃𝐶 =
Population size
𝑥
• 0.5 = ⇒ 𝑥 = 3
6
• 3 pairs will undergo crossover
Inversion & Deletion Operators
• Advanced genetic operators
• Modify chromosome structure
• Help in exploring new solutions

Inversion
• Select a chromosome
• Choose two random points
• Reverse bits between them
Types of Inversion
1. Linear + End Inversion
• Mostly linear inversion (75%)
• Sometimes invert from ends
• Reduces bias toward center

2. Continuous Inversion
• Applied with probability to each individual

3. Mass Inversion
• Applied to half population
• Same inversion points used
1. Linear + End Inversion Example
• Given Chromosome:
• 11010110
• Case 1: Linear Inversion (75% probability)
• Choose positions 3 to 6
• Before: 11 | 0101 | 10
• After : 11 | 1010 | 10
• Middle part is reversed

• Case 2: End Inversion (25% probability)


• Left End:
• Before: 1101 | 0110
After : 1011 | 0110
• Right End:
• Before: 110101 | 10
After : 110101 | 01
• Inversion happens near ends to avoid center bias
2. Continuous Inversion Example
• Given:
• Population:
C1 = 11010110
C2 = 00111100
C3 = 10101010
• Apply inversion with probability (say 0.5)
• C1 → inverted
• C2 → not inverted
• C3 → inverted
• C1 → 11101010
• C2 → 00111100
• C3 → 10010110
• Each chromosome independently may or may not invert
3. Mass Inversion Example
• Given Population:
• C1 = 11010110
C2 = 00111100
C3 = 10101010
C4 = 11110000
• Step:
• Select same inversion points (say 2 to 5)
• Apply to half population
• C1 → 10101110
• C2 → 01110100
• C3 → unchanged
• C4 → unchanged
• Same positions used for selected chromosomes
Deletion & Duplication
• Select some bits
• Remove or duplicate them
Deletion & Regeneration
• Remove part of chromosome
• Replace with random genes
Segregation
• Split parent genes
• Recombine them to form offspring
Crossover + Inversion
• Combination of:
• Crossover
• Inversion
Steps:
• Select two points
• Swap segments
• Reverse exchanged parts
Mutation Operator (Concept)
• Mutation = flipping bits (0 1) with small probability 𝑃𝑚
• Applied after crossover
• Helps:
• Maintain diversity
• Avoid local optimum
• Restore lost genes
• Typical mutation rate: 0.001 to 0.05

Mutation Example (Binary)


• Given Population (8-bit strings):
1) 01101011
2) 00111101
3) 00010110
4) 01111100
• Problem:
• All strings start with 0
• But optimal solution needs 1 in first position
• Apply Mutation (Pm = 0.1)
• Randomly flipping bits:
• Before → After
01101011 → 01101011 (no change)
00111101 → 00111101 (no change)
00010110 → 00010110 (no change)
01111100 → 11111100 (first bit flipped )

Key Insight
• Crossover cannot create new genes
• Mutation introduces new genetic material
• Without mutation:
• All strings stay starting with 0
• With mutation:
• New possibility created: 1XXXXXXX
Mutation Rate 𝑃𝑚
• 𝑃𝑚 =Probability of mutation
• Decides how many bits will change
• Applied bit-by-bit
• For each bit:
Generate random number (0–1)
If random < 𝑃𝑚 →flip bit
Else → no change

Real-Value Mutation Example


• Before:
• (1.38, -69.4, 326.44, 0.1)
• After mutation:
• (1.38, -67.5, 326.44, 0.1)
• Only one value slightly changed
Bit-wise Operators in GA
• Used in binary encoding
• Operate directly on bits (0s and 1s)
• Efficient and fast (used in C)
• Types:
• One’s Complement (~)
• Logical Operators (&, ⊕, |)
• Shift Operators (<<, >>)

One’s Complement (~)


• Flips all bits:
• 1→0
• 0→1
• Example:
• 10101010 → 01010101
• Similar to mutation (full inversion)
Logical Operators --------
• AND (&) 01101001
• 1 & 1 = 1, else 0 • Creates diversity
• 10101010 • OR (|)
11000011 • If any bit is 1 → 1
-------- • 10101010
10000010 11000011
• Keeps common genes --------
11101011
• XOR (⊕) • Combines all genes
• Different bits → 1
• 10101010
11000011
Shift Operators • Effect:
• Concept: • Value increases (×2 each shift)
• Move bits left or right
• Second operand = number of • Right Shift (>>)
shifts • Bits move right
• Rightmost bits lost
• Left Shift (<<) • Left side filled with 0
• Bits move left • Example:
• Leftmost bits lost • a = 10100110
• Right side filled with 0 a >> 2 = 00101001
• Example: • Effect:
• a = 10100110 • Value decreases (÷2 each shift)
a << 2 = 10011000
Masking (Important Concept) Why Bit-wise Operators in GA?
• Used to extract specific bits • Work directly on chromosomes
• Done using AND operator (&) • Faster than traditional operations
• Example: • Can act like:
• a = 10100110 • Crossover (AND, OR, XOR)
mask = 00001111 • Mutation (~)
---------------- • Transformation (Shift)
result = 00000110
• Extracts last 4 bits
• Generational Cycle in Genetic Algorithm
• Definition:
• A generational cycle is one complete iteration of GA where a new
population is created from the current population.

• Steps in One Generation


• Initial Population (P₁)
• Randomly generated chromosomes
• Example: 4 strings of 10 bits each
• Fitness Evaluation
• Evaluate each chromosome using fitness function
• Example:
• 3 ones → fitness = 0.3
• 6 ones → fitness = 0.6
• Selection (Reproduction) → P₂
• Based on survival of the fittest
• Better chromosomes get more copies
• Example:
• Best → 2 copies
• Average → 1 copy
• Worst → removed
• Crossover → P₃
• Selected parents are paired
• Exchange parts of strings
• Example:
• Parent 1: 1111100000
• Parent 2: 0000011111
• After crossover →
• 1111111111
• 0000000000
• Creates new solutions
• Mutation → P₄
• Random bit flipping with small probability
• Example:
• Before: 1111100000
• After: 1111000000
• Maintains diversity and avoids local optimum

• New Generation Formed


• P₄ becomes next population
• Cycle repeats

• Key Insight
• P₁ → P₂ → P₃ → P₄
• Only P₁ and P₄ are full populations
• P₂ & P₃ are intermediate steps
• Convergence of Genetic Algorithm
• What is Convergence?
• Convergence means GA has reached a stable solution
• No significant improvement in fitness over generations

• Key Observations
• Best solution does not change for many generations
• Population becomes similar (homogeneous)
• Average fitness ≈ Best fitness
• Indicates GA has converged
• Convergence Criteria
• GA is considered converged when:
• Population similarity increases
• ~80–85% of bits become identical across chromosomes
• Fitness stagnation
• No improvement in best fitness
• Fixed generations after optimum
• Continue for few generations → confirm no change

• Why Convergence Happens


• Over generations:
• Weak solutions are removed
• Strong solutions dominate
• Population gradually becomes:
• More fit
• Less diverse
• Schema Concept (Important Theory)
• Schema = Pattern of similarity in strings
• Example (5-bit):
• **000 → 00000, 01000, 10000, 11000
• 1*00* → 10000, 10001, 11000, 11001
• * = can be 0 or 1

• Key Terms
• Order: Number of fixed bits
• Example: **000 → order = 3
• Defining length: Distance between fixed positions
• Schema & Convergence
• Each schema has an average fitness
• Good schemata:
• High fitness
• Short defining length
• Called Building Blocks
• Building Block Hypothesis
• GA works by combining good small patterns (building blocks)
• Over generations:
• Small good patterns → combine → better solutions
• Finally leads to optimal solution
• Role of Genetic Operators in Convergence
• 1. Selection
Promotes good schemata
• 2. Crossover
Combines building blocks
Risk: may destroy good patterns
• 3. Mutation
Restores lost information
Maintains diversity
• Important Insight
• Single-point crossover
• Less chance of breaking good schema
• Uniform crossover
• Higher chance of disruption
• Choice of crossover affects convergence
Composite Laminates Optimization using GA (Application of Genetic
Modelling)
• Introduction
• Composite laminates are widely used in aerospace structures
• Provide high strength-to-weight ratio
• Examples:
• Carbon/Epoxy
• Boron/Epoxy
• Graphite/Epoxy
• Weight reduction: 24–40% compared to metals

• What are Laminated Composites?


• Made by combining multiple layers (plies)
• Each layer has different material or fibre orientation
• Key advantage:
• Properties can be tailored
• Improve strength & stiffness
• Fibre Orientation Types
• Symmetric Laminate
• Fibres arranged symmetrically about mid-layer
• Can have odd or even layers
• Antisymmetric Laminate
• Fibres arranged mirror with opposite sign
• Must have even number of layers
Design Problem
• Main issue: Vibration in aerospace structures
• Goal:
Maximize natural frequency
• Frequency depends on:
• Fibre orientation
• Material properties
• GA Design Variables
• Fibre orientation angles = Design variables
• Range: +90° to −80°
• Discrete values: 16 angles
• Each angle encoded using:
4-bit binary string
• Binary Encoding of Angles
• Total possibilities: 16 (2⁴)
Binary Angle
0000 0°
0011 30°
0100 45°
0111 80°
1000 90°
1111 −80°
• Chromosome Representation
• Each solution = Concatenated binary string
• Example:
• 1000 1001
• Layer 1 → 1000 → 90°
• Layer 2 → 1001 → −10°
• For symmetric laminate:
Remaining layers are mirror image

• Genetic Algorithm Steps


• Generate random population
• Decode binary → fibre angles
• Calculate frequency (fitness)
• Apply:
• Reproduction
• Crossover
• Create next generation
• Repeat until convergence
• Fitness Function
• Fitness = Frequency of vibration
• Objective:
Maximize frequency
• Higher frequency → better design

• Reproduction (Selection)
• Based on fitness
• Rules:
• Best → 2 copies
• Worst → eliminated
• Others → 1 copy
• Follows:
Survival of the fittest
• Crossover Operation • Eventually:
• Crossover rate = 1 (100%) Converges to optimal solution
• Two random crossover points
• Exchange segments between • Convergence Criteria
parents • Stop when:
• Example: • No significant improvement
• Parent A: 1000 1001 • OR 80–85% population becomes
similar
Parent B: 1100 0101
→ Offspring: Mixed strings

• Improvement Over Generations


• Average fitness increases
• Population becomes:
• More fit
• Less diverse
Constrained Optimization using Genetic Algorithm
Application: Three-Bar Truss Problem
Problem Overview • Objective Function
• Structural optimization problem • Minimize weight:
• Objective: Minimize weight of • 𝑓 𝑋 = σ 𝐴𝑖 𝐿𝑖 𝜌
truss • Where:
• Structure: Three-bar symmetric • 𝐴𝑖 =Cross-sectional area
truss • 𝐿𝑖 =Length of member
• Material properties: • 𝜌= Density
• Young’s Modulus (E) = 200.8 GPa
• Density (ρ) = 7850 kg/m³
• Constraints:
• Maximum stress = 147.15 MPa
• Maximum displacement = 5 mm
• Constraints
• Stress constraints:
• 𝜎𝑗 ≤ 𝜎𝑎𝑙𝑙𝑜𝑤
• Displacement constraints:
• 𝑢 ≤ 𝑢𝑎𝑙𝑙𝑜𝑤 , 𝑣 ≤ 𝑢𝑎𝑙𝑙𝑜𝑤
• Constraints are implicit → require
structural analysis

• Need for Transformation


• GA works best for unconstrained
problems
• Convert constrained problem →
unconstrained using penalty
method
• Penalty Function Approach
• Constraint violation:
𝑔𝑖 𝑋 , 𝑔𝑖 𝑋 > 0
• 𝐶𝑖 = ቊ
0, 𝑔𝑖 𝑋 ≤ 0
• Total violation:
• 𝐶 = σ 𝐶𝑖

• Modified Objective Function


• 𝜙 𝑋 =𝑓 𝑋 1+𝐾⋅𝐶
• 𝐾 =Penalty constant (usually 10)
• Penalizes infeasible solutions
• Design Variables Encoding
• Areas are discrete values
• Available set:
• 𝑆 = 1.2 1.4 . . . 4.4 [Link]
• Binary encoding:
• 4 bits → 16 values
• 2 variables → total string length = 8 bits

• Chromosome Representation
• Example:
• 1010 1100
• First 4 bits → Area A₁
• Next 4 bits → Area A₂
• Due to symmetry:
• 𝐴3 = 𝐴1
• Fitness Function
• 𝐹𝑖 = 𝜙𝑚𝑎𝑥 + 𝜙𝑚𝑖𝑛 − 𝜙𝑖
• Converts minimization → maximization
• Higher fitness → better solution

• GA Procedure
• Initialize population
• Decode binary → areas
• Perform structural analysis
• Compute fitness
• Apply:
• Selection
• Crossover
• Mutation
• Generate next generation
• Repeat until convergence

You might also like