(fun, discretization)
return min_value
Determine the smallest value of a function on its boundary.

    Parameters
    ----------
    fun : callable
        A tensorflow function that we want to evaluate.
    discretization : instance of `GridWorld`
        The discretization. If None, then the function is assumed to be
        defined on a discretization already.

    Returns
    -------
    min_value : float
        The smallest value on the boundary.
Determine the smallest value of a function on its boundary.
Determine the smallest value of a function on its boundary .
def smallest_boundary_value(fun, discretization):
    """Determine the smallest value of a function on its boundary.

    Parameters
    ----------
    fun : callable
        A tensorflow function that we want to evaluate.
    discretization : instance of `GridWorld`
        The discretization. If None, then the function is assumed to be
        defined on a discretization already.

    Returns
    -------
    min_value : float
        The smallest value on the boundary.

    """
    min_value = np.inf
    feed_dict = get_feed_dict(tf.get_default_graph())

    # Check boundaries for each axis
    for i in range(discretization.ndim):
        # Use boundary values only for the ith element
        tmp = list(discretization.discrete_points)
        tmp[i] = discretization.discrete_points[i][[0, -1]]

        # Generate all points
        columns = (x.ravel() for x in np.meshgrid(*tmp, indexing='ij'))
        all_points = np.column_stack(columns)

        # Update the minimum value
        smallest = tf.reduce_min(fun(all_points))
        min_value = min(min_value, smallest.eval(feed_dict=feed_dict))

    return min_value
def smallest_boundary_value ( fun , discretization ) : min_value = np . inf feed_dict = get_feed_dict ( tf . get_default_graph ( ) ) # Check boundaries for each axis for i in range ( discretization . ndim ) : # Use boundary values only for the ith element tmp = list ( discretization . discrete_points ) tmp [ i ] = discretization . discrete_points [ i ] [ [ 0 , - 1 ] ] # Generate all points columns = ( x . ravel ( ) for x in np . meshgrid ( * tmp , indexing = 'ij' ) ) all_points = np . column_stack ( columns ) # Update the minimum value smallest = tf . reduce_min ( fun ( all_points ) ) min_value = min ( min_value , smallest . eval ( feed_dict = feed_dict ) ) return min_value