From c22108a37c9fd34cf9e20f88905432cf074071c2 Mon Sep 17 00:00:00 2001 From: Mahmoud Bentriou <mahmoud.bentriou@centralesupelec.fr> Date: Tue, 22 Dec 2020 01:17:12 +0100 Subject: [PATCH] more methods set_x0! --- core/MarkovProcesses.jl | 2 +- core/model.jl | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/MarkovProcesses.jl b/core/MarkovProcesses.jl index 26aafb0..d971b80 100644 --- a/core/MarkovProcesses.jl +++ b/core/MarkovProcesses.jl @@ -30,7 +30,7 @@ export get_index, get_value, length_var, isaccepted export simulate, volatile_simulate export distribute_mean_value_lha, mean_value_lha, distribute_prob_accept_lha export set_param!, set_x0!, set_time_bound!, set_observed_var!, observe_all! -export get_param, getproperty, get_proba_model, get_observed_var +export get_param, get_x0, getproperty, get_proba_model, get_observed_var export isbounded, isaccepted, check_consistency export draw_model!, draw!, fill!, prior_pdf!, prior_pdf, insupport diff --git a/core/model.jl b/core/model.jl index f4a117b..7857f93 100644 --- a/core/model.jl +++ b/core/model.jl @@ -465,6 +465,17 @@ function set_param!(am::Model, l_name_p::Vector{ParameterModel}, p::Vector{Float set_param!(m, l_name_p[i], p[i]) end end +function set_x0!(am::Model, l_name_var::Vector{VariableModel}, x0::Vector{Int}) + m = get_proba_model(am) + @assert length(l_name_var) == length(x0) "State names vector state values haven't the same dimensions" + for i = eachindex(l_name_var) + set_x0!(m, l_name_var[i], x0[i]) + end +end +function set_x0!(am::Model, name_var::VariableModel, var_i::Int) + m = get_proba_model(am) + m.x0[m.map_var_idx[name_var]] = var_i +end function set_x0!(am::Model, new_x0::Vector{Int}) m = get_proba_model(am) @assert length(new_x0) == m.dim_state "New x0 vector hasn't the dimension of state space" @@ -472,8 +483,8 @@ function set_x0!(am::Model, new_x0::Vector{Int}) end set_time_bound!(am::Model, b::Float64) = (get_proba_model(am).time_bound = b) - get_param(am::Model) = get_proba_model(am).p +get_x0(am::Model) = get_proba_model(am).x0 function getindex(am::Model, name_p::ParameterModel) m = get_proba_model(am) m.p[m.map_param_idx[name_p]] -- GitLab