How to solve the Riccati equation in Pytorch

Hi, I am trying to solve the discrete Riccati equation using pytorch tensors. I have been attempting to use the control package

import control
import torch


Q = torch.eye(n)
R = torch.eye(d)

A = torch.rand(n,n)
B = torch.rand(n,d)

(P,L,K) = control.dare(A_opt, B_opt, Q, R)

However, when I run this I get the following error,

The control package generally works with numpy arrays. Does anyone know how to solve the Riccati equation using pytorch tensors?

Since the control library doesn’t accept PyTorch tensors, you would have to reimplement the method manually in PyTorch.
I don’t know which functions control.dare is calling and if all functions are available in PyTorch directly.

1 Like

Thank you! I will look into it