简体   繁体   English

阵列在Anylogic中的步进函数

[英]Step Function For Array in Anylogic

How to use an step function for an array in Anylogic? 如何在Anylogic中对数组使用步进功能? step function is applied to double values, but I want to applied on elements of an array at a specific time. step函数应用于双精度值,但是我想在特定时间应用于数组的元素。

You can't... so this is a solution: 您不能...所以这是一个解决方案:

Instead of an array you should use a linkedHashMap where your key is the specific time and the element is the step value you want at that time. 代替数组,您应该使用linkedHashMap,其中您的键是特定时间,而元素是您当时想要的步长值。 So you defined it as follow: 因此,您将其定义如下:

linkedHashMap

And you put the values like this: 然后将这样的值放入:

stepsArray.put(3.0,2.3); 

where 3.0 is the time in which the step will occur and 2.3 is the value the step will take. 其中3.0是执行步骤的时间,而2.3是执行步骤的值。 You have to put there all the values you need. 您必须在其中放置所需的所有值。 You are the one who has to fill these values according to your needs. 您是必须根据自己的需要填写这些值的人。

Then you create an cyclic event that will evaluate if it's time to apply a step and you create a variable of type double that will be the one storing the value of the step. 然后,创建一个循环事件,该事件将评估是否应该应用步骤,并创建一个double类型的变量,该变量将是存储步骤值的变量。

So, the event: 因此,该事件:

double theTime=round(100*time())/100.0;//it's better to round up the time just in case
if(stepsArray.containsKey(theTime)){
    variable=stepsArray.get(theTime);
}

note that I'm using a variable, not a dynamic variable.. they you can connect the variable to wherever your step is needed in the sd model. 请注意,我使用的是变量,而不是动态变量。他们可以将变量连接到sd模型中需要执行步骤的任何位置。

This method is a bit complicated, but it's the most general for your completely ambiguous question. 这种方法有点复杂,但是对于您完全模棱两可的问题,这是最通用的方法。

Not sure Felipe's approach is the best one but maybe I misunderstand the question. 不确定费利佩的方法是最好的方法,但也许我误解了这个问题。

Have you tried using a "table function" object? 您是否尝试过使用“表函数”对象? Define it as below where the horizontal axis represents the time unit and the vertical your step function data: 在下面定义它,其中水平轴代表时间单位,垂直轴代表步进功能数据: 在此处输入图片说明

Then, use a cyclic event that every relevant time unit (depends on your model) pulls the current required value from the table function: 然后,使用一个循环事件,每个相关时间单位(取决于您的模型)从表函数中提取当前所需的值: 在此处输入图片说明

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

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