Changeset 635


Ignore:
Timestamp:
01/06/13 18:48:48 (3 years ago)
Author:
mmckerns
Message:

add comparison against 'known' results in test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/tests/solver_test_compare.py

    r633 r635  
    2121  s2_x = s2(rosen, x0, disp=0, full_output=True, **kwds) 
    2222  # similar bestSolution and bestEnergy 
    23   print 's1:', s1_x[0:2] 
    24   print 's2:', s2_x[0:2] 
     23# print 's1:', s1_x[0:2] 
     24# print 's2:', s2_x[0:2] 
    2525  # print (iters, fcalls) and [maxiter, maxfun] 
    2626# print s1_x[2:4], s2_x[2:4], [maxiter, maxfun] 
     
    4646  sp_x = sp(rosen, x0, disp=0, full_output=True, **kwds) 
    4747  # similar bestSolution and bestEnergy 
    48   print 'my:', my_x[0:2] 
    49   print 'sp:', sp_x[0:2] 
     48# print 'my:', my_x[0:2] 
     49# print 'sp:', sp_x[0:2] 
    5050  assert almostEqual(my_x[0], sp_x[0]) 
    5151  assert almostEqual(my_x[1], sp_x[1]) 
     
    6565if __name__ == '__main__': 
    6666  x0 = [0,0,0] 
     67 
     68  # check solutions versus results based on the random_seed 
     69  print "comparing against known results" 
     70  sol = solvers.diffev(rosen, x0, npop=40, disp=0, full_output=True) 
     71  assert almostEqual(sol[1], 0.0020640145337293249, tol=1e-3) 
     72  sol = solvers.diffev2(rosen, x0, npop=40, disp=0, full_output=True) 
     73  assert almostEqual(sol[1], 0.0017516784703663288) 
     74  sol = solvers.fmin_powell(rosen, x0, disp=0, full_output=True) 
     75  assert almostEqual(sol[1], 8.3173488898295291e-23) 
     76  sol = solvers.fmin(rosen, x0, disp=0, full_output=True) 
     77  assert almostEqual(sol[1], 1.1605792769954724e-09) 
    6778 
    6879  solver2 = 'diffev2' 
     
    91102    test_compare(solver, x0, maxiter=9) 
    92103 
     104 
    93105# EOF 
Note: See TracChangeset for help on using the changeset viewer.