def params(self, n_state: int, n_ctrl: int, horizon: int, seed: int) -> Quadratic: n_tau = n_state + n_ctrl Q = random_spd_matrix(size=n_tau, horizon=horizon, rng=seed) q = random_normal_vector(size=n_tau, horizon=horizon, rng=seed) c = random_normal_vector(size=1, horizon=horizon, rng=seed).squeeze("R") return Q, q, c
def reset_parameters(self): """Standard parameter initialization.""" n_tau, horizon = self.n_tau, self.horizon self.quad.data.copy_(random_spd_matrix(size=n_tau, horizon=horizon)) self.linear.data.copy_( random_normal_vector(size=n_tau, horizon=horizon)) nn.init.uniform_(self.const, -1, 1)
def params(self, n_state: int, horizon: int, seed: int) -> Quadratic: V = random_spd_matrix(size=n_state, horizon=horizon + 1, rng=seed) v = random_normal_vector(size=n_state, horizon=horizon + 1, rng=seed) c = random_normal_vector(size=1, horizon=horizon + 1, rng=seed).squeeze("R") return V, v, c
def reset_parameters(self): """Default parameter initialization.""" self.C.data.copy_(random_spd_matrix(self.n_tau, horizon=self.horizon)) self.c.data.copy_( random_normal_vector(self.n_tau, horizon=self.horizon))