System Architectures Blackboard Pattern Jonathan Thaler Department - - PowerPoint PPT Presentation

system architectures blackboard pattern
SMART_READER_LITE
LIVE PREVIEW

System Architectures Blackboard Pattern Jonathan Thaler Department - - PowerPoint PPT Presentation

System Architectures Blackboard Pattern Jonathan Thaler Department of Computer Science 1 / 31 Blackboard Pattern Motivation Fire propagation in complex buildings is hard to detect and forecast, but exremely important for emergency plans. 2 /


slide-1
SLIDE 1

System Architectures Blackboard Pattern

Jonathan Thaler

Department of Computer Science

1 / 31

slide-2
SLIDE 2

Blackboard Pattern Motivation

Fire propagation in complex buildings is hard to detect and forecast, but exremely important for emergency plans.

2 / 31

slide-3
SLIDE 3

Blackboard Pattern Motivation

Figure: Fire-Alarm System (Jan Bosch, 2000).

3 / 31

slide-4
SLIDE 4

Blackboard Pattern Motivation

Figure: Fire-Alarm System (Jan Bosch, 2000).

Monitors a large number (up to 10,000) of detectors (temp., smoke). Alarm situation depends on complex input correlations in time & space. Each output depends on a potentially large collection of inputs. Each output requests the status at each sensor (input) it depends on. This might result in too long request cycles.

4 / 31

slide-5
SLIDE 5

Blackboard Pattern

Blackboard Architectural Pattern The blackboard architecture is used in an immature domain, in which no closed approach to a solution is known or feasible. It is used to coordinate separate, disparate systems that need to work together or in sequence, continually cycling for updates and actions.

5 / 31

slide-6
SLIDE 6

Blackboard Pattern

The blackboard model is usually presented with three major parts:

  • 1. The knowledge sources: separate, independent parcels of application-dependent
  • knowledge. Interaction among knowledge sources takes place solely through the

blackboard.

  • 2. The blackboard data structure: problem-solving state data, organized into an

application-dependent hierarchy. Knowledge sources make changes to the blackboard that lead incrementally to a solution to the problem.

  • 3. Control: driven entirely by the state of the blackboard. Knowledge sources

respond opportunistically when changes in the blackboard make them applicable. The blackboard consists of a number of variables. This is similar to a repository, which can be accessed by separate autonomous processes. A controller monitors the properties on the blackboard and can decide which knowledge sources to prioritize.

6 / 31

slide-7
SLIDE 7

Blackboard Pattern

Mobile robots was used in the NAVLAB project as part of the CODGER system Captain: overall supervisor (controller). Map navigator: high-level path planner (knowledge source). Lookout: module that monitors the environment for landmark (knowledge source). Pilot: low-level path planner and motor controller (controller). Perception subsystem: modules that accept the raw input from multiple sensors and integrate it into a coherent interpretation.

7 / 31

slide-8
SLIDE 8

Blackboard Pattern

The first blackboard system was the HEARSAY-II speech-recognition system Six- to eight-level hierarchy. Each level abstracts information, blackboard elements represent hypotheses about the interpretation of an utterance. Knowledge sources correspond to tasks as segmenting the raw signal, identifying phonemes, generating word candidates, proposing semantic interpretations,... Knowledge sources organized as a condition part that specifies when it is applicable and an action part that processes relevant blackboard elements and generates new ones.

8 / 31

slide-9
SLIDE 9

Blackboard Pattern The Problem

In general, the Blackboard pattern tackles problems that do not have a feasible deterministic solution for the transformation of raw data into high-level data structures, such as diagrams, tables or english phrases.

9 / 31

slide-10
SLIDE 10

Blackboard Pattern

Problem Domains The Blackboard Pattern is applicable to domains of vision, image recognition, speech recognition and surveillance,... They are characterized by a problem that, when decomposed into subproblems, spans several fields of expertise. In many cases no predetermined strategy exists for how the ”partial problem solvers” should combine their knowledge. This is in contrast to functional de- composition, in which several solution steps are arranged so that the sequence

  • f their activation is hard-coded.

In some of the above problem domains you may also have to work with uncertain

  • r approximate knowledge. Each transformation step can also generate several

alternative solutions.

10 / 31

slide-11
SLIDE 11

Blackboard Pattern

A complete search of the solution space is not feasible in a reasonable time. Since the domain is immature, you may need to experiment with different algorithms for the same subtask. For this reason, individual modules should be easily exchangeable. Different algorithms solve partial problems. Input, as well as intermediate and final results, have different representations, and the algorithms are implemented according to different paradigms. An algorithm usually works on the results of other algorithms. Uncertain data and approximate solutions are involved, for example the interpretation of a signal is error-prone and there might occur competing alternatives for an interpretation at any stage of the process. Employing disjoint algorithms induces potential parallelism. If possible you should avoid a strictly sequential solution.

11 / 31

slide-12
SLIDE 12

Blackboard Pattern Structure and Dynamics

Divide your system into a component called Blackboard, a collection of Knowledge Sources, and a Control Component.

12 / 31

slide-13
SLIDE 13

Blackboard Pattern

The blackboard is the central data store. Elements of the solution space and control data are stored here. The blackboard provides an interface that enables all knowledge sources to read from and write to it. For solutions that are constructed during the problem solving process which are put on the blackboard, we use the terms hypothesis or blackboard entry. Hypotheses rejected later in the process are removed from the blackboard.

13 / 31

slide-14
SLIDE 14

Blackboard Pattern

Knowledge sources are separate, independent subsystems that solve specific aspects of the

  • verall problem.

Together they model the overall problem

  • domain. None of them can solve the task of

the system alone. A solution can only be built by integrating the results of several knowledge sources. Knowledge sources do not communicate

  • directly. They read from and write to the
  • blackboard. They therefore have to understand

the vocabulary of the blackboard.

14 / 31

slide-15
SLIDE 15

Blackboard Pattern

The control structure component runs a loop that monitors the changes on the blackboard and decides what action to take next. It schedules knowledge source evaluations and activations according to a knowledge application strategy. The basis for this strategy is the data on the blackboard. The strategy may rely on special control knowledge sources which perform calculations

  • n which control decisions are made (e.g.

about progress and termination criteria).

15 / 31

slide-16
SLIDE 16

Blackboard Pattern

Theoretically, it is possible that the blackboard can reach a state at which no knowledge source is applicable. In this case, the system fails to deliver a result. In pracice, it is more likely that each reasoning step introduces several new hypotheses and that the number of possible next steps increases exponentially. The problem is therefore to restrict the alternatives to be taken rather than to find an applicable knowledge source.

16 / 31

slide-17
SLIDE 17

Blackboard Pattern

The Blackboard component defines two procedures: inspect and update Knowledge sources call inspect to check the current solutions on the blackboard. update is used to make changes to the data

  • n the Blackboard.

The Control component runs a loop that monitors changes on the blackboard and decides what actions to take next using nextSource.

17 / 31

slide-18
SLIDE 18

Blackboard Pattern

Sequence of Activities:

  • 1. The main loop of the Control component is started.
  • 2. Control calls the nextSource() method to select the next knowledge source.
  • 3. nextSource() first determines which knowledge sources are potential

contributors by observing the blackboard.

  • 4. nextSource() invokes the condition part of each candidate knowledge source.
  • 5. The Control component chooses a knowledge source to invoke, and a hypothesis
  • r a set of hypotheses to be worked on.

18 / 31

slide-19
SLIDE 19

Blackboard Pattern Implementation

19 / 31

slide-20
SLIDE 20

Blackboard Pattern

  • 1. Define the Problem. Specify the domain of the problem and the general fields
  • f knowledge necessary to find a solution.
  • 2. Define the solution space for the problem.
  • 3. Divide the solution process into steps (e.g. how are solutions transformed into

higher-level solutions, predicting and verifying hypotheses, ...).

  • 4. Divide the knowledge into specialized knowledge sources with certain subtasks.

These subtasks often correspond to areas of specialization.

  • 5. Define the vocabulary of the blackboard.
  • 6. Specify the control of the system. Follows an opportunistic problem-solving

strategy that determines which knowledge sources are allowed to make changes to the blackboard. The aim of this strategy is to construct a hypothesis that is acceptable as a result.

  • 7. Implement the knowledge sources (different technologies may apply: actors,

rule-based system, neural net,...).

20 / 31

slide-21
SLIDE 21

Blackboard Pattern Example Implementation: Radar Defence System 1

1https://social.technet.microsoft.com/wiki/contents/articles/13461.

blackboard-design-pattern-a-practical-c-example-radar-defence-system.aspx

21 / 31

slide-22
SLIDE 22

Blackboard Pattern: Radar Defence System

Figure: The radar defense system is detecting objects (Planes, Rockets, Birds or Unknown) which fly from the bottom to the top of the screen.

22 / 31

slide-23
SLIDE 23

Blackboard Pattern: Radar Defence System

Blackboard

public class Blackboard { public ObservableCollection<IObject> CurrentObjects { get; set; } public Blackboard() { CurrentObjects = new ObservableCollection<IObject>(); } } public interface IObject { ObjectType Type { get; set; } string Name { get; set; } bool? IsThreat { get; set; } ProcessingStage Stage { get; set; } } public enum ObjectType { Unknown, Bird, Plane, Rocket } public enum ProcessingStage { Detected, Analysed, Identified, Actioned } 23 / 31

slide-24
SLIDE 24

Blackboard Pattern: Radar Defence System

Control

class Controller { Blackboard blackboard; List<IKnowledgeSource> KnowledgeSources = new List<IKnowledgeSource>(); List<IKnowledgeSource> OrderedKnowSrc; public Controller(Blackboard board) { blackboard = board; KnowledgeSources.Add( new SignalProcessor(DateTime.Now.Millisecond)); KnowledgeSources.Add(new ImageRecognition()); KnowledgeSources.Add(new PlaneIdentification()); KnowledgeSources.Add(new WarMachine()); OrderKnowledgeBases(); foreach (var ks in OrderedKnowSrc) ks.Configure(blackboard); } void tick(object sender, EventArgs e) { foreach (IKnowledgeSource ks in OrderedKnowSrc) if (ks.IsEnabled) ks.ExecuteAction(); }

The controller runs in a loop, iterating over all the knowledge sources that are active, and executing each. The controller is the decision maker, choosing which knowledge source to execute and in what order. That is supported by a Priority enum which

  • rders the knowledge sources.

The WarMachine knowledge source is top priority and executed first, so any known threats are acted upon, before any further decisions are made.

24 / 31

slide-25
SLIDE 25

Blackboard Pattern: Radar Defence System

Knowledge Source

public interface IKnowledgeSource { KnowledgeSourceType KSType { get; } KnowledgeSourcePriority Priority { get; } bool IsEnabled { get; } void Configure(Blackboard board); void Stop(); void ExecuteAction(); } public enum KnowledgeSourcePriority { Disabled, High, Normal } public enum KnowledgeSourceType { Detector, Analyser, Actioner }

The heart of a blackboard architecture are the knowledge sources. Each knowledge source is responsible for declaring whether it is available for the current state of the problem being analysed. This could be an autonomous process, as the knowledge sources could monitor the blackboard directly. In this example there are multiple problems (detected objects) being analysed, so each knowledge source has an IsEnabled property, which is set if there are any valid objects on the blackboard.

25 / 31

slide-26
SLIDE 26

Blackboard Pattern: Radar Defence System

In this examples there are four knoweldge sources:

  • 1. Signal Processing: the biggest job of number crunching the radar data (eg

spectrogram analysis) into digital data.

  • 2. Image Recognition: comparing the part-processed image with known signatures.
  • 3. Plane Identification: ”Hand-shaking” with onboard computers, requesting voice

contact, checking flight paths, basically deciding if friend or foe.

  • 4. War Machine: if a Rocket or hostile Plane, the military take over and decide how

best to deal with the target (Missile defense, scramble rapid response fighters).

26 / 31

slide-27
SLIDE 27

Blackboard Pattern: Radar Defence System

Knowledge Source SignalProcessor The signal processor is enabled if there are any objects which are not analysed yet and executes its action on these objects.

class SignalProcessor : KnowledgeSourceBase { public override bool IsEnabled { for (var ix = 0; ix < blackboard.CurrentObjects.Count(); ix++) if (blackboard.CurrentObjects[ix].Stage < ProcessingStage.Analysed) return true; return false; } public override void ExecuteAction() { for (var ix = 0; ix < blackboard.CurrentObjects.Count(); ix++) if (blackboard.CurrentObjects[ix].Stage < ProcessingStage.Analysed) ProcessAnotherBit(blackboard.CurrentObjects[ix]); } }

27 / 31

slide-28
SLIDE 28

Blackboard Pattern

Knowledge Source WarMachine The war machine is enabled if there are objects which pose a threat and for which no countermeasures have been actioned and executes its action on these

  • bjects.

class WarMachine : KnowledgeSourceBase { public override KnowledgeSourcePriority Priority { return KnowledgeSourcePriority.High; } public override bool IsEnabled { for (var ix = 0; ix < blackboard.CurrentObjects.Count(); ix++) { var obj = blackboard.CurrentObjects[ix]; if (obj.IsThreat != null && obj.IsThreat.Value && (obj.Stage != ProcessingStage.Actioned)) return true; } return false; } public override void ExecuteAction() { for (var ix = 0; ix < blackboard.CurrentObjects.Count(); ix++) { var obj = blackboard.CurrentObjects[ix] as IncomingObject; if (obj.IsThreat != null && obj.IsThreat.Value && (obj.Stage != ProcessingStage.Actioned)) { if (obj.MoveHitsTarget()) DestroyTarget(obj); } } } } 28 / 31

slide-29
SLIDE 29

Blackboard Pattern Consequences

29 / 31

slide-30
SLIDE 30

Blackboard Pattern

Benefits

  • Experimentation. Needed in domains in which no closed approach exists and a

complete search of the solution space is not feasible, e.g. trying different control heuristics. Support for changeability and maintainability. Individual knowledge sources, the control algorithm and the central data structure are strictly separated. Where all modules communicate via the blackboard. Reusable knowledge sources. Knowledge sources are independent specialists for certain tasks. The prerequisites for reuse are that knowledge source and the underlying blackboard system understand the same protocol and data, or are close enough in this respect not to rule out adaptors for protocol or data. Support for concurrency. The blackboard architecture supports concurrency and decouples senders from receivers, thus facilitating maintenance.

30 / 31

slide-31
SLIDE 31

Blackboard Pattern

Drawbacks Difficulty of testing. Since the computations of a Blackboard system do not follow a deterministic algorithm, its results are often not reproducible. In addition, wrong hypotheses are part of the solution process. Dfficulty of establishing a good control strategy. The control strategy cannot be designed in a straightforward way, and requires an experimental approach. No good solution is guaranteed. Usually Blackboard systems can solve only a certain percentage of their given tasks correctly. High development effort. Most Blackboard systems take years to evolve, which is attributed to the ill-structured problem domains and extensive trial-and-error programming when defining vocabulary, control strategies and knowledge sources.

31 / 31