Exemple #1
0
def test_minimize_array():
    assert _round_eq(2, ds.minimize(lambda x: (x[0] - 2)**2, [0], array=True))
    assert _round_eq([2, 1],
                     list(
                         ds.minimize(lambda x: (x[0] - 2)**2 + (x[1] - 1)**2,
                                     [0, 0],
                                     array=True)))
Exemple #2
0
def test_minimize():
    assert _round_eq(2, ds.minimize(lambda x: (x - 2)**2))
    assert _round_eq([2, 1],
                     list(ds.minimize(lambda x, y: (x - 2)**2 + (y - 1)**2)))
    assert _round_eq(2, ds.minimize(lambda x: (x - 2)**2, 1))
    assert _round_eq([2, 1],
                     list(
                         ds.minimize(lambda x, y: (x - 2)**2 + (y - 1)**2,
                                     [1, 1])))
Exemple #3
0
def test_minimize_smooth():
    assert _round_eq(2, ds.minimize(lambda x: (x - 2)**2, smooth=True))
    assert _round_eq([2, 1],
                     list(
                         ds.minimize(lambda x, y: (x - 2)**2 + (y - 1)**2,
                                     smooth=True)))
    assert _round_eq(2, ds.minimize(lambda x: (x - 2)**2, 1, smooth=True))
    assert _round_eq([2, 1],
                     list(
                         ds.minimize(lambda x, y: (x - 2)**2 + (y - 1)**2,
                                     [1, 1],
                                     smooth=True)))
Exemple #4
0
def minimize(f, start=None, **vargs):
    def expanded_f(*args):
        return f(args)

    return datascience.minimize(expanded_f,
                                start=start,
                                method="L-BFGS-B",
                                **vargs)
Exemple #5
0
def test_minimize_array():
    assert _round_eq(2, ds.minimize(lambda x: (x[0]-2)**2, [0], array=True))
    assert _round_eq([2, 1], list(ds.minimize(lambda x: (x[0]-2)**2 + (x[1]-1)**2, [0, 0], array=True)))
Exemple #6
0
def test_minimize_smooth():
    assert _round_eq(2, ds.minimize(lambda x: (x-2)**2, smooth=True))
    assert _round_eq([2, 1], list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2, smooth=True)))
    assert _round_eq(2, ds.minimize(lambda x: (x-2)**2, 1, smooth=True))
    assert _round_eq([2, 1], list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2, [1, 1], smooth=True)))
Exemple #7
0
def test_minimize():
    assert _round_eq(2, ds.minimize(lambda x: (x-2)**2))
    assert _round_eq([2, 1], list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2)))
    assert _round_eq(2, ds.minimize(lambda x: (x-2)**2, 1))
    assert _round_eq([2, 1], list(ds.minimize(lambda x, y: (x-2)**2 + (y-1)**2, [1, 1])))
def minimize(f, start=None, **vargs):
  def expanded_f(*args):
    return f(args)
  return datascience.minimize(expanded_f, start=start, method="L-BFGS-B", **vargs)