/
Chronos
/
Control_lib
Обзор
Документация
Войти
/
Chronos
/
Control_lib
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
LMI_regulators.py
75 строк
2 KB
Chronos
Когда всё кончено, всё и начнётся
03 май 2025, 09:43
03 май 2025, 09:43
226d6e8
Код
Авторство
О чём код?
# Проверка D - устойчивости матрицы import numpy as np import cvxpy as cp from scipy.linalg import block_diag def build_stabilizing_regulator_continuous(A,B): Y = cp.Variable((A.shape[0],A.shape[0]),symmetric=True) Z = cp.Variable((B.shape[1],A.shape[0])) constraints = [ A@Y+Y@A.T+B@Z+Z.T@B.T << 0, Y >> 0 ] objective = cp.Minimize(0) problem = cp.Problem(objective, constraints) problem.solve(solver='MOSEK',verbose=False) print("Статус решения: ", problem.status) theta = Z.value@np.linalg.inv(Y.value) print("Регулятор theta: ",theta) return theta def build_stabilizing_regulator_discrete(A,B): Y = cp.Variable((A.shape[0],A.shape[0]),symmetric=True) Z = cp.Variable((B.shape[1],A.shape[0])) constraints = [ cp.bmat([ [Y,A@Y+B@Z], [(A@Y+B@Z).T,Y] ]) >> 0, Y >> 0 ] objective = cp.Minimize(0) problem = cp.Problem(objective, constraints) problem.solve(solver='MOSEK',verbose=False) print("Статус решения: ", problem.status) theta = Z.value@np.linalg.inv(Y.value) print("Регулятор theta: ",theta) return theta def check_matrix_D_stability(A,L,M): X = cp.Variable((3,3),symmetric=True) constraints = [ cp.kron(L,X)+cp.kron(M,A@X)+cp.kron(M.T,A.T@X) << 0, X >> 0 ] objective = cp.Minimize(0) problem = cp.Problem(objective, constraints) problem.solve(solver='MOSEK',verbose=False) print("Статус решения:", problem.status) return problem.status in ['optimal', 'optimal_inaccurate'] def build_D_stabilizing_regulator(A,B,L,M): X = cp.Variable((A.shape[0],A.shape[0]),symmetric=True) Z = cp.Variable((B.shape[1],A.shape[0])) constraints = [ cp.kron(L,X)+cp.kron(M,A@X+B@Z)+cp.kron(M.T,(A@X+B@Z).T) << 0, X >> 0 ] objective = cp.Minimize(0) problem = cp.Problem(objective, constraints) problem.solve(solver='MOSEK',verbose=False) print("Статус решения:", problem.status) theta = Z.value@np.linalg.inv(X.value) print("Регулятор theta: ", theta) return theta