|
|
|
@ -11,12 +11,13 @@ class ParametersEstimator: |
|
|
|
|
def __init__(self, sample_path, net_graph): |
|
|
|
|
self.sample_path = sample_path |
|
|
|
|
self.net_graph = net_graph |
|
|
|
|
self.fancy_indexing_structure = self.net_graph.build_fancy_indexing_structure(1) |
|
|
|
|
self.amalgamated_cims_struct = None |
|
|
|
|
|
|
|
|
|
def init_amalgamated_cims_struct(self): |
|
|
|
|
self.amalgamated_cims_struct = acims.AmalgamatedCims(self.net_graph.get_states_number(), |
|
|
|
|
self.amalgamated_cims_struct = acims.AmalgamatedCims(self.net_graph.get_states_number_of_all_nodes_sorted(), |
|
|
|
|
self.net_graph.get_nodes(), |
|
|
|
|
self.net_graph.get_ord_set_of_par_of_all_nodes()) |
|
|
|
|
self.net_graph.get_ordered_by_indx_parents_values_for_all_nodes()) |
|
|
|
|
|
|
|
|
|
def parameters_estimation(self): |
|
|
|
|
print("Starting computing") |
|
|
|
@ -36,19 +37,19 @@ class ParametersEstimator: |
|
|
|
|
transition = self.find_transition(trajectory[indx], trajectory[indx + 1]) |
|
|
|
|
which_node = self.net_graph.get_node_by_index(transition[0]) |
|
|
|
|
# print(which_node) |
|
|
|
|
which_matrix = self.which_matrix_to_update(row, which_node) |
|
|
|
|
which_matrix = self.which_matrix_to_update(row, transition[0]) |
|
|
|
|
which_element = transition[1] |
|
|
|
|
self.amalgamated_cims_struct.update_state_transition_for_matrix(which_node, which_matrix, which_element) |
|
|
|
|
|
|
|
|
|
#changed_node = which_node |
|
|
|
|
time = self.compute_time_delta(trajectory[indx], trajectory[indx + 1]) |
|
|
|
|
|
|
|
|
|
for node in self.net_graph.get_nodes(): |
|
|
|
|
for node_indx, node in enumerate(self.net_graph.get_nodes()): |
|
|
|
|
#if node != changed_node: |
|
|
|
|
# print(node) |
|
|
|
|
which_node = node |
|
|
|
|
which_matrix = self.which_matrix_to_update(row, which_node) |
|
|
|
|
which_element = row[self.net_graph.get_node_indx(node) + 1] |
|
|
|
|
which_matrix = self.which_matrix_to_update(row, node_indx) |
|
|
|
|
which_element = row[node_indx + 1] |
|
|
|
|
# print("State res time element " + str(which_element) + node) |
|
|
|
|
# print("State res time matrix indx" + str(which_matrix)) |
|
|
|
|
self.amalgamated_cims_struct.update_state_residence_time_for_matrix(which_node, which_matrix, which_element, time) |
|
|
|
@ -63,13 +64,9 @@ class ParametersEstimator: |
|
|
|
|
def compute_time_delta(self, current_row, next_row): |
|
|
|
|
return next_row[0] - current_row[0] |
|
|
|
|
|
|
|
|
|
def which_matrix_to_update(self, current_row, node_id): # produce strutture {'X':1, 'Y':2} dove X e Y sono i parent di node_id |
|
|
|
|
result = {} |
|
|
|
|
parent_list = self.net_graph.get_parents_by_id(node_id) |
|
|
|
|
for node in parent_list: |
|
|
|
|
result[node] = current_row[self.net_graph.get_node_indx(node) + 1] |
|
|
|
|
# print(result) |
|
|
|
|
return result |
|
|
|
|
def which_matrix_to_update(self, current_row, node_indx): # produce strutture {'X':1, 'Y':2} dove X e Y sono i parent di node_id |
|
|
|
|
return current_row[self.fancy_indexing_structure[node_indx]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -90,6 +87,7 @@ pe = ParametersEstimator(s1, g1) |
|
|
|
|
pe.init_amalgamated_cims_struct() |
|
|
|
|
print(pe.amalgamated_cims_struct.get_set_of_cims('X').get_cims_number()) |
|
|
|
|
print(pe.amalgamated_cims_struct.get_set_of_cims('Y').get_cims_number()) |
|
|
|
|
print(pe.amalgamated_cims_struct.get_set_of_cims('Z').get_cims_number()) |
|
|
|
|
#pe.parameters_estimation_single_trajectory(pe.sample_path.trajectories[0].get_trajectory()) |
|
|
|
|
pe.parameters_estimation() |
|
|
|
|
for matrix in pe.amalgamated_cims_struct.get_set_of_cims('Y').actual_cims: |
|
|
|
|