NetLogo / NetLogo/Time-Extension
time:plus doesn't work as expected with Logotimes
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 8
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Here is a second unfortunate "feature" of the time extension... The
behavior of time:plus seems to depend on the format used to create the
Logotime variable that is its first argument.
In the attached code, you will see that, in "setup", there are two
alternative statements to initialize the value of sim-start-time. One
initializes this Logotime using text input with millisecond precision
and the second uses input with one hour precision.
The value of sim-start-time is then used to initialize "sim-time", which
is the Logotime variable linked to ticks (in the time:anchor-to-ticks
statement).
To see the problem, do this:
-
Use the first "set sim-start-time" statement, leaving the 2nd one
commented out. -
Click "setup" and then "step", which runs one time step. (I set the
time step to 1.3 hours to make the problem visible.) -
In the Command Center, enter this:
show time:plus sim-time 1.0 "minutes"
You will see that the result is correct: 09:19:00.000
-
Now comment out the first "set sim-start-time" statement and instead
use the second. -
Again use "setup" and "step" and enter the same statement in the
Command Center. Now you will see that the result is wrong: 09:01:00.000
It appears that because sim-time was initialized with another Logotime
that was initialized with hour precision, time:plus truncates its value
to the previous hour before adding to it.
That behavior is certainly not in the documentation and doesn't make
sense to me. I think Logotimes initialized as DateTime values should
always have millisecond precision.
I'm sure this is a mistake from our original version but it raises havoc
with discrete event simulation and was not easy to find!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the setup and step actions, using each of the two sim-start-time initialization statements, then run time:plus sim-time 1.0 "minutes" in the Command Center. Inspect the time:plus and Logotime precision handling; done means both initialization paths preserve millisecond precision and return the expected 09:19:00.000 result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100