Skip to content

Commit

Permalink
make random generation of stochastic models less restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
emuskardin committed Apr 24, 2024
1 parent 0ee6f55 commit d65dab6
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions aalpy/utils/AutomatonGenerators.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,11 @@ def generate_random_mdp(num_states, input_size, output_size, possible_probabilit

deterministic_model = generate_random_deterministic_automata('moore', num_states, input_size, output_size)

if input_size > output_size:
assert False, 'Cannot create deterministic MDP (in all states, all input-output pairs leads to a single state)' \
', if number of inputs is smaller than number of outputs)'

if not possible_probabilities:
possible_probabilities = [(1.,), (1.,), (1.,), (0.9, 0.1),
(0.8, 0.2), (0.7, 0.3), (0.8, 0.1, 0.1), (0.7, 0.2, 0.1), (0.6, 0.2, 0.1, 0.1)]
# ensure that there are no infinite loops
max_prob_num = min(num_states, input_size)
max_prob_num = min(num_states, output_size)
possible_probabilities = [p for p in possible_probabilities if len(p) <= max_prob_num]

mdp_states = []
Expand Down Expand Up @@ -322,15 +318,11 @@ def generate_random_smm(num_states, input_size, output_size, possible_probabilit
output_al = list(set([o for state in deterministic_model.states for o in state.output_fun.values()]))
output_al.sort()

if input_size > output_size:
assert False, 'Cannot create deterministic SMM (in all states, all input-output pairs leads to a single state)' \
', if number of inputs is smaller than number of outputs)'

if not possible_probabilities:
possible_probabilities = [(1.,), (1.,), (1.,), (0.9, 0.1),
(0.8, 0.2), (0.7, 0.3), (0.8, 0.1, 0.1), (0.7, 0.2, 0.1), (0.6, 0.2, 0.1, 0.1)]
# ensure that there are no infinite loops
max_prob_num = min(num_states, input_size)
max_prob_num = min(num_states, output_size)
possible_probabilities = [p for p in possible_probabilities if len(p) <= max_prob_num]

smm_states = []
Expand Down

0 comments on commit d65dab6

Please sign in to comment.