Home > Software design >  How do I define a variable in Anylogic that show the value of another variable in yesterday?
How do I define a variable in Anylogic that show the value of another variable in yesterday?

Time:08-04

Available variable count the number of walking in a day by statechart. The new variable that I need to define is the number of walking in yesterday.

CodePudding user response:

If it is really just about yesterday, create 2 variables endOfToday and endOfYesterday.

At the end of the day (or when your statechart triggers), you call:

endOfYesterday  = endOfToday;
endOfToday = newValueFromToday;

If you need to store all values, you can use a DataSet and add an entry each day.

CodePudding user response:

Now, I have two variables dailyTravelByWalk that it get its value from my statechart and yesterdayTravelByWalk that it get its value from the yesterday value of dailyTravelByWalk by a event. In addition, I have another variable (Id) that it is equal with dailyTravelByWalk / yesterdayTravelByWalk. When I run the model, NaN error appear. If I remove Id, I do not have NaN error.please click this pic link, yesterdayTravelByWalk

please click this pic link, Id

You think what is the problem? thank you for your help.

  • Related