任何人有这样使用Blackboard Pattern的想法? [英] Anyone have thoughts on using the Blackboard Pattern in this way?

查看:140
本文介绍了任何人有这样使用Blackboard Pattern的想法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人对实用程序员的第165页有任何关于Blackboard概念的想法吗?



我想要有几个小型子系统(DLL和EXE)主要是彼此独立的。所有EXE都将使用一些程序集。这些程序集几乎都使用相同的数据库。而不是使用界面来进行这些程序集之间的通信,Blackboard类型模式不会提供更多的独立性?



我在想一些通过事件通知的调解器类型构造,并且所有子系统通信都通过它。这使得syb系统非常独立。调解员将持有应广播的所有通知的名称。然后,用户将按名称听特定的事件,但始终订阅相同的(或者可能通过名称作为参数)调解器事件。



这里有更多的讨论: a href =http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22829492.html =noreferrer> http://www.experts-exchange.com/Programming/Languages/C_Sharp/ Q_22829492.html

解决方案

黑板的概念是,多个独立的进程在工作时运行和更新黑板它的碎片。一个典型的例子是语音识别。输入数据是要识别的音频。音频可以被分割,并且多个线程开始将片段匹配到单词。当每个线程找到匹配的单词时,他们使用翻译将黑板更新为此。当短语开始组装时,另一个线程可以进行语法检查,以验证各种识别器线程正在进行的选择。如果一个词的信心低,违反了语法,那么该片可以重新运行寻找替代品。这可能会导致音频数据重新分区,因为stutters和暂停被解决。



随着短语变成句子,甚至可以采用更大的视图,同音(对,对)可以解决。所有这些都是通过将黑板打开到所有进程和锁,只有在各种结果滚动时才被应用。



使用数据库作为黑板有意义的是,您可以免费获得交易,但这取决于更新和重新读取数据的积极性。如果发生很快,往返行程会相加,使内存结构更加合理。



您的调解者的想法有意义,因为它创建了一个单一的锁定点,而黑板算法很少遇到A-> B,B-> A风格的死锁,因为他们要求所有的数据元素在前面。除此之外,放弃锁不是一个很大的惩罚,因为各种子任务将随着数据滚动而重新启动。当他们拥有的数据已经过时时,需要通知董事会的订户,这可以通过回调来完成,该回调将使用最新的数据重新启动任务。



就工作流的注释而言:这里的主要区别是大多数工作流程是协调的通过一个主进程,采取刚刚进入的状态,并决定什么状态可用于数据移动。虽然可能有独立的演员,但他们很少会通过创造更好的结果(其他任务将使用)相互参与超越。换句话说,一个工作流通常是一组数据非常有限的数据,而黑板几乎是一个独立的活动的空闲。 (也就是说,黑板可能在你的工作流程之后: http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-247/FORUM_15.pdf



我可以没有想到我看到的任何C#示例,我所做的工作类型没有太多的调用(计算是确定性的)。进行一些搜索查找其他语言的参考文献,但没有出现很好的质量。


Does anyone have any thoughts of the Blackboard concept from p.165 of 'The Pragmatic Programmer'?

I want to have several small sub-systems (DLLs and EXEs) mostly independent of each other. There are some assemblies that will be used by all EXEs. These assemblies will nearly all use the same database. Rather than using interfaces for communication between these assemblies, wouldn't a Blackboard type pattern provide more independence?

I'm thinking of some mediator type construct that notifies via events and all sub-system communication goes through it. This keeps the syb-systems very independent. The mediator will hold the name of all notifications it should broadcast. Subscribers will then listen to a particular event by name but always subscribe to the same (or perhaps pass name as parameter) mediator event.

Here's some more discussion on it: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22829492.html

解决方案

The concept of a blackboard is that multiple independent processes run and update the blackboard as they work out pieces of it. A classic example is speech recognition. The input data is the audio that is to be recognized. The audio can be segmented and multiple threads start matching the snippets to words. As each thread finds matching words, they update the blackboard with the translation up to this point. As phrases start to be assembled another thread can do grammar checking to verify the choices the various recognizer threads are making. If a word has a low confidence and violates the grammar, the piece can be rerun looking for alternatives. This might even result in re-partitioning the audio data as stutters and pauses are resolved.

As the phrases become sentences, even larger views can be taken and the various options for homophones (pair, pare) can be resolved. All of this is done by having the blackboard open to all of the processes and "locks" only being applied as they various results roll in.

Using a database as your blackboard makes some sense because you get transactions "for free", but it would depend on how aggressively the data is being updated and re-read. If it is happening very quickly the round trips would add up and make an in memory structure more reasonable.

Your idea of a mediator makes sense as it creates a single lock point... and blackboard algorithms rarely encounter the A->B, B->A style deadlocks because they ask for all the data elements up front. Beyond that, giving up on a lock isn't a large penalty as the various sub-tasks will be restarting all the time as the data rolls in. Subscribers to the board will need to be notified when the data they have has become obsolete, which could be done with callbacks which would restart the task with the newest data.

As far as the comment about a workflow: the major difference here is that most workflows are coordinated by a master process that takes the state just entered and makes decisions as to what states become available for the data to move within. While there may be independent actors, they rarely get involved in "outdoing" one another by creating better results (which other tasks will then use). In other words, a workflow is usually a very constrained set of states that data marches through, while a blackboard is almost a free-for all of independent activity. (That said, a blackboard could be behind your workflow: http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-247/FORUM_15.pdf)

I can't think of any C# examples of the pattern that I have seen, and the type of work I do doesn't have much call for it (the computations being deterministic). Doing some searches find references in other languages, but none that appear of great quality.

这篇关于任何人有这样使用Blackboard Pattern的想法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆