anylogic - How I can evaluate a condition on next time-step in anylogic?
问题描述
I am trying to write a code for one state to another state transition where the system will first store the initial model time and then will check a condition (used while loop). It will continue to run the loop until the condition is false and when the condition is false it will record the final model time. So, my main objective is to get the total time that while loop condition is true. The problem is, I don't know how to check the while loop every 1 time step, For example, I tried "wait (1);" in place of "???" section of the below code which is not correct. Can anyone please suggest how I can do this?
My transition code as below: ... ...
initialTime=time();
while ((thisPed.inState(walking) && thisPed.fieldOfVision.contains(pedX, pedY));
{
???
}
finalTime= time();
exposureTime = finalTime - initialTime;
... ...
解决方案
you can't put while statements in a model that at the same time run with time steps... to do that you have many other ways..
For instance you can generate a transition that goes from that state to the same state (internally) and generate your code there every time step.
Another option is to use a conditional transition in the same way
BUt NOT a while loop
推荐阅读
- mysql - 如何避免添加重复的外键约束
- arrays - 关联列的脚本
- angular - Angular buildOptimizer 打破引导轮播过渡效果
- python-3.x - 单例类实例化:RecursionError:超出最大递归深度
- azure - Azure 函数 Cosmos DB 输出绑定 - 自定义 JsonSerializerSettings
- javascript - Meteor/Cordova 应用程序未将 graph.facebook 图像保存到数据缓存中
- android - 在滚动视图中滚动firebase Recyclerview到最后插入的项目
- android - 我应该为 compileSdkVersion、minSdkVersion 和 targetSdkVersion 设置什么以支持从 Marshmallow 到 Pie?
- dart - 使用 source_gen 包,我怎样才能获得初始值设定项?
- google-chrome-extension - 在 chrome 扩展中使用嵌套异步调用传递消息失败