Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Knowledge-based and soft computing IS models

Overview of knowledge-based systems and soft computing models (fuzzy logic, neural nets, Bayesian reasoning, genetic algorithms) used for intelligent decision making in pervasive computing environments.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Engineers use knowledge-based and soft computing models when designing pervasive systems that must make intelligent decisions from uncertain, noisy or incomplete context data (for example, deciding whether a user is at home from sensor signals). These models allow reasoning, learning and adaptation in smart devices and smart environments without requiring perfect data or rigid rules.

Key ideas

Start with definitions (each term is defined exactly before use).

  • Knowledge-based system: a computer system that represents domain knowledge explicitly and applies reasoning mechanisms to draw conclusions or make decisions. Assumptions: knowledge can be encoded in a formal representation (rules, frames, ontologies) and a separate reasoning engine can operate on that representation.

  • Rule-based system: a type of knowledge-based system whose knowledge is a set of conditional rules of the form IF antecedent THEN consequent. Assumptions: rules are correct, conflicts resolved by an explicit strategy (priority, recency).

  • Expert system: a rule-based system intended to reproduce the decision process of a human expert; typically includes a knowledge base, an inference engine, working memory and an explanation facility.

    Exact architecture to draw: draw five boxes left to right or stacked. Label them: Knowledge base (top-left) containing rules/facts; Inference engine (centre) with arrows to and from Working memory (below it); User interface (left) pointing into Working memory and to Inference engine; Explanation facility (right) connected to Inference engine. Show arrows: User -> Working memory; Working memory <-> Inference engine <-> Knowledge base; Inference engine -> Explanation facility -> User. This is the standard expert-system diagram. Typical inference modes are forward chaining (data-driven) and backward chaining (goal-driven).

  • Soft computing: a set of techniques that tolerate imprecision, uncertainty and partial truth to achieve tractable and robust solutions. Main components: fuzzy logic, artificial neural networks, evolutionary computation (genetic algorithms), and probabilistic reasoning (Bayesian networks). Assumptions: exact models are hard/expensive; approximate solutions acceptable.

  • Fuzzy logic: a framework for reasoning about imprecise concepts using membership functions that map an input value to a degree of membership in [0,1]. Exact definition: a fuzzy set A over universe X is defined by a membership function mu_A: X -> [0,1], where mu_A(x) is the degree to which element x belongs to A.

    Important operations: fuzzy AND (typically min), fuzzy OR (typically max), fuzzy NOT (1 - mu). Fuzzy inference applies rules with fuzzy antecedents and consequents; typical overall steps: (1) fuzzification of crisp inputs, (2) rule evaluation (apply AND/OR to antecedent memberships to get rule firing strength), (3) implication and aggregation of consequents, (4) defuzzification to get a crisp output. Common defuzzification methods include centroid (center of gravity), bisector of area, and mean/max of maxima (MOM/LOM/SOM).

    Two popular systems: Mamdani (fuzzy output sets aggregated, then defuzzified) and Sugeno (consequent is a function of inputs, easier to compute and used for control).

  • Artificial neural network (ANN): a parametric model composed of interconnected nodes (neurons) arranged in layers. Exact basic unit: perceptron with weighted inputs w_i, bias b, and activation function f; output y = f( sum_i w_i x_i + b ). Assumptions for basic training: data labelled, loss differentiable for gradient methods, learning rate small enough to converge.

    Important training rule (perceptron learning): for a binary linearly separable problem, update weights w := w + eta (t - y) x, where t is target, y is predicted label, eta is learning rate.

  • Bayesian network: a directed acyclic graph where nodes are random variables and edges encode conditional dependencies. Exact definition: a joint probability distribution factorizes as P(X1,...,Xn) = product_i P(Xi | Parents(Xi)). Assumptions: variables discrete or continuous with known conditional distributions; graph correctly encodes independence relations.

  • Genetic algorithm (GA): a population-based optimization technique inspired by evolution; main steps: initialise population, evaluate fitness, select parents, apply crossover and mutation, form new population. Assumptions: fitness measurable, representation amenable to crossover/mutation.

Derivations universities commonly ask for (show step-by-step):

  1. Bayes theorem derivation from definition of conditional probability:

    • Start: P(A | B) = P(A and B) / P(B) and P(B | A) = P(A and B) / P(A).
    • Solve for P(A and B): P(A and B) = P(A | B) P(B) = P(B | A) P(A).
    • Rearranged: P(A | B) = P(B | A) P(A) / P(B). State assumptions: P(B) > 0.
  2. Centroid (center of gravity) defuzzification formula derivation concept: treat aggregated output fuzzy set mu(y) as a distribution; crisp output y* = (integral y mu(y) dy) / (integral mu(y) dy). Assumption: integrals finite and mu(y) integrable. For discrete approximations replace integrals by sums.

  3. Perceptron convergence concept: for linearly separable data, the perceptron algorithm with any fixed positive learning rate converges in a finite number of steps. Give high-level steps and assumptions: existence of a positive margin and bounded input norm.

Formulas

P(A | B) = P(B | A) · P(A) / P(B)
P(A | B): conditional probability of A given B (unitless). Applies when P(B) > 0.

P(X1,...,Xn) = ∏_i P(Xi | Parents(Xi))
Joint probability factorization for a Bayesian network. Probabilities unitless. Applies when graph is a DAG representing conditional independences.

y = f(Σ_i w_i x_i + b)
Neuron output y: f is activation function (sigmoid, ReLU, step), w_i are weights (unitless), x_i inputs (unitless), b bias (unitless). Applies per neuron.

w := w + η (t - y) x
Perceptron weight update: η is learning rate (unitless), t target label (±1 or 0/1), y predicted output (±1 or 0/1), x input vector. Applies for perceptron learning rule on misclassified samples.

y* = (∫ y μ(y) dy) / (∫ μ(y) dy)
Centroid defuzzification: y* is a crisp output with the same units as the output variable (e.g., degrees Celsius); μ(y) is an aggregated membership grade in [0,1] (unitless). Applies when μ(y) is integrable and the denominator is nonzero.

P(select i) = f_i / Σ_j f_j
Fitness-proportionate selection probability in GA where f_i is fitness of individual i. Unitless. Applies when all fitnesses nonnegative and sum > 0.

Worked examples

Example 1 — Fuzzy temperature control (Mamdani, centroid defuzzification)

Problem: Input variable Temperature T in degrees Celsius; two fuzzy sets: Cold with triangular membership peaks (0 at 0, 1 at 15, 0 at 30) and Hot (0 at 15, 1 at 30, 0 at 45). Output variable HeaterPower P from 0 to 100%. Rules: R1: IF T is Cold THEN P is High (High triangular with peak at 80 and support [40,100]); R2: IF T is Hot THEN P is Low (Low triangular peak at 20, support [0,60]). Crisp input: T = 18°C.

Steps:

  1. Fuzzification: compute mu_Cold(18). Cold triangle with points (0,0),(15,1),(30,0). For 15<=T<=30: mu_Cold = (30 - T) / (30 -15) = (30 - 18)/15 = 12/15 = 0.8. mu_Hot(18) (hot triangle points (15,0),(30,1),(45,0)): for 15<=T<=30: mu_Hot = (T - 15) / (30 - 15) = (18-15)/15 = 3/15 = 0.2.
  2. Rule firing strengths: R1 strength α1 = mu_Cold = 0.8; R2 α2 = mu_Hot = 0.2.
  3. Implication: clip consequent membership by firing strength. So High membership clipped at 0.8, Low clipped at 0.2.
  4. Aggregation: combined membership mu_P(y) = max(mu_High_clipped(y), mu_Low_clipped(y)).
  5. Defuzzification (centroid): approximate integral by sampling y at increments of 10 from 0 to 100 and compute numerator and denominator.
    • For brevity show calculation for three sample points: y=20 (Low peak area): mu_Low(20)=1 clipped->0.2; mu_High(20)=0; mu_P(20)=0.2.
    • y=60: mu_Low(60)=0; mu_High(60)=(60-40)/(80-40)=20/40=0.5 (clipped to 0.5); mu_P(60)=0.5.
    • y=90: mu_Low(90)=0; mu_High(90)=(100-90)/20=0.5 (clipped to 0.5); mu_P(90)=0.5. (Note: full computation would sample all points and produce y* ≈ (Σ y μ(y))/(Σ μ(y)).)

Final answer: performing the full centroid computation for the specified triangles yields a crisp HeaterPower around 62% (exact value depends on whether you integrate continuously or use discrete sampling and on the precise triangle parameters). State uncertainty: exact numeric depends on sampling resolution and precise triangle parameters.

Example 2 — Bayes for context inference

Problem: Sensors WiFi (W) and GPS (G) report whether user is at home H. Known: P(H) = 0.6. Sensor models: P(W = detected | H) = 0.9, P(W = detected | not H) = 0.2. P(G = home | H) = 0.85, P(G = home | not H) = 0.1. Both sensors conditionally independent given H. Observed: W detected, G home. Compute P(H | W, G).

Steps:

  1. Use Bayes with conditional independence: P(W,G | H) = P(W | H) P(G | H).
  2. Compute numerator: P(W,G | H) P(H) = 0.9 * 0.85 * 0.6 = 0.459.
  3. Compute denominator: P(W,G) = P(W,G | H)P(H) + P(W,G | not H)P(not H) = 0.90.850.6 + 0.20.10.4 = 0.459 + 0.008 = 0.467.
  4. Posterior: P(H | W,G) = 0.459 / 0.467 = 0.9829 ≈ 0.983.

Example 3 — Perceptron learning trace (2D, linearly separable)

Problem: Points (x1=(1,1), t=1), (x2=(−1,1), t=−1). Initialize weights w = (0,0), bias b=0, learning rate η = 1. Activation step function y = sign(w·x + b) where sign(0)=1 for this trace.

Steps:

  1. Sample x1: y = sign(0) = 1 equals t so no update.
  2. Sample x2: y = sign(0) = 1 but t = −1 so misclassified. Update: w := w + η(t - y)x = (0,0) + 1(−1 - 1)(−1,1) = (0,0) + (−2)(−1,1) = (2, −2). b := b + η(t - y) = 0 + (−2) = −2.
  3. Re-evaluate x1: net = w·x1 + b = (2*1 + (−2)*1) + (−2) = (0) + (−2) = −2 => sign = −1 but t=1 so misclassified. Update: w := (2,−2) + 1(1 - (−1)) (1,1) = (2,−2) + 2(1,1) = (4,0). b := −2 + 2 = 0.
  4. Re-evaluate both: x1 net = 41 + 01 + 0 = 4 => y=1 correct. x2 net = 4*(−1) + 0*1 + 0 = −4 => y=−1 correct. Done. Final weights (4,0), b=0.

Common mistakes

  • For Bayes problems, forgetting conditional independence assumptions when multiplying likelihoods.
  • In perceptron updates, using (t) instead of (t - y) or forgetting to update bias.
  • In GA, not normalizing fitness for selection or using negative fitness without shift.
  • In expert systems, failing to state conflict resolution strategy for multiple matching rules.

For your exam

Question types you will see: short definitions (define fuzzy set, Bayes theorem, expert system), short notes (compare Mamdani vs Sugeno, list soft computing techniques), derivations (derive Bayes theorem, centroid defuzzification), numeric problems (compute posterior probabilities, fuzzy inference with given membership functions), algorithm traces (perceptron update, simple GA generation), diagrams (expert system architecture).

What full-marks answers include:

  • For definitions: the exact formal statement and at least one short example.
  • For derivations: start from definitions, show algebraic steps and state assumptions (eg P(B)>0).
  • For numericals: write each step, substitute numbers into the stated formula, carry units or state unitless, give final answer with correct rounding and units.
  • For diagrams: draw labelled boxes and arrows as described in Key ideas.

Quick check

  1. Define a fuzzy set and give the range of its membership function.
  2. State Bayes theorem in formula form and name the assumption for applying it.
  3. In a perceptron update w := w + η (t - y) x, what does η control?

Answers: 1) A fuzzy set A over X is defined by membership mu_A: X -> [0,1]; range [0,1]. 2) P(A|B) = P(B|A) P(A) / P(B), assumption P(B) > 0. 3) η is the learning rate controlling update step size.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?