MRC-CSO-SPHSU / LoneParentsModel.jl

An initial implementation of an ABM for social and child care
0 stars 5 forks source link

a future reason for calling seed! before loading model parameters #139

Closed AtiyahElsheikh closed 2 years ago

AtiyahElsheikh commented 2 years ago

Since one can read in Julia code, it is apparently straightforward to call parameter values according to an input statistical distribution, e.g. Unfiorm(0.0,10.0) or Normal(10.0,0.5) This looks more elegant rather than reading in distribution parameters as one can even easily switch between a distribution to another.

AtiyahElsheikh commented 2 years ago

p.s.: If the related input parsing package is within independent repository, I would have wrote an issue there. That looks good that kind of discussion is associated with it and it is good to record its progress history.

mhinsch commented 2 years ago

It might look elegant in the source code, but you would have to jump through hoops to make it work in parameter files or on the command line. I think the most straightforward solution (for a problem that at this point is purely hypothetical, might I add) is probably to have one (String) parameter that describes the type of distribution and another (Vector{Float64}) that lists the parameters. Which would also remove the need to seed before reading parameters.

AtiyahElsheikh commented 2 years ago

I have enhanced module ParamType with the following code:

reseed0!(simPars) = 
    simPars.seed = simPars.seed == 0 ?  floor(Int, time()) : 
                                        simPars.seed 

function seed!(simPars::SimulationPars,
                randomizeSeedZero=true)
    if randomizeSeedZero 
        reseed0!(simPars)
    end
    Random.seed!(simPars.seed)
end