Skip to content

mapteb/blackboard-pattern-using-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blackboard Design Pattern Using Python

This repo has an implementation of the Blackboard design pattern in Python

Components

The module bbpattern has three classes - Blackboard, BBController and KS (KnowledgeSource possibly using AI Agent). The Blackboard object holds a BBTask object which inturn holds a List[BBSubTask] object. The BBController holds a set of KS objects. The KS object has an asynchronous process() method. Each KS (possibly using an AI Agent) is specialized in solving a specific problem.

How it Works

The Blackboard Pattern solves (or partially solves) a large complex problem by assembling part solutions. The blackboard engine (the main() method) receives data (possibly as a data stream from various IoT devices) that need to be analyzed and some action taken (like an autonomous vehicle that needs to take the next step).

  1. The engine adds the BBController as a subscriber (Observer) to the Blackboard. It also configues the controller with a set of KS objects.
  2. The engine places each sub-task that it receives from an external source on the Blackboard.
  3. The Blackboard updates the BBController whenever its state changes (subTask is addded)
  4. The BBController holds a set of KS objects that it can launch as a worker Coroutine by assigning the subTask. Each KS object is specialized in handling a a part of the whole problem. The BBController launches the KS that is knowledgable in handling a specfic subTask.
  5. The KS worker/s perform the subTask asynchronously. When completed, updates the Blackboard with the completed subTask.
  6. A BBTask is considered completed when all the BBSubTasks have their isComplete() returning True.

Input / Output

When the module is run (python BBPatternApp.py), the following output is generated:

>> adding a new subTask to he Blackboard
>> BBController received a new subTask
>> BBController assigning the subTask to a KS worker
>> KS worker performing subTask in a Coroutine
>> Task long-running: Starting...
>> Task long-running: Finished.
>> KS completed the subTask and updating the Blackboard

Use Cases

Here are some scenarios where the Blackbord pattern could be employed

  1. Stream of sensors data in an autonomous vehicle and the vehicle needs to take the next set of acions incrementally
  2. A TV station headquarters receiving stream of election voting counts from various sub-stations and need to create a dashboard of the results incrementally (The KS workers for various regions like Northeast, South, etc. have specialized knowledge of how to analyze the election counts of their regions) etc.

About

Implements the Blackboard design pattern in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages