Commit d880650f authored by Bentriou Mahmoud's avatar Bentriou Mahmoud
Browse files

implementation of probability_var_value_lha

parent b3e1e771
......@@ -28,7 +28,7 @@ export get_index, get_value, length_var, isaccepted
# Model related methods
export simulate, volatile_simulate
export distribute_mean_value_lha, mean_value_lha, distribute_prob_accept_lha
export distribute_mean_value_lha, mean_value_lha, distribute_prob_accept_lha, probability_var_value_lha
export set_param!, set_x0!, set_time_bound!, set_observed_var!, observe_all!
export get_param, get_x0, getproperty, get_proba_model, get_observed_var
export isbounded, isaccepted, check_consistency
......
......@@ -382,6 +382,21 @@ function mean_value_lha(sm::SynchronizedModel, sym_var::VariableAutomaton, nbr_s
end
return sum_val / nbr_sim
end
"""
`distribute_var_value_lha(sm::SynchronizedModel, nbr_sim::Int, value = 0, sym_var = :d)
Compute the probability that the variable `sym_var` is equal to `value`
of a LHA over `nbr_sim` simulations of the model.
"""
function probability_var_value_lha(sm::SynchronizedModel, nbr_sim::Int;
value::Float64 = 0.0, sym_var::VariableAutomaton = :d)
sum_val = @distributed (+) for i = 1:nbr_sim
S = volatile_simulate(sm)
S[sym_var] == value
end
return sum_val / nbr_sim
end
function distribute_prob_accept_lha(sm::SynchronizedModel, nbr_sim::Int)
sum_val = @distributed (+) for i = 1:nbr_sim
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment