[julia-users] Re: scoping rule help for functions within functions
Mauro, are there any new scoping issues raised by the use of parallelization? Are variables in global scope automatically available to different processors? R
[julia-users] Puzzling over @parallel
Running 0.4.0-dev+5933. I expected the print outs from this code to be the same and to equal zero. What am I doing wrong? Thanks in advance. addprocs(4); @everywhere function test(state) return state.^2.0 end const n = 1; const m = 1; states = randn(n); store = zeros(n,m); for i = 1:n j = 1:m state = states[i] store[i,j] = i-j+test(state) end stored = SharedArray(typeof(1.0),n,m); @parallel for i = 1:n j = 1:m state = states[i] stored[i,j] = i-j+test(state) end println(maximum(store-stored)) println(maximum(store-stored)) rmprocs(2:5);
Re: [julia-users] Puzzling over @parallel
Thanks Tim. Richard On Wednesday, July 22, 2015 at 12:27:52 PM UTC+1, Tim Holy wrote: > > Just put @sync in front of @parallel. The workers are not yet done with > their > tasks before you run your test. > > Please capture these hints by making pull requests to improve the parallel > documentation---you'll save future users the confusion you're suffering > (sorry), and other developers the time in answering. > > https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#improving-documentation > > > --Tim > > On Tuesday, July 21, 2015 03:58:19 PM Richard Dennis wrote: > > Running 0.4.0-dev+5933. I expected the print outs from this code to be > the > > same and to equal zero. What am I doing wrong? Thanks in advance. > > > > addprocs(4); > > > > @everywhere function test(state) > > return state.^2.0 > > end > > > > const n = 1; > > const m = 1; > > states = randn(n); > > store = zeros(n,m); > > for i = 1:n j = 1:m > > state = states[i] > > store[i,j] = i-j+test(state) > > end > > > > stored = SharedArray(typeof(1.0),n,m); > > @parallel for i = 1:n j = 1:m > > state = states[i] > > stored[i,j] = i-j+test(state) > > end > > > > println(maximum(store-stored)) > > println(maximum(store-stored)) > > > > rmprocs(2:5); > >
[julia-users] Re: GtkIDE.jl, a semi-functional editor for Julia
Hi, after I type using GtkIDE I get the following. Any thoughts? - INFO: Precompiling module Immerse... - ERROR: LoadError: LoadError: UndefVarError: absolute_native_units not defined in include at boot.jl:261 in include_from_node1 at loading.jl:320 in include at boot.jl:261 in include_from_node1 at loading.jl:320 [inlined code] from none:2 in anonymous at no file:0 in process_options at client.jl:257 in _start at client.jl:378 while loading C:\Users\rd125m\.julia\v0.4\Immerse\src\compose.jl, in expression starting on line 13 while loading C:\Users\rd125m\.julia\v0.4\Immerse\src\Immerse.jl, in expression starting on line 31
[julia-users] A question about expressions
I'm fiddling around with expressions and I'm puzzled why the following tells me that k is not defined. Any thoughts would be appreciated. # a = is a 3D array # b = a vector of vectors vars = [[symbol("i1")]; [symbol("i2")]; [symbol("i3")]] glomp = :( inner_prod = a[$(vars...)]; for k = 1:size(b,1); inner_prod *= b[k][$(vars[k])]; end; ) I realize that it is probably obvious, but the reason eludes me.
[julia-users] Re: A question about expressions
Thanks Cedric. I've found a way to construct the product I needed. Richard
[julia-users] Pesky type instability
I wrote a generate function to compute Chebyshev weights using Chebyshev regression. I'm sure that there are many ways the code could be improved, but at the top of my list is eliminating what appears to be a type instability whose source I'm having trouble locating using @code_warntype. Any suggestions on how to eliminate the type instability would be appreciated. The code can be found at the following gist: https://gist.github.com/RJDennis/a0ea1e4e49da97edaa464ba2a8d701ab Thanks, Richard
[julia-users] Re: Pesky type instability
Hi Kristoffer, yes, the return type is stable because I explicitly declared weights as Array{T,N}. With order being a 1D array it needs to be "converted" to a tuple to initialize the weights array and I don't see too many ways of doing this. The problem seems to be present is the following function test{S}(order::Array{S,1}) h = (order...) end @code_warntype test([1,2,3]) so perhaps the type instability to within the julia code that does the splatting to create the tuple. Regarding my use of strings and parsing them, I realize that it is not so elegant, but does it impact performance? Thanks, Richard
[julia-users] Re: Parallel computing and type-stability
When I run this code in Julia 0.5.0-rc4 the code is much shorter and most of the red indicating type instability is gone. Cheers.
[julia-users] Re: FastGauss.jl: fast computation of Gauss quadrature rules
Nice work. You might also want to check out https://github.com/billmclean/GaussQuadrature.jl On Monday, September 1, 2014 10:33:31 PM UTC+1, Alex Townsend wrote: > > I have written a package FastGauss.jl available here: > > https://github.com/ajt60gaibb/FastGauss.jl > > to compute Gauss quadrature rules to 16-digit precision (so far Legendre, > Jacobi, Lobatto, Radau), > aiming to be the fastest implementation in Julia. For example, this is how > long > it takes to compute 1,000,000 Gauss-Legendre nodes and weights: > > tic(), GaussLegendre( 100 ); toc() > elapsed time: 0.336489122 seconds > > > In my comparisons, GaussLegendre() is faster than Base.gauss() for n>60 > (nothing in it for > small n), but my implementation right now does not allow for higher > precision. I couldn't find a > Gauss-Jacobi code in Base. > > I am a Julia beginner (only been learning for 2 weeks) so I am assuming > the code can be > improved in a million and one ways. Please tell me if I've done something > that Julia does > not like. I am not sure if it is appropriate to make this an official > package. >
[julia-users] Combining modules with parallel computing
The follow (contrived) code illustrates a problem that I would like to overcome. The problem seems to be one of getting the contents of a module seen by multiple processors. Is there any solution other than stripping the functions out of the module, putting them into a separate file and then using require(). Any suggestions appreciated. addprocs(3) using NLsolve function fixed_point_system(x,f) f[1] = x[1].^2.0+x[2].^2.0+1.0 f[2] = x[1]-0.7*x[2]-0.7 return f end function solve_fixed_point_system(init,tol) z1 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol) z2 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol) z3 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol) z4 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol) z1 = fetch(z1) z2 = fetch(z2) z3 = fetch(z3) z4 = fetch(z4) z = (z1.zero+z2.zero+z3.zero+z4.zero)/4 return z end const tol = 1e-12 init = [0.2, 1.0] fixed_point = solve_fixed_point_system(init,tol) println(fixed_point)
[julia-users] Re: Combining modules with parallel computing
Thanks Sam. Your suggestion combined with using require on the two functions and it works. On Sunday, 7 September 2014 14:31:53 UTC+1, Sam Kaplan wrote: > > Hi Richard, > > Give > > @everywhere using NLSolve > > a try. Hope that helps. > > Sam > >
[julia-users] @spawn and PyPlot
Hi All, does anyone else get an error when they run the following in REPL: addprocs(1) using PyPlot a = @spawn randn(2,2) fetch(a) After fetch(a) I get the following: Worker 2 terminated. Error: ProcessExitedException() in wait at task.jl:284 Thanks, Richard
[julia-users] Re: @spawn and PyPlot
Right. I don't get the error in version 0.3.1 either. But I do get it in version 0.4.0-dev+371 commit c6036da. On Monday, 13 October 2014 23:10:52 UTC+1, Richard Dennis wrote: > > Hi All, > > does anyone else get an error when they run the following in REPL: > > addprocs(1) > using PyPlot > a = @spawn randn(2,2) > fetch(a) > > After fetch(a) I get the following: > > Worker 2 terminated. Error: ProcessExitedException() in wait at task.jl:284 > > Thanks, > > Richard >
[julia-users] Re: @spawn and PyPlot
It has something to do with the update of PyPlot from 1.3.0 to 1.4.0. It does not occur with the former, but does with the latter. On Monday, 13 October 2014 23:10:52 UTC+1, Richard Dennis wrote: > > Hi All, > > does anyone else get an error when they run the following in REPL: > > addprocs(1) > using PyPlot > a = @spawn randn(2,2) > fetch(a) > > After fetch(a) I get the following: > > Worker 2 terminated. Error: ProcessExitedException() in wait at task.jl:284 > > Thanks, > > Richard >
[julia-users] Re: @spawn and PyPlot
Thanks David. I understand the general advice, but once PyPlot is ungraded to version 1.4 the error occurs in Julia 0.3.1 as well. So the problem is to do with changes in PyPlot and not with changes in Julia. I'll report the issue with PyPlot. On Tuesday, 14 October 2014 14:38:04 UTC+1, David P. Sanders wrote: > > Ah, I see. I suggest reporting an issue in the PyPlot repository un that > case. > > But in any case, the general advice is that packages are not expected to > work with the dev version until it stabilises somewhat. >
[julia-users] [ANN - SolveDSGE] A Julia package to solve DSGE models
Hi All, I have posted a package called SolveDSGE on github: https://github.com/RJDennis/SolveDSGE The package contains a variety of methods for solving Dynamic Stochastic General Equilibrium (DSGE) models to to first- or second-order accuracy. The package will be of most interest to macro-economists, but others may find the routines for reordering the complex Schur form and the generalized complex Schur form useful. I am still very new to Julia so I'm sure that much of the code could be improved. Nevertheless, I hope that some people will find the package useful for their research. Cheers, Richard
Re: [julia-users] Re: [ANN - SolveDSGE] A Julia package to solve DSGE models
Others on this forum can probably speak with more authority than me about Dynare as I have never used it My understanding is that in its initial stages there were versions of Dynare in c++, Gauss, and Matlab. The c++ and Gauss versions have long since become obsolete and disappeared. The extent to which c++ is exploited by the Matlab Dynare is not clear to me, but I don't think it is used a lot --- Dynare users do not oooh and h over its speed. Where Dynare aims to be an entire modeling ecosystem for estimating, solving, and simulating models with a parser that allows its users to specify their model much as they would write it on paper, SolveDSGE is a much more modest creation, focusing for now on the solution part. Solving DSGE models is the bread and butter of much applied macro so a package like SolveDSGE seemed necessary to get macro-economists to adopt Julia. Once the Dynare team decide that the Julia market is big enough I have no doubt that they will release something that wipes the floor with my little creation (which ironically aims to grow the market), but until then Cheers, Richard On Tuesday, 2 December 2014 18:27:41 UTC, Viral Shah wrote: > > Last commit was in June... > > -viral > On 2 Dec 2014 23:47, "Pileas" > wrote: > >> Has anyone tried to run these examples? >> >> It seems that something is obsolete ... >> >> Τη Τρίτη, 2 Δεκεμβρίου 2014 12:20:28 μ.μ. UTC-5, ο χρήστης David Anthoff >> έγραψε: >>> >>> https://github.com/DynareTeam/Dynare.jl >>> >>> >>> >>> >>> >>> *From:* julia...@googlegroups.com [mailto:julia...@googlegroups.com] *On >>> Behalf Of *Viral Shah >>> *Sent:* Tuesday, December 2, 2014 8:52 AM >>> *To:* julia...@googlegroups.com >>> *Subject:* [julia-users] Re: [ANN - SolveDSGE] A Julia package to solve >>> DSGE models >>> >>> >>> >>> Tangential, but I have heard (no experience) that Dynare is the tool of >>> choice for DSGE modeling, and it appears that much of Dynare is in C++. Do >>> you know anything about how easy it would be to get Dynare working with >>> Julia? As I understand they only use Matlab for plotting and convenience, >>> but not for real computation. >>> >>> >>> >>> -viral >>> >>> On Tuesday, December 2, 2014 1:34:01 AM UTC+5:30, Richard Dennis wrote: >>> >>> Hi All, >>> >>> >>> >>> I have posted a package called SolveDSGE on github: >>> https://github.com/RJDennis/SolveDSGE >>> >>> >>> >>> The package contains a variety of methods for solving Dynamic Stochastic >>> General Equilibrium (DSGE) models to to first- or second-order accuracy. >>> The package will be of most interest to macro-economists, but others may >>> find the routines for reordering the complex Schur form and the generalized >>> complex Schur form useful. >>> >>> >>> >>> I am still very new to Julia so I'm sure that much of the code could be >>> improved. Nevertheless, I hope that some people will find the package >>> useful for their research. >>> >>> >>> >>> Cheers, >>> >>> >>> >>> Richard >>> >>> >>> >>>
Re: [julia-users] Re: [ANN - SolveDSGE] A Julia package to solve DSGE models
Hi Sebastien, some collaboration down the line would make sense. Thus far, I haven't been working on a unified framework like Dynare, but rather trying to develop a set of solution tools that give people flexibility over how they solve their problems. Will you be at either of the SNDE or CEF conferences next year? Feel free to contact me directly, outside of this forum. Cheers, Richard On Wednesday, 3 December 2014 09:43:05 UTC, seba...@debian.org wrote: > > Hi Richard (and other participants to this thread), > > Concerning Dynare: it is indeed written in MATLAB/Octave (with some parts > in C++, like the preprocessor and some optimized portions of code). Dynare > currently covers a very large range of features, and replicating all of > them in Julia would take a lot of time. The Dynare Team has currently no > plan to port the existing Dynare to Julia, given the size of this endeavour > and the limited resources of the team. > > However, as has already been pointed, I have started writing something > from scratch (https://github.com/DynareTeam/Dynare.jl). This package is > able to solve models at first order in rational expectations mode, and with > full nonlinearities in perfect foresight mode. The interesting thing about > this package is that you can write equations naturally as you would in > Dynare: the package uses the Julia parser to get the equations and to > compute their symbolic derivatives, and then forms the model matrices > automatically. > > I am rather busy at the moment so I have not been able to improve on that > package in the last couple of months. But it should be functional. > Bugreports and improvements are welcome. I definitely plan to continue > working on it when time permits. I may get help from other members of the > Dynare Team, but this is not guaranteed at this stage. > > Richard: it would be great if we could join our efforts and create a nice > Julia package for DSGE modeling, out of our two prototypes. I am open to > any suggestion, so feel free to get back to me. > > Best, > > -- > Sébastien Villemot > Economist > OFCE — Sciences Po > http://sebastien.villemot.name > >
[julia-users] Re: [ANN - SolveDSGE] A Julia package to solve DSGE models
Hi All, I have added some new functionality to SolveDSGE that allows the solution of various linear-quadratic optimal policy problems to be computed. Specifically, for various model forms, SolveDSGE can compute policies under:1) discretion; 2) commitment; 3) quasi-commitment; and 4) timeless-perspective commitment. I hope that people find this functionality useful. Richard
[julia-users] A question about chol()
Why is the following not okay? s = [0.1 0.09; 0.09 0.5] z = chol(s) t = z[:,1] This gives a dimension error. The following does work s = [0.1 0.09; 0.09 0.5] z = chol(s) y = convert(Array,z) t = z[:,1] Somehow it seems to me that the convert() should not be needed.
[julia-users] Re: causes of system crash?
I get crashes a lot running Julia on Windows when running long simulations. In my case, it seems to be related to @parallel as it does not happen when I take these out and run the program on one core. It happens on both my desktop and my laptop, both Windows machines.