Diffuse only certain patches?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Diffuse only certain patches?

KEsquivel
Hi-

I'm wondering if there's a way to diffuse only certain patches, or diffuse
different patch types at different rates. I am having difficulty using the
diffuse function because it is observer only, but I was hoping to find
another way in which I may allow a patch variable to be shared at different
rates for different patch types (in my case I have grey patches, and
non-grey patches).

Thanks!
KE



--
Sent from: http://netlogo-users.18673.x6.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Diffuse only certain patches? [1 Attachment]

Francois Guerrin
Hi KE,

below is a way to do that, taking here as an example patch color as the
diffusion parameter. But any patches-owned parameter may be dealt with
the same as well.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

     patches-own [init-pcolor] ; this is to recall the initial pcolor
before the process of assigning new values patch after patch in random
order starts

     to Alter-diffuse-color [who? rate]        ;; rate is the diffusion
rate (within the range (0 1))

         ;; who? can be any patch-set (patches, patches with [pcolor =
??]... or individual patch x y

       ask patches [set init-pcolor pcolor] ; each patch recalls its
initial pcolor
       ask who? [
             let amount init-pcolor * rate                  ;; the
amount to be shared with the neighbors
             let neighbor-share amount / 8             ;; each neigbor
will get 1/8th of the amount to share
             ask neighbors [set pcolor pcolor + neighbor-share] ;; the
neighors get their share
             set pcolor pcolor - (neighbor-share * count neighbors) ;;
the donor patch loses what it gave to its receiving neighbors
       ]
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
E.g. launching the procedure :
     Alter-diffuse-color patches 0.5
gives exactly the same result as
      diffuse pcolor 0.5
Checked on a single patch e.g:
     Alter-diffuse-color patch  3 2
provides also the expected result.

Checking it on a bigger cluster is more difficult because of patches
multiple interactions, but I'm confident it should also work.

Hoping it will provide you with some help.
Cheers,

FG

Le 22/03/2018 à 00:40, KEsquivel [hidden email] [netlogo-users] a écrit :

>
> Hi-
>
> I'm wondering if there's a way to diffuse only certain patches, or diffuse
> different patch types at different rates. I am having difficulty using the
> diffuse function because it is observer only, but I was hoping to find
> another way in which I may allow a patch variable to be shared at
> different
> rates for different patch types (in my case I have grey patches, and
> non-grey patches).
>
> Thanks!
> KE
>
> --
> Sent from: http://netlogo-users.18673.x6.nabble.com/
>
>

--

SignatureMail-FG.png (33K) Download Attachment