def _design_controller(self, states, inputs, transitions, rng):
    logger = self._get_logger()
    (Anom, Bnom, _) = utils.solve_least_squares(states, inputs, transitions, reg=self._reg)
    eps_A = np.linalg.norm((Anom - self._A_star), ord=2)
    eps_B = np.linalg.norm((Bnom - self._B_star), ord=2)
    effective_eps_A = (self._actual_error_multiplier * eps_A)
    effective_eps_B = (self._actual_error_multiplier * eps_B)
    epoch_id = ((self._epoch_idx + 1) if self._has_primed else 0)
    logger.info('_design_controller(epoch={}): effective_eps_A={}, effective_eps_B={}'.format(epoch_id, effective_eps_A, effective_eps_B))
    (is_feasible, _, _, K) = sls_common_lyapunov(Anom, Bnom, self._Q, self._R, effective_eps_A, effective_eps_B, tau=0.999, logger=logger)
    if (not is_feasible):
        try:
            self._current_K
            assert (self._current_K is not None)
            logger.warn('_design_controller(epoch={}): SLS not feasible: keeping current controller'.format(epoch_id))
            self._midway_infeasible += 1
        except AttributeError:
            logger.warn('_design_controller(epoch={}): SLS not feasible: no existing controller to fallback on, effective_eps_A={}, effective_eps_B={}'.format(epoch_id, effective_eps_A, effective_eps_B))
            raise SLSInfeasibleException()
    else:
        logger.info('_design_controller(epoch={}): SLS was feasible. updating controller'.format(epoch_id))
        self._current_K = K
    Jnom = utils.LQR_cost(self._A_star, self._B_star, self._current_K, self._Q, self._R, self._sigma_w)
    return (Anom, Bnom, Jnom)
def _design_controller(self, states, inputs, transitions, rng):
    logger = self._get_logger()
    (Anom, Bnom, _) = utils.solve_least_squares(states, inputs, transitions, reg=self._reg)
    eps_A = np.linalg.norm((Anom - self._A_star), ord=2)
    eps_B = np.linalg.norm((Bnom - self._B_star), ord=2)
    effective_eps_A = (self._actual_error_multiplier * eps_A)
    effective_eps_B = (self._actual_error_multiplier * eps_B)
    epoch_id = ((self._epoch_idx + 1) if self._has_primed else 0)
    logger.info('_design_controller(epoch={}): effective_eps_A={}, effective_eps_B={}'.format(epoch_id, effective_eps_A, effective_eps_B))
    (is_feasible, _, _, K) = sls_common_lyapunov(Anom, Bnom, self._Q, self._R, effective_eps_A, effective_eps_B, tau=0.999, logger=logger)
    if (not is_feasible):
        try:
            self._current_K
            assert (self._current_K is not None)
            logger.warn('_design_controller(epoch={}): SLS not feasible: keeping current controller'.format(epoch_id))
            self._midway_infeasible += 1
        except AttributeError:
            logger.warn('_design_controller(epoch={}): SLS not feasible: no existing controller to fallback on, effective_eps_A={}, effective_eps_B={}'.format(epoch_id, effective_eps_A, effective_eps_B))
            raise SLSInfeasibleException()
    else:
        logger.info('_design_controller(epoch={}): SLS was feasible. updating controller'.format(epoch_id))
        self._current_K = K
    Jnom = utils.LQR_cost(self._A_star, self._B_star, self._current_K, self._Q, self._R, self._sigma_w)
    return (Anom, Bnom, Jnom)