Skip to content

Commit

Permalink
Merge branch 'misc_polish' into dev
Browse files Browse the repository at this point in the history
misc_polish had been closed
  • Loading branch information
PTWaade committed Apr 14, 2024
2 parents 7016dd3 + 4c3e217 commit 754870f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
15 changes: 10 additions & 5 deletions src/create_agent/init_agent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function init_agent(
action_model::Function;
substruct::Any = nothing,
parameters::Dict = Dict(),
parameter_groups::Dict = Dict(),
parameter_groups::Union{ParameterGroup, Vector{ParameterGroup}} = Vector{ParameterGroup}(),
states::Union{Dict,Vector} = Dict(),
settings::Dict = Dict(),
save_history::Bool = true,
Expand Down Expand Up @@ -137,9 +137,13 @@ function init_agent(
end


#If ther is only one parameter group, wrap it in a vector
if parameter_groups isa ParameterGroup
parameter_groups = [parameter_groups]
end

#Go through each specified shared parameter
for (parameter_group, parameter_value) in parameter_groups
for parameter_group in parameter_groups

#check if the name of the shared parameter is part of its own derived parameters
if parameter_group.name in parameter_group.parameters
Expand All @@ -152,16 +156,17 @@ function init_agent(

#Set the parameter group in the agent
agent.shared_parameters[parameter_group.name] = GroupedParameters(
value = parameter_value,
value = parameter_group.value,
grouped_parameters = parameter_group.parameters,
)

#Set the parameters
set_parameters!(agent, parameter_group, parameter_value)
reset!(substruct)
set_parameters!(agent, parameter_group, parameter_group.value)

end

#Reset the substruct to make sure initial states are correct, after setting the grouped parameters
reset!(substruct)


#Initialize states
Expand Down
1 change: 1 addition & 0 deletions src/structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Type for specifying a group of parameters
Base.@kwdef mutable struct ParameterGroup
name::String
parameters::Vector
value::Real
end

"""
Expand Down
31 changes: 0 additions & 31 deletions test/utility_tests.jl

This file was deleted.

0 comments on commit 754870f

Please sign in to comment.