(self, next_states, rewards, **solver_options)
return np.array(values.value)
Tensorflow wrapper around a cvxpy value function optimization.

        Parameters
        ----------
        next_states : ndarray
        rewards : ndarray

        Returns
        -------
        values : ndarray
            The optimal values at the states.
Tensorflow wrapper around a cvxpy value function optimization.
Tensorflow wrapper around a cvxpy value function optimization .
def _run_cvx_optimization(self, next_states, rewards, **solver_options):
        """Tensorflow wrapper around a cvxpy value function optimization.

        Parameters
        ----------
        next_states : ndarray
        rewards : ndarray

        Returns
        -------
        values : ndarray
            The optimal values at the states.
        """
        # Define random variables; convert index from np.int64 to regular
        # python int to avoid strange cvxpy error; see:
        # https://github.com/cvxgrp/cvxpy/issues/380
        values = cvxpy.Variable(rewards.shape)

        value_matrix = self.value_function.tri.parameter_derivative(
            next_states)
        # Make cvxpy work with sparse matrices
        value_matrix = cvxpy.Constant(value_matrix)

        objective = cvxpy.Maximize(cvxpy.sum(values))
        constraints = [values <= rewards + self.gamma * value_matrix * values]
        prob = cvxpy.Problem(objective, constraints)

        # Solve optimization problem
        prob.solve(**solver_options)

        # Some error checking
        if not prob.status == cvxpy.OPTIMAL:
            raise OptimizationError('Optimization problem is {}'
                                    .format(prob.status))

        return np.array(values.value)
def _run_cvx_optimization ( self , next_states , rewards , * * solver_options ) : # Define random variables; convert index from np.int64 to regular # python int to avoid strange cvxpy error; see: # https://github.com/cvxgrp/cvxpy/issues/380 values = cvxpy . Variable ( rewards . shape ) value_matrix = self . value_function . tri . parameter_derivative ( next_states ) # Make cvxpy work with sparse matrices value_matrix = cvxpy . Constant ( value_matrix ) objective = cvxpy . Maximize ( cvxpy . sum ( values ) ) constraints = [ values <= rewards + self . gamma * value_matrix * values ] prob = cvxpy . Problem ( objective , constraints ) # Solve optimization problem prob . solve ( * * solver_options ) # Some error checking if not prob . status == cvxpy . OPTIMAL : raise OptimizationError ( 'Optimization problem is {}' . format ( prob . status ) ) return np . array ( values . value )