简体   繁体   English

随机取合金

[英]Take a random Object in Alloy

Let's say you have a basic elevator system defined in Alloy... You have a set of floors and a set of people waiting on the elevator on each floor. 假设您有一个用Alloy定义的基本电梯系统...您有一组楼层,每个楼层上都有一群人在等待电梯。 You work with State to show the progress the elevator makes. 您与State合作以显示电梯的进度。 How can you send the elevator in the initial state to a random floor to pick up his first person? 您如何将处于初始状态的电梯发送到随机楼层去接他的第一个人? (aka; how can you randomise the element alloy takes?) (又名;如何随机化元素合金的含量?)

I think what you want to do here is to leave the initial state unspecified. 认为您要在此处进行的操作是保留未指定的初始状态。 That is, describe its existence, clarify that there is exactly one, but leave it unspecified which of the possible states is the initial state. 就是说,描述其存在,明确存在一个,但未指定哪个可能的状态是初始状态。

The Alloy Analyzer will then check your assertions and predicates for all possible initial states, and will (eventually) generate instances of the model for all possible initial states. 然后,合金分析器将检查所有可能的初始状态的断言和谓词,并(最终)生成所有可能的初始状态的模型实例。 This resembles the behavior of a good random number generator, in that the likelihood of any given state being chosen as the initial state is equal to the likelihood of any other given state being chosen -- it's just that the likelihood here becomes 1.0, not 1/n for n possible states. 这类似于一个好的随机数生成器的行为,因为选择任何给定状态作为初始状态的可能性等于选择任何其他给定状态的可能性-只是这里的可能性变为1.0,而不是1 / n表示n个可能的状态。

最好说一个随意的楼层,而不是随机的楼层。

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

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