On Tuesday, April 28, 2015 02:45:59 AM 'Antoine Messager' via julia-users wrote: > I would love too but it seems that NLsolve does not accept anonymous > function.
I'd be really surprised if this were true. Search the README for "->". --Tim > > <https://lh3.googleusercontent.com/-spe5mTRqJDQ/VT9WpGNgDEI/AAAAAAAAABg/_caa > IfVwkec/s1600/Capture%2Bd%E2%80%99e%CC%81cran%2B2015-04-28%2Ba%CC%80%2B10.44 > .04.png> > Le lundi 27 avril 2015 18:38:30 UTC+1, Tim Holy a écrit : > > gc() doesn't clear memory from compiled functions---the overhead of > > compilation is so high that any function, once compiled, hangs around > > forever. > > > > The solution is to avoid creating so many compiled functions. Can you use > > anonymous functions? > > > > --Tim > > > > On Monday, April 27, 2015 10:22:20 AM 'Antoine Messager' via julia-users > > > > wrote: > > > And then (approximatively): > > > > > > * myfunction = eval(code_f)* > > > > > > Le lundi 27 avril 2015 18:21:09 UTC+1, Antoine Messager a écrit : > > > > I use meta programming to create my function. This is a simpler > > > > example. > > > > > > The parameters are generated randomly in the actual function. > > > > > > > > * lhs = {"ode1"=> :(fy[1]), "ode2"=> :(fy[2])};* > > > > * rhs = {"ode1"=> :(y[1]*y[1]-2.0), "ode2"=> :(y[2]-y[1]*y[1])};* > > > > > > > > * function code_f(lhs::Dict, rhs::Dict)* > > > > * lines = {}* > > > > * for key in keys(lhs)* > > > > * push!(lines, :( $(lhs[key]) = $(rhs[key])) )* > > > > * end* > > > > * @gensym f* > > > > * quote* > > > > * function $f(y, fy)* > > > > * $(lines...)* > > > > * end* > > > > * end* > > > > * end* > > > > > > > > Le lundi 27 avril 2015 18:12:24 UTC+1, Tom Breloff a écrit : > > > >> Can you give us the definition of make_function as well? This is > > > > being > > > > > >> run in global scope? > > > >> > > > >> On Monday, April 27, 2015 at 12:37:48 PM UTC-4, Antoine Messager > > > > wrote: > > > >>> When I input the following code, where myfunction is only a system > > > > of 2 > > > > > >>> equations with 2 unknowns, the code starts to be really slow after > > > >>> 10,000 > > > >>> iterations. NLsolve is a non linear solver ( > > > >>> https://github.com/EconForge/NLsolve.jl). > > > >>> > > > >>> * size=2* > > > >>> * for k in 1:100000* > > > >>> * myfun=make_function(size);* > > > >>> * try{* > > > >>> * res=nlsolve(myfun,rand(size))* > > > >>> * }* > > > >>> * end* > > > >>> * end* > > > >>> > > > >>> Thank you for your help, > > > >>> Antoine > > > >>> > > > >>> Le lundi 27 avril 2015 16:30:19 UTC+1, Mauro a écrit : > > > >>>> It is a bit hard to tell what is going wrong with essentially no > > > >>>> information. Does the memory usage of Julia go up more than you > > > > would > > > > > >>>> expect from storing the results? Any difference between 0.3 and > > > > 0.4? > > > > > >>>> Anyway, you should try and make a small self-contained runable > > > > example > > > > > >>>> and post it otherwise it will be hard to divine an answer. > > > >>>> > > > >>>> On Mon, 2015-04-27 at 16:49, 'Antoine Messager' via julia-users < > > > >>>> > > > >>>> [email protected]> wrote: > > > >>>> > Dear all, > > > >>>> > > > > >>>> > I need to create a lot of systems of equation, find some > > > >>>> > > > >>>> characteristics of > > > >>>> > > > >>>> > each system and store the system if of interest. Each system is > > > >>>> > > > >>>> created > > > >>>> > > > >>>> > under the same name. It works fine for the first 1000 systems but > > > >>>> > > > >>>> after the > > > >>>> > > > >>>> > program starts to be too slow. I have tried to use the garbage > > > >>>> > > > >>>> collector > > > >>>> > > > >>>> > each time I create a new system but it did not speed up the code. > > > > I > > > > > >>>> don't > > > >>>> > > > >>>> > know what to do, I don't understand where it could come from. > > > >>>> > > > > >>>> > Cheers, > > > >>>> > Antoine
