def supc3(g2, g1): """ This function is an alternative do supc2 where a list of SPEC_local, and a list of G_local are passed as parameters. Its performance can be enhanced.""" st_out = {} # g1 = PLANT # g2 = SPEC states_to_be_visited_in_g1 = list() states_to_be_visited_in_g2 = list() g_initial_states_list = list() g_events_set = set() for g_i in g1: g_initial_states_list.append(g_i.initial_state) g_events_set.update(g_i.events_set()) e_initial_states_list = list() e_events_set = set() events_in_more_than_one_spec = set() for spec_i in g2: e_initial_states_list.append(spec_i.initial_state) for event_i in spec_i.events_set(): if event_i in e_events_set: events_in_more_than_one_spec.add(event_i) e_events_set.update(spec_i.events_set()) states_to_be_visited_in_g1.append(g_initial_states_list) states_to_be_visited_in_g2.append(e_initial_states_list) s1 = states_to_be_visited_in_g1.pop() s2 = states_to_be_visited_in_g2.pop() state_name_string = str() state_mark = True for state_i in e_initial_states_list: state_name_string += '|' + state_i.name state_mark = state_mark and state_i.mark for state_i in g_initial_states_list: state_name_string += '|' + state_i.name state_mark = state_mark and state_i.mark current_state_out = automata.State(state_name_string, state_mark) state_out_dict = dict() state_out_dict[state_name_string] = current_state_out out_initial_state = current_state_out common_events = g_events_set.intersection(e_events_set) while s1: while s2: st_out[current_state_out] = {} active_events_g = set() active_events_spec = set() for g_i, s_i in zip(g1, s1): for event_g_i in g_i.transitions[s_i].keys(): active_events_g.add(event_g_i) for spec_i, s_i in zip(g2, s2): for event_e_i in spec_i.transitions[s_i].keys(): active_events_spec.add(event_e_i) for ev1 in active_events_g: if ev1 not in common_events: state_name_string = str() state_mark = True for state_i in s2: state_name_string += '|' + state_i.name state_mark = state_mark and state_i.mark for state_i, g_i in zip(s1, g1): if ev1 in g_i.transitions[state_i].keys(): state_name_string += '|' + g_i.transitions[ state_i][ev1].name state_mark = state_mark and g_i.transitions[ state_i][ev1].mark else: state_name_string += '|' + state_i.name state_mark = state_mark and state_i.mark if state_name_string not in state_out_dict: state_out_dict[state_name_string] = automata.State( state_name_string, state_mark) state_to_be_visited_gather_s1 = list() for state_i, g_i in zip(s1, g1): if ev1 in g_i.transitions[state_i].keys(): state_to_be_visited_gather_s1.append( g_i.transitions[state_i][ev1]) else: state_to_be_visited_gather_s1.append(state_i) states_to_be_visited_in_g1.append( state_to_be_visited_gather_s1) states_to_be_visited_in_g2.append(s2) st_out[current_state_out][ev1] = state_out_dict[ state_name_string] elif ev1 in active_events_spec: # check if destination state is bad state flag_bad_state_one = False next_active_events_g = set() next_active_events_spec = set() for spec_i, s_i in zip(g2, s2): if ev1 in spec_i.transitions[s_i].keys(): next_active_events_spec.update( set(spec_i.transitions[spec_i.transitions[s_i] [ev1]].keys())) else: next_active_events_spec.update( set(spec_i.transitions[s_i].keys())) for g_i, s_i in zip(g1, s1): if ev1 in g_i.transitions[s_i].keys(): next_active_events_g.update( set(g_i.transitions[g_i.transitions[s_i] [ev1]].keys())) else: next_active_events_g.update( set(g_i.transitions[s_i].keys())) next_active_events_g -= next_active_events_spec for event_1 in next_active_events_g.intersection( common_events): if not event_1.controllable: flag_bad_state_one = True break if not flag_bad_state_one: state_name_string = str() state_mark = True for state_i, spec_i in zip(s2, g2): if ev1 in spec_i.transitions[state_i].keys(): state_name_string += '|' + spec_i.transitions[ state_i][ev1].name state_mark = state_mark and spec_i.transitions[ state_i][ev1].mark else: state_name_string += '|' + state_i.name state_mark = state_mark and state_i.mark for state_i, g_i in zip(s1, g1): if ev1 in g_i.transitions[state_i].keys(): state_name_string += '|' + g_i.transitions[ state_i][ev1].name state_mark = state_mark and g_i.transitions[ state_i][ev1].mark else: state_name_string += '|' + state_i.name state_mark = state_mark and state_i.mark if state_name_string not in state_out_dict: state_out_dict[state_name_string] = \ automata.State(state_name_string, state_mark) state_to_be_visited_gather_s1 = list() state_to_be_visited_gather_s2 = list() for state_i, spec_i in zip(s2, g2): if ev1 in spec_i.transitions[state_i].keys(): state_to_be_visited_gather_s2.append( spec_i.transitions[state_i][ev1]) else: state_to_be_visited_gather_s2.append( state_i) for state_i, g_i in zip(s1, g1): if ev1 in g_i.transitions[state_i].keys(): state_to_be_visited_gather_s1.append( g_i.transitions[state_i][ev1]) else: state_to_be_visited_gather_s1.append( state_i) states_to_be_visited_in_g1.append( state_to_be_visited_gather_s1) states_to_be_visited_in_g2.append( state_to_be_visited_gather_s2) st_out[current_state_out][ev1] = state_out_dict[ state_name_string] try: s1 = states_to_be_visited_in_g1.pop() s2 = states_to_be_visited_in_g2.pop() state_name_string = str() for state_i in s2: state_name_string += '|' + state_i.name for state_i in s1: state_name_string += '|' + state_i.name current_state_out = state_out_dict[state_name_string] except IndexError: s1 = None s2 = None sup = automata.Automaton(st_out, out_initial_state) coaccessible(sup) return sup
def supc(k, g): """ This function is based on the classical implementation of the SupC algorithm""" breaking_bad = round( 0.01 * len(k.transitions.keys()) + 0.6) # This is a variable to break the loop to remove bad # states, as it enhance the performance of the algorithm... basically, you don´t need to run through all states # to delete some of them... and by deleting and trimming when you reach a significant amount of bad states (1%), # you reduce the number of states to be visited significantly. This is a kind of minimization problem where there is # a optimum amount of bad states to "break" the loop. However, I did some runs and roughly determined 1% of the # states of K. sup = automata.Automaton(k.transitions, k.initial_state) flag_bad_state = True set_bad_state = set() n_bad_states_in_sup = 0 while flag_bad_state: flag_bad_state = False states_to_be_visited_in_sup = list() states_to_be_visited_in_sup.append(sup.initial_state) states_to_be_visited_in_g = list() states_to_be_visited_in_g.append(g.initial_state) flag_end = True visiting_state_in_sup = states_to_be_visited_in_sup.pop() visiting_state_in_g = states_to_be_visited_in_g.pop() visited_states_set = set() while flag_end: for ev in g.transitions[visiting_state_in_g].keys(): if ev in sup.transitions[visiting_state_in_sup].keys(): nxt_state = sup.transitions[visiting_state_in_sup][ev] if nxt_state not in visited_states_set: visited_states_set.add(nxt_state) states_to_be_visited_in_sup.append(nxt_state) states_to_be_visited_in_g.append( g.transitions[visiting_state_in_g][ev]) else: if not ev.controllable and visiting_state_in_sup not in set_bad_state: n_bad_states_in_sup += 1 set_bad_state.add(visiting_state_in_sup) flag_bad_state = True if n_bad_states_in_sup == breaking_bad: break if n_bad_states_in_sup == breaking_bad: n_bad_states_in_sup = 0 break try: visiting_state_in_sup = states_to_be_visited_in_sup.pop() visiting_state_in_g = states_to_be_visited_in_g.pop() except IndexError: flag_end = False if flag_bad_state: sup.remove_states( set_bad_state) # remove bad states and all transitions to it set_bad_state = set() trim(sup) return sup
def supc2(g2, g1): """ This function is the faster calculation of the supervisor we have got. The parameters are SPEC_global and G_global. The key to its performance is to identify bad states even before than creating them. So, instead of calculating the all K and then search a bad state and exclude it and trim (and do it again, and again)... We identify bad states in the process of calculating the composition of E_global and G_global and do not create them. Also, the loops run through accessible states only, so we do not calculate trim, we only calculate coaccessible states at last.""" st_out = {} # dictionary for transitions of the supervisor # g1 = GLOBAL PLANT # g2 = GLOBAL SPECIFICATION states_to_be_visited_in_g1 = list() states_to_be_visited_in_g2 = list() # Check if initial state is not a bad state, in order to visit it: flag_bad_state = False for nxt_ev in g1.transitions[g1.initial_state].keys(): if not nxt_ev.controllable and nxt_ev.common and nxt_ev not in \ g2.transitions[g2.initial_state].keys(): flag_bad_state = True break if not flag_bad_state: s1 = g1.initial_state s2 = g2.initial_state else: return current_state_out = automata.State(s1.name + '|' + s2.name, s1.mark and s2.mark) state_out_dict = dict() state_out_dict[s1.name + '|' + s2.name] = current_state_out out_initial_state = current_state_out common_events = g1.events_set().intersection(g2.events_set()) alphabet = set(g1.events_set()) alphabet.update(g2.events_set()) flag_remained_bad_state = False for ev in alphabet: if ev in common_events: ev.common = True else: ev.common = False while s1: # The while is used instead of the for loop. The reason is that we only visit accessible states, # so, along the algorithm, we determine the next accessible states do be visited. st_out[current_state_out] = {} for current_ev in g1.transitions[s1].keys(): if not current_ev.common: if g1.transitions[s1][ current_ev].name + '|' + s2.name not in state_out_dict: state_out_dict[g1.transitions[s1][current_ev].name + '|' + s2.name] = \ automata.State( g1.transitions[s1][current_ev].name + '|' + s2.name, g1.transitions[s1][current_ev].mark and s2.mark) states_to_be_visited_in_g1.append( g1.transitions[s1][current_ev]) states_to_be_visited_in_g2.append(s2) st_out[current_state_out][current_ev] = state_out_dict[ g1.transitions[s1][current_ev].name + '|' + s2.name] elif current_ev in g2.transitions[s2].keys(): # check if destination state is bad state flag_bad_state = False for nxt_ev in g1.transitions[g1.transitions[s1] [current_ev]].keys(): if not nxt_ev.controllable and nxt_ev.common and nxt_ev not in \ g2.transitions[g2.transitions[s2][current_ev]].keys(): flag_bad_state = True if not current_ev.controllable: flag_remained_bad_state = True # detects "retrocedent" bad states which were already added break if not flag_bad_state: # if destination state is bad state, it is not included # in the output transitions if g1.transitions[s1][current_ev].name + '|' + g2.transitions[s2][current_ev].name \ not in state_out_dict: state_out_dict[g1.transitions[s1][current_ev].name + '|' + g2.transitions[s2][current_ev].name]\ = automata.State(g1.transitions[s1][current_ev].name + '|' + g2.transitions[s2][current_ev].name, g1.transitions[s1][current_ev].mark and g2.transitions[s2][current_ev].mark) states_to_be_visited_in_g1.append( g1.transitions[s1][current_ev]) states_to_be_visited_in_g2.append( g2.transitions[s2][current_ev]) st_out[current_state_out][current_ev] = state_out_dict[ g1.transitions[s1][current_ev].name + '|' + g2.transitions[s2][current_ev].name] try: s1 = states_to_be_visited_in_g1.pop() s2 = states_to_be_visited_in_g2.pop() current_state_out = state_out_dict[s1.name + '|' + s2.name] except IndexError: s1 = None s2 = None supervisor = automata.Automaton(st_out, out_initial_state) if flag_remained_bad_state: supervisor = supc( supervisor, g1 ) # in order to guarantee there is no bad states left in the supervisor else: coaccessible( supervisor ) # the supervisor is already accessible, we only calculate coaccessible return supervisor
# Creating states s0 = automata.State('0', True) s1 = automata.State('1') # Creating events s_on = automata.Event('s_on') s_off = automata.Event('s_off') e_on = automata.Event('c', True) e_off = automata.Event('d', True) sensor_transitions = {s0: {s_on: s1}, s1: {s_off: s0}} conveyor_transitions = {s0: {e_on: s1}, s1: {e_off: s0}} G1 = automata.Automaton(sensor_transitions, s0) G2 = automata.Automaton(conveyor_transitions, s0) specifications_transitions = { s0: { s_on: s1, e_off: s0 }, s1: { s_off: s0, e_on: s1 } } E = automata.Automaton(specifications_transitions, s0)
def sync(g1, g2): """ This function returns the accessible part of the synchronous composition. Instead of calculating all composed states and then calculate the accessible part, we only add accessible states to the output.""" st_out = {} states_to_be_visited_in_g1 = list() states_to_be_visited_in_g2 = list() states_to_be_visited_in_g1.append(g1.initial_state) states_to_be_visited_in_g2.append(g2.initial_state) s1 = states_to_be_visited_in_g1.pop() s2 = states_to_be_visited_in_g2.pop() state_flag = dict() current_state = automata.State(s1.name + '|' + s2.name, s1.mark and s2.mark) state_flag[s1.name + '|' + s2.name] = False state_out_dict = dict() state_out_dict[s1.name + '|' + s2.name] = current_state out_initial_state = current_state common_events = g1.events_set().intersection( g2.events_set()) # set of events which are in both alphabets alphabet = set(g1.events_set()) alphabet.update(g2.events_set()) for ev in alphabet: if ev in common_events: ev.common = True else: ev.common = False while s1: st_out[current_state] = {} ev_exclusive_set_2 = set(g2.transitions[s2].keys()) - common_events for ev1 in g1.transitions[s1].keys(): if not ev1.common: if g1.transitions[s1][ ev1].name + '|' + s2.name not in state_out_dict: state_out_dict[g1.transitions[s1][ev1].name + '|' + s2.name] = \ automata.State( g1.transitions[s1][ev1].name + '|' + s2.name, g1.transitions[s1][ev1].mark and s2.mark) states_to_be_visited_in_g1.append(g1.transitions[s1][ev1]) states_to_be_visited_in_g2.append(s2) st_out[current_state][ev1] = state_out_dict[ g1.transitions[s1][ev1].name + '|' + s2.name] elif ev1 in g2.transitions[s2].keys(): if g1.transitions[s1][ev1].name + '|' + g2.transitions[s2][ ev1].name not in state_out_dict: state_out_dict[g1.transitions[s1][ev1].name + '|' + g2.transitions[s2][ev1].name] = \ automata.State(g1.transitions[s1][ev1].name + '|' + g2.transitions[s2][ev1].name, g1.transitions[s1][ev1].mark and g2.transitions[s2][ev1].mark) states_to_be_visited_in_g1.append(g1.transitions[s1][ev1]) states_to_be_visited_in_g2.append(g2.transitions[s2][ev1]) st_out[current_state][ev1] = state_out_dict[ g1.transitions[s1][ev1].name + '|' + g2.transitions[s2][ev1].name] for ev2 in ev_exclusive_set_2: if s1.name + '|' + g2.transitions[s2][ ev2].name not in state_out_dict: state_out_dict[s1.name + '|' + g2.transitions[s2][ev2].name] = \ automata.State( s1.name + '|' + g2.transitions[s2][ev2].name, s1.mark and g2.transitions[s2][ev2].mark) states_to_be_visited_in_g1.append(s1) states_to_be_visited_in_g2.append(g2.transitions[s2][ev2]) st_out[current_state][ev2] = state_out_dict[ s1.name + '|' + g2.transitions[s2][ev2].name] try: s1 = states_to_be_visited_in_g1.pop() s2 = states_to_be_visited_in_g2.pop() current_state = state_out_dict[s1.name + '|' + s2.name] except IndexError: s1 = None s2 = None out = automata.Automaton(st_out, out_initial_state) return out
def EXPERIMENT03(): #Size of the Matrix of states w, h, N = 8, 5, 20 #Creating States number_of_states = w * h states = [None] * number_of_states #Defining the positions of each State for i in range(number_of_states): states[i] = automata.State('S' + str(i)) # Creating events number_of_events = 4 * w * h + 2 * (w + h - 2) events = [None] * number_of_events for i in range(number_of_events): events[i] = automata.Event(('e' + str(i)), 1, True) #Creating the automaton itself and its positions trans = dict() Matrix_states = [[0 for x in range(w)] for y in range(h)] #Data about positions wsize = 3.2 whalf = wsize / 2 hsize = 2 hhalf = hsize / 2 Initial_point = np.array([0, 0, 0]) wdif = wsize / (w) hdif = hsize / (h) positions = [[0 for x in range(w)] for y in range(h)] DIC_POSITIONS = dict() counter_states = 0 for i in range(h): for j in range(w): Matrix_states[i][j] = states[counter_states] trans[states[counter_states]] = dict() positions[i][j] = [ x + y for x, y in zip(Initial_point, [(j - (w - 1) / 2) * wdif, (-i + (h - 1) / 2) * hdif, 0]) ] DIC_POSITIONS[states[counter_states]] = positions[i][j] counter_states += 1 counter_events = 0 for i in range(h): for j in range(w): if i < (h - 1): trans[Matrix_states[i][j]][ events[counter_events]] = Matrix_states[i + 1][j] counter_events += 1 if i > (0): trans[Matrix_states[i][j]][ events[counter_events]] = Matrix_states[i - 1][j] counter_events += 1 if j < (w - 1): trans[Matrix_states[i][j]][ events[counter_events]] = Matrix_states[i][j + 1] counter_events += 1 if j > (0): trans[Matrix_states[i][j]][ events[counter_events]] = Matrix_states[i][j - 1] counter_events += 1 G = automata.Automaton(trans, events[0]) #Creating inputs for robotarium RADIUS = 0.06 # Experiment 3 - Compound movement Initial_pos = (Matrix_states[0][:] + Matrix_states[4][:] + [Matrix_states[2][0]] + [Matrix_states[2][3]] + [Matrix_states[2][4]] + [Matrix_states[2][7]]) Final_pos = (Matrix_states[4][:] + Matrix_states[0][:] + [Matrix_states[2][3]] + [Matrix_states[2][0]] + [Matrix_states[2][7]] + [Matrix_states[2][4]]) real_state = Initial_pos pivot_state = [[]] * N past_state = [[]] * N past_state2 = [[]] * N #Path planning variables N = len(Final_pos) T = [None] * N S = [None] * N T_optimal = [None] * N S_optimal = [None] * N T_dj = [None] * N S_dj = [None] * N logical_state = [None] * N priority_radius = [2] * N buffer = [0] * N communication_radius = [3] * N blacklist = dict() blacklist_individual = dict() calculating = [True] * N defined_path = dict() calculating = [True] * N for i in range(N): blacklist[i] = [] defined_path[i] = [] #Control variables possible = rc.FC_POSSIBLE_STATES_ARRAY(DIC_POSITIONS) goal_points = np.ones([3, N]) # Initializing the states list initial_points = rc.FC_SET_ALL_POSITIONS(DIC_POSITIONS, Initial_pos) # Initializing the robotarium r = robotarium.Robotarium(number_of_robots=N, show_figure=True, initial_conditions=initial_points, sim_in_real_time=True) single_integrator_position_controller = create_si_position_controller() __, uni_to_si_states = create_si_to_uni_mapping() si_to_uni_dyn = create_si_to_uni_dynamics_with_backwards_motion() x = r.get_poses() x_si = uni_to_si_states(x) #""" r.step() RUN = True first = [True] * N finished = [0] * N # Creating an structure of past states during actual order past = dict() for s in range(N): past[s] = [] string_size = list() while real_state != Final_pos: x = r.get_poses() x_si = uni_to_si_states(x) # Update Real State for i in range(N): blacklist[i] = [] past_state[i] = real_state[i] real_state[i] = rc.FC_MAKE_REAL_TRANSITION(possible, states, real_state[i], x, i, RADIUS) if past_state[i] != real_state[i]: past_state2[i] = past_state[i] for i in range(N): if real_state[i] != Final_pos[i]: if real_state[i] == pivot_state[i]: #Recalculus of route is necessary calculating[i] = True elif real_state[i] == logical_state[i]: #Update Robotarium state orders, no recalculus is needed defined_path[i].pop(0) logical_state[i] = defined_path[i][1] if calculating[i]: for j in range(N): if j != i: d_real = dk.DIST(G, real_state[j], communication_radius[j]) if real_state[i] in d_real: #Update blacklist[i] if S[j] != None and len(defined_path[j]) > 1: start_black = True for k in range(len(defined_path[j])): if start_black: blacklist[ i] = rc.add_black_real_logical( G, blacklist[i], defined_path[j][k], defined_path[j][k + 1]) start_black = False else: blacklist[i] = rc.add_black3( G, blacklist[i], defined_path[j][k]) start_black = False else: blacklist[i] = rc.add_black3( G, blacklist[i], real_state[j]) #Update Path[i] (T_optimal[i], S_optimal[i]) = dk.PATH2(G, [], real_state[i], Final_pos[i]) try: (T[i], S[i]) = dk.PATH2(G, blacklist[i], real_state[i], Final_pos[i]) if len(S[i]) > priority_radius[i]: index = list(range(priority_radius[i])) else: index = list(range(len(S[i]))) defined_path[i] = list() for j in index: defined_path[i].append(S[i][j]) if len(S[i]) > len(S_optimal[i]): if len(defined_path[i]) > 2: for j in reversed( range(2, len(defined_path[i]))): if defined_path[i][j] not in S_optimal[i]: defined_path[i].pop(j) pivot_state[i] = defined_path[i][-1] logical_state[i] = S[i][1] if logical_state[i] == past_state2[i]: try: blacklist[i] = rc.add_black3( G, blacklist[i], past_state2[i]) (T[i], S[i]) = dk.PATH2(G, blacklist[i], real_state[i], Final_pos[i]) if len(S[i]) > priority_radius[i]: index = list(range(priority_radius[i])) else: index = list(range(len(S[i]))) defined_path[i] = list() for j in index: defined_path[i].append(S[i][j]) pivot_state[i] = defined_path[i][-1] logical_state[i] = S[i][1] except: pass except: blocked = rc.check_block(G.transitions, real_state[i], blacklist[i]) if blocked: S[i] = [real_state[i]] T[i] = [None] defined_path[i] = [S[i][0]] pivot_state[i] = S[i][0] logical_state[i] = S[i][0] else: white_auto = G.transitions[real_state[i]] white_keys = white_auto.keys() white_list = list() for j in white_keys: # print(j) if j not in blacklist[i]: if white_auto[j] != past_state2[i]: white_list.append(j) else: past_event = j if len(white_list) >= 1: white_event = random.choice(white_list) elif past_event not in blacklist[i]: white_event = past_event S[i] = [real_state[i], white_auto[white_event]] T[i] = [white_event] defined_path[i] = [ real_state[i], white_auto[white_event] ] pivot_state[i] = S[i][1] logical_state[i] = S[i][1] calculating[i] = False else: #Reached final position # Reached final position logical_state[i] = real_state[i] for j in range(N): if logical_state[j] != None: rc.FC_SET_GOAL_POINTS(DIC_POSITIONS, goal_points, j, logical_state[j]) else: rc.FC_SET_GOAL_POINTS(DIC_POSITIONS, goal_points, j, real_state[j]) dxi = single_integrator_position_controller(x_si, goal_points[:2][:]) dxu = si_to_uni_dyn(dxi, x) r.set_velocities(np.arange(N), dxu) r.step() r.call_at_scripts_end() time_of_execution = r._iterations * 0.033 return (time_of_execution)
i + 1][j] counter_events += 1 if i > (0): trans[Matrix_states[i][j]][events[counter_events]] = Matrix_states[ i - 1][j] counter_events += 1 if j < (w - 1): trans[Matrix_states[i][j]][ events[counter_events]] = Matrix_states[i][j + 1] counter_events += 1 if j > (0): trans[Matrix_states[i][j]][ events[counter_events]] = Matrix_states[i][j - 1] counter_events += 1 G = automata.Automaton(trans, events[0]) #Creating inputs for robotarium RADIUS = 0.07 #""" Initial_pos = (Matrix_states[0][:] + Matrix_states[4][:]) Final_pos = (Matrix_states[4][:] + Matrix_states[0][:]) #""" real_state = Initial_pos pivot_state = [[]] * N #Path planning variables N = len(Final_pos)
c = automata.Event('c', 1, True) d = automata.Event('d', 1, True) e = automata.Event('e', 1, True) f = automata.Event('f', 1, True) g = automata.Event('g', 1, True) h = automata.Event('h', 1, True) k = automata.Event('k', 1, True) l = automata.Event('l', 1, True) m = automata.Event('m', 1, True) n = automata.Event('n', 1, True) o = automata.Event('o', 1, True) p = automata.Event('p', 1, True) #Creating the automaton itself trans = {A: {a: B, f: D}, B: {b: A, c: C, h: E}, C: {d: B, l: F}, D: {e: A, m: E}, E: {g: B, n: D, o: F}, F: {k: C, p: E}} G = automata.Automaton(trans, A) #Creating inputs for robotarium scale = 1.5 A_point = [-0.8*scale, 0.4*scale, -np.pi/2] B_point = [0*scale, 0.4*scale, 0*scale] C_point = [0.8*scale, 0.4*scale, -np.pi/2] D_point = [-0.8*scale, -0.4*scale, 0*scale] E_point = [0*scale, -0.4*scale, 0*scale] F_point = [0.8*scale, -0.4*scale, 0*scale] DIC_POSITIONS = {'A': A_point, 'B': B_point, 'C': C_point, 'D': D_point, 'E': E_point, 'F': F_point} Initial_pos = [A, C] Final_pos = [C, B] N = len(Final_pos) RADIUS = 0.07 #Control variables
alphabet[i][4]: s[3] }, s[1]: { alphabet[i][1]: s[0] }, s[2]: { alphabet[i][3]: s[0] }, s[3]: { alphabet[i][5]: s[0] } } robot_initial_state.insert(i, s[0]) robot.insert( i, automata.Automaton(robot_transitions[i], robot_initial_state[i])) # "Processing Chambers" Plants alphabet2 = dict() alphabet2_uncontrollable = dict() n_automata = clusters chamber_transitions = dict() chamber_initial_state = list() chamber = list() I_C = dict() F_C = dict() for i in range(n_automata): I_C[i] = automata.Event('I_C', True)
# Creating states s0 = automata.State('0', True) s1 = automata.State('1') # Creating events a = automata.Event('a', True) b = automata.Event('b') c = automata.Event('c', True) d = automata.Event('d') transitions_1 = {s0: {a: s1, b: s0}, s1: {b: s0}} transitions_2 = {s0: {c: s1}, s1: {d: s0}} G1 = automata.Automaton(transitions_1, s0) G2 = automata.Automaton(transitions_2, s0) print("G1 states list:", G1.states_set()) print("G1 events list:", G1.events_set()) G = operations.sync(G1, G2) print("G states list:", G.states_set()) print("G events list:", G.events_set()) print("G transitions:", G.transitions) ######################################################################################################################## # Coaccessible example ########################################################################################################################