[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Glenn Fulford
Hi Christopher, You are right, there are not many examples out there of using Julia for agent based models, at least as far as I can see. I am not sure if you know about this one, but in the excellent QuantEcon website, they give an example of Schelling's model of segregation with some

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Scott Jones
You might also want to think about using BitVectors to store the information about whether a person was infected, vaccinated, or deceased (which would take only 3 bits per person), and then you could easily perform operations to find out the number of people infected, etc. using the bit

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
You might be right. I previously coded a simple simulation similar to what you described. In this simulation, individuals were stored in a vector and their properties were represented as integers (e.g. recovered: 3, infected: 1, not infected: 0 etc.). I used an adjacency matrix to represent

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread David P. Sanders
El sábado, 4 de junio de 2016, 18:18:00 (UTC-4), Christopher Fisher escribió: > > Ok. I didn't anticipate this would be a drawn out process. I just Ford's > suggestion fixed the issue of changing values but recreated the problem of > accessing an individual's information like so:

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
Ok. I didn't anticipate this would be a drawn out process. I just Ford's suggestion fixed the issue of changing values but recreated the problem of accessing an individual's information like so: population[2] . population[:,2] did not work either. I tried other changes to the syntax but to

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
Got it. Thanks for clarifying. On Saturday, June 4, 2016 at 5:49:39 PM UTC-4, Steven G. Johnson wrote: > > > > On Saturday, June 4, 2016 at 5:05:47 PM UTC-4, Christopher Fisher wrote: >> >> Thanks Ford. Is there a reason you discourage using symbols? I opted for >> the symbols partly because I

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Steven G. Johnson
On Saturday, June 4, 2016 at 5:05:47 PM UTC-4, Christopher Fisher wrote: > > Thanks Ford. Is there a reason you discourage using symbols? I opted for > the symbols partly because I couldn't get your example to work. So I > combined code from the various answers until something worked. > > I

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
Thanks Ford. Is there a reason you discourage using symbols? I opted for the symbols partly because I couldn't get your example to work. So I combined code from the various answers until something worked. I also noticed some odd behavior with the present implementation and I think its part of

[julia-users] Re: ANN: PkgSearch - a REPL utility for package discovery

2016-06-04 Thread David P. Sanders
El viernes, 3 de junio de 2016, 16:40:50 (UTC-4), Adrian Salceanu escribió: > > Hi, > > I have released PkgSearch, a small REPL utility for package discovery. > > Very nice work! > Package discovery seemed to be a recurring issue, with many related > questions - and I can still remember

Re: [julia-users] ANN: PkgSearch - a REPL utility for package discovery

2016-06-04 Thread Tim Holy
This looks awesome, thanks for tackling this. I'll post over at your repo about any issues I notice. Best, --Tim On Friday, June 3, 2016 1:40:50 PM CDT Adrian Salceanu wrote: > Hi, > > I have released PkgSearch, a small REPL utility for package discovery. > > Package discovery seemed to be a

Re: [julia-users] Uniform syntax

2016-06-04 Thread Tim Holy
Right, but perhaps that prior about "I'm probably not the first person ever to have thought about this" could be bumped up a notch or two. I'm not saying there aren't things that need fixing (there are many, it's why julia is still being actively developed), but at this stage julia is not brand

[julia-users] Re: ANN: PkgSearch - a REPL utility for package discovery

2016-06-04 Thread Adrian Salceanu
Hi, thanks very much for the feedback, much appreciated. 1. good point, haven't considered that as package names don't have spaces. But nonetheless, a search with spaces should definitely be all right. I fixed the issue and pushed on GitHub - it now considers whitespace as a keyword

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Ford Ox
I would like to discourage you from passing symbols as an array index but I guess you gonna do it anyway... So if you really want it, here it is: setindex!(p::Population, value, field::Symbol, index...) = p.individuals[ index...].(field) = value getindex(p::Population, field::Symbol, index...)

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
Thanks everyone for your helpful suggestions. Although a few details seem fuzzy, I think I am learning quite a bit and I am very close to the final product. Combining Ford's initial code, Steve's code and David's code allowed me to access the information from specific individuals (e.g.

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Ford Ox
FWIW [individual.infected for individual in population] #list of all infected individuals typealias Population Vector{Individual} population = Population(0) On Saturday, June 4, 2016 at 4:48:29 PM UTC+2, Christopher Fisher wrote: > > Thank you for your help. > > So my basic goal is to be

Re: [julia-users] Uniform syntax

2016-06-04 Thread Ford Ox
I have this on my mind, so 75% of my ideas / questions don't make it to this forum. On Saturday, June 4, 2016 at 5:02:19 PM UTC+2, Steven G. Johnson wrote: > > On Saturday, June 4, 2016 at 4:31:55 AM UTC-4, Ford Ox wrote: >> >> I know that I have close to zero experience in julia compared to

Re: [julia-users] Uniform syntax

2016-06-04 Thread Stefan Karpinski
Because `for i = 1:10` is pretty clear but `for i = v` looks like it's assigning `v` to `i` rather than assigning each value in `v` to `i`. The recommended practice is to use `=` when the RHS is a range and `in` when the RHS is a value. On Sat, Jun 4, 2016 at 12:25 PM, Ford Ox

Re: [julia-users] Uniform syntax

2016-06-04 Thread Ford Ox
If for i=1:10 is less verbose than for i in 1:10, why do we keep the second version around?

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread David P. Sanders
You can define a `Population` type and overload `getindex` for it to do what you want, something like: type Person infected::Bool vaccinated::Bool dead::Bool history::Vector{Int} end type Population <: AbstractArray individuals::Vector{Person} end Population() =

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
Thanks for your suggestions Steven. You are correct. I could many of those fields as Boolean and maybe there is a reason to prefer that rather than using 1 and 0s. Initially, I also tried to push the individuals into an empty array as you suggested. This worked well, except I was not able to

Re: [julia-users] Uniform syntax

2016-06-04 Thread Steven G. Johnson
On Saturday, June 4, 2016 at 4:31:55 AM UTC-4, Ford Ox wrote: > > I know that I have close to zero experience in julia compared to you. > That's why I created this thread, because *discussion* doesn't *damage * > anything. > No, but uninformed discussion can waste people's time, and decreases

Re: [julia-users] errors using packages in parallel

2016-06-04 Thread Ethan Anderes
Just synchronized the julia versions to the exact commit number (using `git checkout 430601c` on my laptop). The problem still persists. I wonder if I should just open an issue on github and move the conversation there. I just wanted to make sure I wasn't making an obvious mistake with the

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
Thank you for your help. So my basic goal is to be able to perform operations on the individual and population level. In this case, population.infected would return an Array{Int64,1} indicating which individuals in the population are infected. For example, population.infected[1] = 1 would

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Steven G. Johnson
On Saturday, June 4, 2016 at 8:19:02 AM UTC-4, Christopher Fisher wrote: > > I was wondering if someone would be willing to help me with creating > user-defined types. I've been using Julia for about two years now but I am > new to the idea of creating custom types. I'm trying to create a

[julia-users] Re: Help creating user-defined types and constructors

2016-06-04 Thread Ford Ox
Could you please specify what should population.infected return? Could you provide an interface? Right now it seems like you want something like this: type Individual end type Population individuals::Vector{Individual} end setindex!(p::Population, i::Individual, index...) =

[julia-users] Help creating user-defined types and constructors

2016-06-04 Thread Christopher Fisher
I was wondering if someone would be willing to help me with creating user-defined types. I've been using Julia for about two years now but I am new to the idea of creating custom types. I'm trying to create a population of agents/individuals in a simple epidemiological simulation. I would like

[julia-users] Re: ANN: PkgSearch - a REPL utility for package discovery

2016-06-04 Thread Evan Fields
Hi, this looks great. Two comments from playing around a little bit. 1) PkgSearch.lookup fails if any of the arguments contain a space. In general maybe add to the documentation some notes about whitespace, case sensitivity, etc.? 2) The search seems to get confused between package names and

Re: [julia-users] errors using packages in parallel

2016-06-04 Thread Tim Holy
On Friday, June 3, 2016 5:48:24 PM CDT Ethan Anderes wrote: > I just checked and the package versions are the same (v0.1.8). However, the > julia versions on my laptop is slightly different from what is on the > server (Version 0.4.6-pre+37 vrs Version 0.4.6-pre+36). Is that a problem? Very

Re: [julia-users] errors using packages in parallel

2016-06-04 Thread Ethan Anderes
So, @everywhere Pkg.build("Dierckx") didn’t help, and Fortran is working fine on the servers (recall that the code works fine when the workers are launched from the server with addprocs(2)). However, just to rule out anything having to do with Fortran I decided to test a few code

Re: [julia-users] Uniform syntax

2016-06-04 Thread Ford Ox
> > In Julia 0.5, [1, 2, 3] and [1; 2; 3] do not mean the same thing > That means that 'classic' way of doing arrays is available in 0.5? (I have 0.45 and both mine and your example don't work there) a = [[1, 2, 3, 4], [9, 8, 7, 6]] a[0][0] > 9 Syntax 3 is not available since it already

Re: [julia-users] Signal / slot (or publish-subscribe) libraries in Julia

2016-06-04 Thread Tim Holy
I've sometimes also wished for an imperative version of Reactive, but Shashi has pointed out some pretty serious advantages of a declarative approach. My favorite is `throttle`, which allows you to make many separate updates to various `Signal`s and yet allow some operation that depends on all

Re: [julia-users] errors using packages in parallel

2016-06-04 Thread Tony Kelman
That may cause recompilation to happen. Do you also have the Fortran library installed on all machines? If not, @everywhere Pkg.build("Dierckx") may help. On Friday, June 3, 2016 at 5:48:24 PM UTC-7, Ethan Anderes wrote: > > Hi Tim: > > I just checked and the package versions are the same

Re: [julia-users] Re: big on the mac with large matrices

2016-06-04 Thread Tony Kelman
And where exactly did you install Julia from? The staticfloat/homebrew-julia tap, the OSX binaries, homebrew-cask (which should be the same as the OSX binaries), source build, etc? On Friday, June 3, 2016 at 2:55:21 PM UTC-7, Stefan Karpinski wrote: > > What BLAS library are you using? I.e.