Artificial Intelligence

Fuzzy Logic; Genetic Algorithms

C-CAT

Fuzzy Logic

What is Fuzzy Logic?

"Fuzzy" = vague, not clear, imprecise — real-world characteristics.

Classical (crisp) logic: operates with binary values — True (1) or False (0).

Real life problem: Statements are often neither completely true nor false:

  • "This person is tall" — how tall is tall?
  • "It is quite hot today" — how hot?
  • "The car is moving fast" — how fast?

Fuzzy Logic: allows truth values to be any value between 0 and 1, representing degrees of truth.

Fuzzy vs Classical Logic

FeatureClassical LogicFuzzy Logic
Values0 or 1 (binary)[0.0 to 1.0] (continuous)
"Age 25 is young"True or FalseTrue to degree 0.8
UncertaintyCannot handleHandles naturally
Mimics human reasoningNoYes

Fuzzy Membership Functions

Membership
Degree
  1.0  |   /\          /\
       |  /  \        /  \
  0.5  | /    \      /    \
       |/      \    /      \
  0.0  +--------\--/--------\-----> Temperature
       COLD      WARM        HOT

Each value belongs to multiple fuzzy sets with different degrees.

Fuzzy Logic System

Crisp Input --> Fuzzification --> Fuzzy Inference --> Defuzzification --> Crisp Output
    (e.g., temperature = 35 C)     (Apply rules)         (Convert back)  (e.g., fan speed = 70%)

Use Cases of Fuzzy Logic in AI

  1. Engineering decisions with uncertainty / imprecise data (e.g., NLP — "large file", "recent")
  2. Regulating and controlling machine outputs with multiple inputs (e.g., temperature control systems)

Additional Applications:

  • Air conditioner temperature control
  • Washing machine cycle selection (water/dirt level fuzzy)
  • Anti-lock Braking System (ABS)
  • Camera auto-focus

Medical diagnosis systems

Fuzzy Logic vs Neural Networks

AspectFuzzy LogicNeural Network
Knowledge sourceExpert-defined rulesLearned from data
InterpretabilityHigh (transparent rules)Low (black box)
Training requiredNoYes
Computing resourcesLowHigh
Best forControl systems, embeddedPattern recognition, large data

Genetic Algorithms

What are Genetic Algorithms?

Genetic Algorithms (GAs) are search and optimization techniques inspired by natural evolution — specifically Darwin's theory of natural selection.

They are part of Evolutionary Computing — a branch of AI. GAs are effective for:

Complex optimization problems

  • Problems where the search space is large
  • Problems where traditional methods are too slow

Biological Analogy

BiologyGenetic Algorithm
Individual (organism)Candidate solution
ChromosomeEncoded solution (bit string)
GeneOne parameter of the solution
PopulationSet of candidate solutions
FitnessQuality/goodness of solution
Natural SelectionSelect better solutions
CrossoverCombine two solutions
MutationRandom small change
GenerationOne iteration of the algorithm

Genetic Algorithm Workflow

Step 1: INITIALIZATION
  Create a random initial population of solutions
  Population: [10110010, 01101100, 11001011, 00111010, ...]

Step 2: EVALUATION
  Calculate fitness of each individual (how good is this solution?)
Fitness: [0.82, 0.45, 0.91, 0.33, ...]

Step 3: SELECTION
  Select better-fit individuals for reproduction
  (Methods: Tournament,
Roulette Wheel, Rank-based)

Step 4: CROSSOVER (Recombination)
  Combine two parents to create offspring
  Parent 1: 1 1
0 1 | 0 0 1 0
  Parent 2: 0 1 1 0 | 1 1 0 1
  Child:    1 1 0 1 | 1 1 0 1  (crossover at
position 4)

Step 5: MUTATION
  Randomly flip some bits (small probability)
  Before: 1 1 0 1 1 1 0 1
After:  1 1 0 1 0 1 0 1  (bit 5 flipped)

Step 6: REPLACEMENT
  Replace old population with the new generation

Step 7: TERMINATION
  If best solution found OR max generations reached -> STOP
  Else -> Go to Step 2

Applications of Genetic Algorithms

ApplicationDescription
Feature SelectionSelect the best features for ML models
Neural Architecture SearchFind optimal neural network architecture
Route OptimizationTraveling Salesman Problem (shortest route)
Game PlayingEvolve AI game strategies
Engineering DesignOptimize structural designs (aerodynamics)
Financial TradingEvolve trading strategies
SchedulingJob shop, airline crew scheduling
Drug DesignOptimize molecular structures

Continue learning

Related notes

Put this topic into timed practice

Open mock tests when you want full-exam pacing, or keep drilling in practice mode.