LABSS / PROTON-OC

Simulation of recruitment to organized crime
MIT License
4 stars 2 forks source link

BUG: in RETURN-KIDS, nlogo.nvm.RuntimePrimitiveException: That person is dead. #168

Open mariopaolucci opened 4 years ago

mariopaolucci commented 4 years ago

Here, pretty self-explanatory. The bug comes out in the runs of the 0.9.3 series

Run #3, RUNTIME ERROR: That person is dead.
error while observer running OF
  called by (anonymous command: [ a -> let last but-last a if any? turtle-set father [ if [ age ] of last a >= 18 [ if random-float 1 < 6 / first a [ ask last a [ create-offspring-link-from father ] set removed-fatherships remove a removed-fatherships ] ] ] ])
  called by procedure RETURN-KIDS
  called by procedure GO
  called by procedure __EVALUATOR
org.nlogo.nvm.RuntimePrimitiveException: That person is dead.
        at org.nlogo.nvm.AnonymousCommand.perform(AnonymousProcedure.scala:181)
        at org.nlogo.nvm.AnonymousCommand.perform(AnonymousProcedure.scala:158)
        at org.nlogo.prim.etc._foreach.perform(_foreach.scala:33)
        at org.nlogo.nvm.Context.stepConcurrent(Context.java:107)
        at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.scala:65)
        at org.nlogo.job.JobThread.runPrimaryJobs(JobThread.scala:133)
        at org.nlogo.job.JobThread.$anonfun$run$1(JobThread.scala:68)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at scala.util.control.Exception$Catch.apply(Exception.scala:228)
        at org.nlogo.api.Exceptions$.handling(Exceptions.scala:41)
        at org.nlogo.job.JobThread.run(JobThread.scala:66)
mariopaolucci commented 4 years ago

To reproduce the issue, I have set

set num-persons 1000
set num-oc-persons 1000
set number-crimes-yearly-per10k 10000

and I have changed a line of code to pump up arrests: set arrest-rate number-arrests-per-year / ticks-per-year / number-crimes-yearly-per10k / 1000 * count persons instead of set arrest-rate number-arrests-per-year / ticks-per-year / number-crimes-yearly-per10k / 10000 * count persons.

I run with while [length removed-fatherships < 3] [go] print "finito" and I kill all the prisoners with observer> ask turtle-set map [a -> last but-last a] removed-fatherships [ if my-job != nobody [ ask my-job [ set my-worker nobody ] ] if my-school != nobody [ ask my-school [ set my-students other my-students ] ] die] (bit long, ok).

Under those conditions, I get removed-fatherships to length 8 at step 14. This means that even if the kids are very small, I'll get a re-add before long - that is, if the kids are 12, they will get to 18 in 72 steps.. how old are they? And then there's just a chance they get re-added- should have tweaked that too.

Indeed, it uncooly arrived to 230 steps without anything happening. I'm starting to think it's the turtle-set that solved it for dead fathers - maybe it's a dead offspring?

And yes, it was a dead OFFSPRING - exactly same error obtained - something that points to family reunitions happening too rarely. Let's review that:

        if (random-float 1) < 6 / (first a) [
          ask last a [ create-offspring-link-from father ]
          set removed-fatherships remove a removed-fatherships
        ]

Can't find a way to explain that - 6 / the number of ticks? That variable contains ((18 * ticks-per-year + birth-tick) - ticks). Well it's ok, it amounts to just the number of ticks spent in separation, and makes them slower to return. However, in two years they should all be back.

mariopaolucci commented 4 years ago

Ok, it should be solved when interface goes up.. in the end I clean up the list during the death routine.