JuliaDynamics / DiscreteEvents.jl

Discrete event generation and simulation in Julia
MIT License
56 stars 10 forks source link

Information update #43

Closed ga72kud closed 2 years ago

ga72kud commented 2 years ago

I have two events (movement of agent A and agent B). The agent movements are set in a certain class and realized as objects (mutable structs). I want to compute the distance between the two agents in a third event.

Currently the distance is only computed on the initial position. I guess I have to use the push!(...., newposition) command to update the positions. I see in the documentation that you are using the push! command. It is not clear to me, why. I currently get some errors.

   println(typeof(x))
   println(typeof(obj.state))
   push!(obj.state, x)

ERROR:
LoadError: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type Float64

x and obj.state are from type Vector{Float64}. So I do not understand the error. With the push! command I want to update the current state (position) of each agent by a new value x.

Update: it seems that it does not work in different modules. take! for a channel does not produce an error, but the simulation does not continue.

ga72kud commented 2 years ago

Update It works for me, if I use the Channel in the main script only.