mailr19372 - /branches/relax_disp/specific_analyses/relax_disp.py


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

Header


Content

Posted by edward on April 04, 2013 - 22:07:
Author: bugman
Date: Thu Apr  4 22:07:07 2013
New Revision: 19372

URL: http://svn.gna.org/viewcvs/relax?rev=19372&view=rev
Log:
The 'exp_fit' relaxation dispersion model now uses the minfx.grid sparseness 
argument.

This is used to skip all parts of the grid search belonging to a different 
exponential curve or
different spin.  If the number of curves is N and the number of spins M, the 
grid size decreases
from inc**(2*N*M) to (inc**2)*N*M.  For lots of spins and curves, this is a 
huge decrease.


Modified:
    branches/relax_disp/specific_analyses/relax_disp.py

Modified: branches/relax_disp/specific_analyses/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp.py?rev=19372&r1=19371&r2=19372&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp.py Thu Apr  4 22:07:07 
2013
@@ -557,7 +557,7 @@
             lower = []
             upper = []
 
-            # First add the spin specific parameters.
+            # First the spin specific parameters.
             for spin_index in range(len(spins)):
                 # Alias the spin.
                 spin = spins[spin_index]
@@ -609,10 +609,42 @@
                     lower.append(0.0)
                     upper.append(10000.0)
 
+        # Define sparse regions to skip.
+        sparseness = []
+        if cdp.model == 'exp_fit':
+            for spin_index1 in range(len(spins)):
+                for spin_index2 in range(len(spins)):
+                    for exp_index1, key in self._exp_curve_loop():
+                        for exp_index2, key in self._exp_curve_loop():
+                            # The same spin and curve, so no sparseness.
+                            if spin_index1 == spin_index2 and exp_index1 == 
exp_index2:
+                                continue
+    
+                            # The parameter index.
+                            index1 = spin_index1 * 2 * cdp.curve_count + 
exp_index1 * cdp.curve_count
+                            index2 = spin_index2 * 2 * cdp.curve_count + 
exp_index2 * cdp.curve_count
+
+                            # Add the parameter combinations.
+                            sparseness.append([index1, index2])
+                            sparseness.append([index1, index2+1])
+                            sparseness.append([index1+1, index2])
+                            sparseness.append([index1+1, index2+1])
+
+        # The sparse grid size.
+        if cdp.model == 'exp_fit':
+            grid_size = 0
+            for spin_index in range(len(spins)):
+                for exp_index, key in self._exp_curve_loop():
+                    index = spin_index * 2 * cdp.curve_count + exp_index * 
cdp.curve_count
+                    grid_size += inc[index] * inc[index+1]
+
+        # The full grid size.
+        else:
+            grid_size = 1
+            for i in range(n):
+                grid_size *= inc[i]
+
         # Test if the grid is too large.
-        grid_size = 1
-        for i in range(n):
-            grid_size = grid_size * inc[0]
         if isinstance(grid_size, long):
             raise RelaxError("A grid search of size %s is too large." % 
grid_size)
 
@@ -622,7 +654,7 @@
             upper[i] = upper[i] / scaling_matrix[i, i]
 
         # Return the data structures.
-        return grid_size, inc, lower, upper
+        return grid_size, inc, lower, upper, sparseness
 
 
     def _linear_constraints(self, spins=None, scaling_matrix=None):
@@ -1054,7 +1086,7 @@
 
             # Get the grid search minimisation options.
             if match('^[Gg]rid', min_algor):
-                grid_size, inc, lower, upper = 
self._grid_search_setup(spins=spins, param_vector=param_vector, lower=lower, 
upper=upper, inc=inc, scaling_matrix=scaling_matrix)
+                grid_size, inc, lower, upper, sparseness = 
self._grid_search_setup(spins=spins, param_vector=param_vector, lower=lower, 
upper=upper, inc=inc, scaling_matrix=scaling_matrix)
 
             # Linear constraints.
             A, b = None, None
@@ -1078,7 +1110,7 @@
 
             # Grid search.
             if search('^[Gg]rid', min_algor):
-                results = grid(func=model.func, args=(), num_incs=inc, 
lower=lower, upper=upper, A=A, b=b, verbosity=verbosity)
+                results = grid(func=model.func, args=(), num_incs=inc, 
lower=lower, upper=upper, A=A, b=b, sparseness=sparseness, 
verbosity=verbosity)
 
                 # Unpack the results.
                 param_vector, chi2, iter_count, warning = results




Related Messages


Powered by MHonArc, Updated Thu Apr 04 22:40:02 2013