I want to discourage you from using symbols because although it perfectly works for you right now, but you might get into trouble later.
Lets say you want to add an array into Population and you want to keep symbol indexing: Population persons newarray end #You can't do population[:newarray, index] #Unless you rewrite your code and change population[:persons, :attribute, index] Or you decide, that you wanna make new interface: population[:persons, index] population[:attribute, index] population[index] # throws error This also wont be possible, so you end up rewriting all your code. I wish it would be possible to do this in julia setindex!(population, value, ::Individual, index...) = population. individuals[index...] = value setindex!(population, value, ::Infected, index...) = population.individuals[ index...].infected = value population[::Individual, 1] = Individual() population[::Infected, 1] = true # Note that I have not declared Infected type anywhere Which would eliminate all kind of problems, but I am not sure it's codeable or wanted in the first place. So since this is not possible, I would stick to classical functions, as I showed you in the very first post in this discussion. On Sunday, June 5, 2016 at 7:06:32 AM UTC+2, Glenn Fulford wrote: > > 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 > example code. > > http://nbviewer.jupyter.org/github/QuantEcon/QuantEcon.applications/blob/master/schelling/schelling_solutions_jl.ipynb > > But I think maybe what you are trying to do is a little bit more than > this, but just thought I would mention this example in case you hadn't seen > it. > Glenn > > > On Saturday, 4 June 2016 22:19:02 UTC+10, 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 population >> of agents/individuals in a simple epidemiological simulation. >> >> type Person >> infected::Int64 >> vaccinated::Int64 >> dead::Int64 >> history::Array{Int64,1} >> end >> >> Any help would be greatly appreciated. >> >
