This function seems to work for some inputs but not for others. The issue I have picked up specifically is that recalculating the minimal realisation can lead to a different eigenvalues of the A matrix, and therefore different poles. Test code is as follows:
I believe the problem is in the remove_uncontrollable_or_unobservable_states function, specifically in the following lines:
elif uncontrollable is False and unobservable is True:
P[0:rank, :] = con_or_obs_matrix[0:rank, :]
# matrix will replace the dependent columns in P to make P invertible
replace_matrix = numpy.matrix(numpy.random.random((m, n_states)))
# make P invertible
P[rank:n_states, :] = replace_matrix
P_inv = numpy.linalg.inv(P)
A_new = P*a*P_inv
A_new = numpy.delete(A_new, numpy.s_[rank:n_states], 1)
A_new = numpy.delete(A_new, numpy.s_[rank:n_states], 0)
B_new = P*b
B_new = numpy.delete(B_new, numpy.s_[rank:n_states], 0)
C_new = c*P_inv
C_new = numpy.delete(C_new, numpy.s_[rank:n_states], 1)
given that we entered the elif part of the if statement. I suspect that the issue is in the deletes, are these supposed to be different depending on which path we went through in the if statement? Unfortunately I don't know what the algorithm should look like.
This function seems to work for some inputs but not for others. The issue I have picked up specifically is that recalculating the minimal realisation can lead to a different eigenvalues of the A matrix, and therefore different poles. Test code is as follows:
I believe the problem is in the remove_uncontrollable_or_unobservable_states function, specifically in the following lines:
given that we entered the elif part of the if statement. I suspect that the issue is in the deletes, are these supposed to be different depending on which path we went through in the if statement? Unfortunately I don't know what the algorithm should look like.