Exemplo n.º 1
0
def tolerance(lower_bounds, upper_bounds, data=None):
    """ Returns a new, single point some tolerence away from existing points.

    Parameters
    ----------
    lower_bounds : list
        List of ``float`` that are lower bounds. List is indexed by parameter.
    upper_bounds : list
        List of ``float`` that are upper bounds. List is indexed by parameter.
    data : {None, list}
        List of tuples. Each tuple is a list of ``float`` that are previous
        data points.

    Returns
    -------
    pts : numpy.array
        An array with new point.
    """
    rtol = None
    dist = None
    n_new_pts = 1
    data = [] if data == None else data
    if len(data) == 0:
        return uniform(lower_bounds, upper_bounds)
    pts = math.fillpts(lower_bounds, upper_bounds, n_new_pts, data, rtol, dist)
    return pts[0]
Exemplo n.º 2
0
    def _InitialPoints(self):  #XXX: user can provide legacy data?
        """Generate a grid of starting points for the ensemble of optimizers"""
        npts = self._npts
        if len(self._strictMax): upper = list(self._strictMax)
        else:
            upper = list(self._defaultMax)
        if len(self._strictMin): lower = list(self._strictMin)
        else:
            lower = list(self._defaultMin)

        # build a grid of starting points
        from mystic.math import fillpts
        data = self._evalmon._x if self._evalmon else []
        data += self._stepmon._x if self._stepmon else []
        return fillpts(lower, upper, npts, data, self._rtol, self._dist)
Exemplo n.º 3
0
data=[[0,0]]
#data = []

ndim = len(data[0]) if data else 2
lb,ub = [-10]*ndim, [10]*ndim

npts = 12
rtol = None # 4.5

#from mystic.math import Distribution
#from scipy.stats import norm
dist = None # Distribution(norm,0,2)


if __name__ == '__main__':
    from mystic.math import fillpts
    pts = fillpts(lb, ub, npts, data, rtol, dist)

    import numpy as np
    print(np.array(pts).reshape(-1,ndim))

    import matplotlib.pyplot as plt

    _x,_y = np.array(pts).reshape(-1,ndim).T
    x,y = np.array(data).reshape(-1,ndim).T

    plt.scatter(x=x,y=y)
    plt.scatter(x=_x,y=_y)
    plt.show()

Exemplo n.º 4
0
#data=[[2,-6],[5,-7],[1,0],[1,3],[5,9],[2,2],[-10,-10],[-10,10],[10,-10]]
#data=[[0,0],[-10,-10],[-10,0],[10,0],[0,-10],[0,10],[10,-10],[-10,10],[10,10]]
data = [[0, 0]]
#data = []

ndim = len(data[0]) if data else 2
lb, ub = [-10] * ndim, [10] * ndim

npts = 12
rtol = None  # 4.5

#from mystic.math import Distribution
#from scipy.stats import norm
dist = None  # Distribution(norm,0,2)

if __name__ == '__main__':
    from mystic.math import fillpts
    pts = fillpts(lb, ub, npts, data, rtol, dist)

    import numpy as np
    print(np.array(pts).reshape(-1, ndim))

    import matplotlib.pyplot as plt

    _x, _y = np.array(pts).reshape(-1, ndim).T
    x, y = np.array(data).reshape(-1, ndim).T

    plt.scatter(x=x, y=y)
    plt.scatter(x=_x, y=_y)
    plt.show()