Menu

#3 crash in MonteCarlo integration

open
nobody
None
5
2003-04-19
2003-04-19
No

When using many iterations in MonteCarlo integration,
the program crashes from time to time:

---
p2 = Proc.new {|k, p|
p / (1.0 - cos(k[0]) * cos(k[1]) * cos(k[2]))
}

a = 1.0 / (M_PI * M_PI * M_PI)
dim = 3

f = Function.new dim, a, p2
plain = Plain.new dim

xl = [0.0, 0.0, 0.0]
xu = [M_PI, M_PI, M_PI]
calls = 10000
rng = Random::RNG.new

r = plain.integrate f, xl, xu, calls, rng
result = r[0]
abserr = r[1]
---

Crash occurs in Monte.c (MFunction_function) when the
call to the Proc object is made (rb_funcall).

I suspect it is something with the memory management.
Probably the COPYCARRAY/COPYRUBYARRAY macros
do some harm if called too often.

BTW: Could this be a Ruby problem (see attached file)?

Discussion

  • Arno Erpenbeck

    Arno Erpenbeck - 2003-04-19
     
  • Nobody/Anonymous

    Logged In: NO

    I tried to reproduce this bug but cannot; I increased the
    calls parameter to
    10000000 (ten million) and still no crash. I wonder if it
    works on my system
    because I have the latest Ruby checked out from the CVS tree?

     
  • Rudi Cilibrasi

    Rudi Cilibrasi - 2003-04-25

    Logged In: YES
    user_id=756654

    BTW that above testing comment is by Rudi, me, I wasn't
    logged in.

     
  • Arno Erpenbeck

    Arno Erpenbeck - 2003-04-25

    Logged In: YES
    user_id=755035

    It's strange, because sometimes it runs fine on my machines,
    and sometimes it crashes. Also, if I put in some debug
    output, it never crashes...

    Maybe someone from the Ruby community knows some
    help, I will check.

     
  • Arno Erpenbeck

    Arno Erpenbeck - 2003-05-03

    Logged In: YES
    user_id=755035

    I replaced the macro COPYCARRAY and now it seems to work.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.