Example #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)))
Example #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])))
Example #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)))
Example #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)
Example #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)))
Example #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)))
Example #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)