简体   繁体   English

具有驻留持续时间的有限可能非确定性状态机

[英]A finite possibly non-deterministic state machine with dwell durations

after posting a somewhat ambiguous question , I believe I have nailed that what I am wondering (I am a complete novice in FSMs).在发布了一个有点模棱两可的问题之后,我相信我已经确定了我的疑惑(我是 FSM 的完全新手)。

I would like to simulate a state space using finite state machines (possibly non-deterministic automata ie multiple next-state transitions allowed) in clojure.我想在 clojure 中使用有限状态机(可能是非确定性自动机,即允许多个下一状态转换)来模拟状态空间。

This is essentially my problem:这基本上是我的问题:

Suppose we have these states Q={flying,cycling,running,driving} and we have the state durations for each during an average day D={120,30,30,60} - where for the sake of argument those are in minutes.假设我们有这些状态Q={flying,cycling,running,driving}并且我们有平均一天中每个状态的持续时间D={120,30,30,60} - 为了论证,这些以分钟为单位. How can one then create a possibly non-deterministic FSM (multiple destination states allowed) using clojure?那么如何使用 clojure 创建一个可能的非确定性 FSM(允许多个目标状态)? I have looked at eg https://github.com/cdorrat/reduce-fsm and https://github.com/ztellman/automat but I do not believe it is quite what I want.我看过例如https://github.com/cdorrat/reduce-fsmhttps://github.com/ztellman/automat但我不相信这正是我想要的。

My end goal is to get a simulation looking something like S = {flying,flying,flying,flying,flying,cycling,cycling,running,driving,driving,driving} .我的最终目标是让模拟看起来像S = {flying,flying,flying,flying,flying,cycling,cycling,running,driving,driving,driving}

Effectively inducing heavy self-transition bias in the state machine.有效地在状态机中引起严重的自转移偏差。 End and start state are not important.结束和开始状态并不重要。

The problem is not completely formulated to be answered unequivocally. 这个问题并未完全解决,不能明确回答。 Anyway: If you just want to recognize a specific sequence of states, you can use a finite automaton, and you will have to write them in that order, like: 无论如何:如果您只想识别特定的状态序列,则可以使用有限的自动机,并且必须按此顺序编写它们,例如:

flying -> flying -> flying -> flying -> flying -> cycling -> cycling -> running -> driving -> driving -> driving

where I'm considering that the transitions are caused by the durations you refer. 我在考虑过渡是由您所指的持续时间引起的。

However, I suspect that you possibly need something more elaborated. 但是,我怀疑您可能需要更详细的说明。 That, can not be elaborated here. 那个,在这里不能详细说明。 In my opinion if this is for programming purposes, I suggest that you use state machine diagrams from UML. 我认为如果这是出于编程目的,建议您使用UML中的状态机图。 They are powerful enough for your problem. 它们足以解决您的问题。

I would recommend:我会推荐:

  1. Draw the picture with states, transitions, and conditions for transitions.绘制带有状态、转换和转换条件的图片。
  2. Check the picture for consistency, dead loops, etc.检查图片的一致性、死循环等。
  3. Implement FSM for yourself using maps and vectors.使用地图和向量为自己实现 FSM。 Do not use other FSM libraries until you need something heavy from FSM.不要使用其他 FSM 库,除非您需要 FSM 的一些重要内容。

Here is an example of such an approach for ants simulation Ant FSM这是蚂蚁模拟Ant FSM这种方法的一个例子

  1. When the ant is born it goes for food.当蚂蚁出生时,它会去觅食。
  2. If ant sees a threat then it runs away from the threat.如果蚂蚁看到威胁,它就会逃离威胁。
  3. If the threat disappears then an ant continues to find food.如果威胁消失,蚂蚁会继续寻找食物。
  4. If food is found by ants then it goes for home.如果蚂蚁找到食物,它就会回家。
  5. If an ant sees a threat then it runs away from the threat with food.如果蚂蚁看到威胁,它就会用食物逃离威胁。
  6. If the threat disappears then an ant continues to return home.如果威胁消失,那么蚂蚁会继续回家。
  7. If ant at home it put food inside anthill then goes for food.如果蚂蚁在家,它会将食物放入蚁丘,然后去觅食。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM