0

To design the movement of one agent based on agent's neighbors position. We come usually to this control protocol:

x'_i(t) = ai1*x_i(t)+ +aij*x_j(t) ; j=1,..,N, 
  • N is the total neighbor of i.
  • aij : are the constant (design coefficient).

at the end we come to solve this equation:

x'(t) = Ax(t) : A is a design matrix, x is the position of the agent.

one of the simplest case could be: (x,y are neighbors)

x'(t) = x(t) + 2y(t)
y'(t) = 2x(t) + y(t)

Is there any numerical method to solve this equation. So that at each tick time, I can display the x(t) and y(t).

In matlab we have ode45 solver to do this. But with Netlogo I don't know how. With Runge-Kutta Method it work only with one variable x(t) = f(x,t).

Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51
realgalois
  • 1
  • 1
  • 2
  • Have you looked at https://stackoverflow.com/q/29564018/3088138 as an example of changing Euler to RK4 in LOGO – Lutz Lehmann Dec 02 '17 at 17:11
  • I have looked carefully with the answer, but it 's still not clear for me. The runge Kutta method can be used for first order matrix equation but in Centralized method, with agent-based method, I don't know how. – realgalois Dec 03 '17 at 20:07

1 Answers1

4

NetLogo is inherently discrete in its treatment of time, not continuous. It is also agent-centric (so work out the model rule from the perspective of the agent, not someone external).

Treat this as a difference equation. You could store attributes (in your case: x, x-prime) for each agent. Having decided on your meaning of neighbor (eg the closest agent, the agent at the other end of a randomly chosen link), then you directly calculate the new value of x-prime and set the agent's variable to that value.

If you want them all to update at the same time, your code could look something like this:

turtles-own
[ x
  x-prime
  next-x
  next-x-prime
]

to setup
  clear-all
  create-turtles 10
  [ setxy random-xcor random-ycor
    set x random-float 10
    set x-prime random-float 10
  ]
  reset-ticks
end

to go
  ask turtles
  [ let partner one-of other turtles
    set next-x x + x-prime
    set next-x-prime x + 2 * [x] of partner * [x-prime] of partner
  ]
  ask turtles
  [ set x next-x
    set x-prime next-x-prime
  ]
  tick
end
JenB
  • 17,620
  • 2
  • 17
  • 45