|
|
@ -29,13 +29,13 @@ class ParametersEstimator: |
|
|
|
print("Elapsed Time ", t1) |
|
|
|
print("Elapsed Time ", t1) |
|
|
|
|
|
|
|
|
|
|
|
def parameters_estimation_single_trajectory(self, trajectory): |
|
|
|
def parameters_estimation_single_trajectory(self, trajectory): |
|
|
|
#print(type(trajectory[0][0])) |
|
|
|
row_length = trajectory.shape[1] |
|
|
|
for indx, row in enumerate(trajectory): |
|
|
|
for indx, row in enumerate(trajectory): |
|
|
|
if trajectory[indx][1] == -1: |
|
|
|
if trajectory[indx][1] == -1: |
|
|
|
break |
|
|
|
break |
|
|
|
if trajectory[indx + 1][1] != -1: |
|
|
|
if trajectory[indx + 1][1] != -1: |
|
|
|
transition = self.find_transition(trajectory[indx], trajectory[indx + 1]) |
|
|
|
transition = self.find_transition(trajectory[indx], trajectory[indx + 1], row_length) |
|
|
|
which_node = self.net_graph.get_node_by_index(transition[0]) |
|
|
|
which_node = transition[0] |
|
|
|
# print(which_node) |
|
|
|
# print(which_node) |
|
|
|
which_matrix = self.which_matrix_to_update(row, transition[0]) |
|
|
|
which_matrix = self.which_matrix_to_update(row, transition[0]) |
|
|
|
which_element = transition[1] |
|
|
|
which_element = transition[1] |
|
|
@ -44,19 +44,18 @@ class ParametersEstimator: |
|
|
|
#changed_node = which_node |
|
|
|
#changed_node = which_node |
|
|
|
time = self.compute_time_delta(trajectory[indx], trajectory[indx + 1]) |
|
|
|
time = self.compute_time_delta(trajectory[indx], trajectory[indx + 1]) |
|
|
|
|
|
|
|
|
|
|
|
for node_indx, node in enumerate(self.net_graph.get_nodes()): |
|
|
|
for node_indx in range(0, 3): |
|
|
|
#if node != changed_node: |
|
|
|
#if node != changed_node: |
|
|
|
# print(node) |
|
|
|
# print(node) |
|
|
|
which_node = node |
|
|
|
which_node = node_indx |
|
|
|
which_matrix = self.which_matrix_to_update(row, node_indx) |
|
|
|
which_matrix = self.which_matrix_to_update(row, node_indx) |
|
|
|
which_element = row[node_indx + 1] |
|
|
|
which_element = row[node_indx + 1] |
|
|
|
# print("State res time element " + str(which_element) + node) |
|
|
|
self.amalgamated_cims_struct.update_state_residence_time_for_matrix( |
|
|
|
# print("State res time matrix indx" + str(which_matrix)) |
|
|
|
which_node, which_matrix, which_element, time) |
|
|
|
self.amalgamated_cims_struct.update_state_residence_time_for_matrix(which_node, which_matrix, which_element, time) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_transition(self, current_row, next_row): |
|
|
|
def find_transition(self, current_row, next_row, row_length): |
|
|
|
for indx in range(1, len(current_row)): |
|
|
|
for indx in range(1, row_length): |
|
|
|
if current_row[indx] != next_row[indx]: |
|
|
|
if current_row[indx] != next_row[indx]: |
|
|
|
return [indx - 1, (current_row[indx], next_row[indx])] |
|
|
|
return [indx - 1, (current_row[indx], next_row[indx])] |
|
|
|
|
|
|
|
|
|
|
@ -85,12 +84,12 @@ g1.init_graph() |
|
|
|
|
|
|
|
|
|
|
|
pe = ParametersEstimator(s1, g1) |
|
|
|
pe = ParametersEstimator(s1, g1) |
|
|
|
pe.init_amalgamated_cims_struct() |
|
|
|
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(0).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(1).get_cims_number()) |
|
|
|
print(pe.amalgamated_cims_struct.get_set_of_cims('Z').get_cims_number()) |
|
|
|
print(pe.amalgamated_cims_struct.get_set_of_cims(2).get_cims_number()) |
|
|
|
#pe.parameters_estimation_single_trajectory(pe.sample_path.trajectories[0].get_trajectory()) |
|
|
|
#pe.parameters_estimation_single_trajectory(pe.sample_path.trajectories[0].get_trajectory()) |
|
|
|
pe.parameters_estimation() |
|
|
|
pe.parameters_estimation() |
|
|
|
for matrix in pe.amalgamated_cims_struct.get_set_of_cims('Y').actual_cims: |
|
|
|
for matrix in pe.amalgamated_cims_struct.get_set_of_cims(1).actual_cims: |
|
|
|
print(matrix.state_residence_times) |
|
|
|
print(matrix.state_residence_times) |
|
|
|
print(matrix.state_transition_matrix) |
|
|
|
print(matrix.state_transition_matrix) |
|
|
|
matrix.compute_cim_coefficients() |
|
|
|
matrix.compute_cim_coefficients() |
|
|
|