mailRe: r25331 - /trunk/test_suite/shared_data/curve_fitting/profiling/profiling_relax_fit.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on August 27, 2014 - 12:09:
70 times faster is not bad at all!  That's what different optimisation
algorithms can give.  Well the simplex to Newton change is a speed up
of 6.97 (about one order of magnitude).  You should also expect an
order of difference in speed when changing algorithms for the
relaxation dispersion models.  However we do not have the gradients
and Hessians derived and implemented for these yet.  This would be a
possible (distant) future target.  However the Maple brute force
expansion of numeric models would be far more time saving and may even
be publishable as a note somewhere (again a distant future target).

Regards,

Edward


On 27 August 2014 11:49,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Wed Aug 27 11:49:21 2014
New Revision: 25331

URL: http://svn.gna.org/viewcvs/relax?rev=25331&view=rev
Log:
Modified profiling script to calculate timings.

The timings for C-code are:
 Simplex, with constraints = 2.192
 Simplex, without constraints = 0.216
 BFGS, without constraints = 0.079
 Newton, without constraints = 0.031

This is pretty pretty fast.

To this profiling script, I would also now add some verification on 
calculations.

Profile, with constraints, C code, Simplex
Wed Aug 27 11:45:16 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmpvJSNrB

         724946 function calls (723444 primitive calls) in 2.192 seconds

   Ordered by: cumulative time
   List reduced from 307 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    2.192    2.192 
profiling_relax_fit.py:314(verify)

 Verify, without constraints, C code, Simplex
Wed Aug 27 11:45:16 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmphJ9GV3

         76042 function calls (74654 primitive calls) in 0.216 seconds

   Ordered by: cumulative time
   List reduced from 132 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.216    0.216 
profiling_relax_fit.py:314(verify)

 Verify, without constraints, C code BFGS
Wed Aug 27 11:45:16 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmp78MZjS

         25618 function calls (24230 primitive calls) in 0.079 seconds

   Ordered by: cumulative time
   List reduced from 153 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.079    0.079 
profiling_relax_fit.py:314(verify)

 Verify, without constraints, C code Newton
Wed Aug 27 11:45:16 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmp2IPgFC

         14572 function calls (13184 primitive calls) in 0.031 seconds

   Ordered by: cumulative time
   List reduced from 169 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.031    0.031 
profiling_relax_fit.py:314(verify)

 Verify, with constraints, Python, Simplex
Wed Aug 27 11:45:20 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmpQUUY4L

         808444 function calls (806942 primitive calls) in 3.108 seconds

   Ordered by: cumulative time
   List reduced from 141 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    3.108    3.108 
profiling_relax_fit.py:353(verify_pyt)

 Verify, without constraints, Python, Simplex
Wed Aug 27 11:45:20 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmp3nFBTq

         87492 function calls (86104 primitive calls) in 0.320 seconds

   Ordered by: cumulative time
   List reduced from 131 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.320    0.320 
profiling_relax_fit.py:353(verify_pyt)

 Verify, without constraints, Python Scipy
Wed Aug 27 11:45:20 2014    
/var/folders/ww/1jkhkh315x57jglgxnr9g24w0000gp/T/tmpo1HoWn

         6600 function calls (5212 primitive calls) in 0.020 seconds

   Ordered by: cumulative time
   List reduced from 137 to 1 due to restriction <1>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.020    0.020 
profiling_relax_fit.py:388(verify_sci)

task #7822(https://gna.org/task/index.php?7822): Implement user function to 
estimate R2eff and associated errors for exponential curve fitting.

Modified:
    
trunk/test_suite/shared_data/curve_fitting/profiling/profiling_relax_fit.py

Modified: 
trunk/test_suite/shared_data/curve_fitting/profiling/profiling_relax_fit.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/shared_data/curve_fitting/profiling/profiling_relax_fit.py?rev=25331&r1=25330&r2=25331&view=diff
==============================================================================
--- 
trunk/test_suite/shared_data/curve_fitting/profiling/profiling_relax_fit.py 
(original)
+++ 
trunk/test_suite/shared_data/curve_fitting/profiling/profiling_relax_fit.py 
Wed Aug 27 11:49:21 2014
@@ -57,7 +57,8 @@
 # relax module imports.
 from status import Status; status = Status()
 from specific_analyses.relax_disp.estimate_r2eff import minimise_leastsq, 
Exp
-from target_functions.relax_fit import setup, func, dfunc, d2func, 
back_calc_I
+from specific_analyses.relax_fit.optimisation import func_wrapper, 
dfunc_wrapper, d2func_wrapper
+from target_functions.relax_fit import setup
 from target_functions.chi2 import chi2_rankN

 ## Set the min_algor.
@@ -114,7 +115,7 @@
             print("C_cT=%1.1e C_cF=%1.1e P_cT=%1.1e P_cF=%1.1e" % 
(chi_v_cT-chi_v_cT, chi_v_cF-chi_v_cT, chi_v_pyt_cT-chi_v_cT, 
chi_v_pyt_cF-chi_v_cT) )

     # Do verification for Python code, and difference between minfx and 
Scipy optimisation without constraints.
-    if True:
+    if False:
         # Calculate with Python code.
         # Calculate without contraints.
         v_pyt_cF_chi2_list = array(verify_pyt(constraints=False))
@@ -132,10 +133,12 @@
             print("P_cF=%1.1e Sci_cF=%1.1e" % (chi_v_pyt_cF-chi_v_pyt_cF, 
chi_v_pyt_cF-chi_v_sci_cF) )

     # Do profiling.
-
     if True:
-        #################
-        print("Verify, with constraints, C code")
+        print("\n################################# Profiling 
#################################")
+
+
+        #################
+        print("#####################\nProfile, with constraints, C code, 
Simplex \n#####################")
         constraints = True

         # Print statistics.
@@ -148,9 +151,8 @@

         print_report(filename=filename, verbose=verbose)

-    if True:
-        #################
-        print("Verify, without constraints, C code")
+        #################
+        print("#####################\n Verify, without constraints, C 
code, Simplex \n#####################")
         constraints = False

         # Print statistics.
@@ -163,9 +165,8 @@

         print_report(filename=filename, verbose=verbose)

-    if True:
-        #################
-        print("Verify, without constraints, C code BFGS")
+        #################
+        print("#####################\n Verify, without constraints, C code 
BFGS \n#####################")
         constraints = False

         # Print statistics.
@@ -178,9 +179,24 @@

         print_report(filename=filename, verbose=verbose)

-    if False:
-        #################
-        print("Verify, with constraints, Python")
+
+        #################
+        print("#####################\n Verify, without constraints, C code 
Newton \n#####################")
+        constraints = False
+
+        # Print statistics.
+        verbose = True
+
+        # Calc for verify with constraints.
+        filename = tempfile.NamedTemporaryFile(delete=False).name
+        # Profile for a single spin.
+        cProfile.run('verify(min_algor="Newton", 
constraints=%s)'%(constraints), filename)
+
+        print_report(filename=filename, verbose=verbose)
+
+
+        #################
+        print("#####################\n Verify, with constraints, Python, 
Simplex \n#####################")
         constraints = True

         # Print statistics.
@@ -193,9 +209,8 @@

         print_report(filename=filename, verbose=verbose)

-    if False:
-        #################
-        print("Verify, without constraints, Python")
+        #################
+        print("#####################\n Verify, without constraints, 
Python, Simplex \n#####################")
         constraints = False

         # Print statistics.
@@ -208,9 +223,8 @@

         print_report(filename=filename, verbose=verbose)

-    if True:
-        #################
-        print("Verify, without constraints, Python Scipy")
+        #################
+        print("#####################\n Verify, without constraints, Python 
Scipy \n#####################")

         # Print statistics.
         verbose = True
@@ -316,6 +330,11 @@

         E.set_settings_minfx(min_algor=min_algor, constraints=constraints)

+        # Define func.
+        func = func_wrapper
+        dfunc = dfunc_wrapper
+        d2func = d2func_wrapper
+
         # Initialise the function to minimise.
         scaling_list = [1.0, 1.0]
         setup(num_params=len(x0), num_times=len(E.times), values=E.values, 
sd=E.errors, relax_times=E.times, scaling_matrix=scaling_list)
@@ -353,6 +372,7 @@
         # Define func.
         func = E.func_exp
         dfunc = E.func_exp_grad
+        d2func = None

         results = generic_minimise(func=func, dfunc=dfunc, d2func=d2func, 
args=(), x0=x0, min_algor=E.min_algor, min_options=E.min_options, 
func_tol=E.func_tol, grad_tol=E.grad_tol, maxiter=E.max_iterations, A=E.A, 
b=E.b, full_output=True, print_flag=E.verbosity)



_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Wed Aug 27 15:00:14 2014