mailr5193 - /1.3/specific_fns/model_free/mf_minimise.py


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

Header


Content

Posted by edward on March 23, 2008 - 15:44:
Author: bugman
Date: Sun Mar 23 15:33:19 2008
New Revision: 5193

URL: http://svn.gna.org/viewcvs/relax?rev=5193&view=rev
Log:
Shifted the grid size print out to the test_grid_size() method.


Modified:
    1.3/specific_fns/model_free/mf_minimise.py

Modified: 1.3/specific_fns/model_free/mf_minimise.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/specific_fns/model_free/mf_minimise.py?rev=5193&r1=5192&r2=5193&view=diff
==============================================================================
--- 1.3/specific_fns/model_free/mf_minimise.py (original)
+++ 1.3/specific_fns/model_free/mf_minimise.py Sun Mar 23 15:33:19 2008
@@ -463,7 +463,7 @@
         self.minimise(min_algor='grid', lower=lower, upper=upper, inc=inc, 
constraints=constraints, verbosity=verbosity, sim_index=sim_index)
 
 
-    def grid_search_config(self, num_params, spin=None, spin_id=None, 
lower=None, upper=None, inc=None, scaling_matrix=None):
+    def grid_search_config(self, num_params, spin=None, spin_id=None, 
lower=None, upper=None, inc=None, scaling_matrix=None, verbosity=1):
         """Configure the grid search.
 
         @param num_params:          The number of parameters in the model.
@@ -478,12 +478,15 @@
         @keyword upper:             The upper bounds of the grid search 
which must be equal to the
                                     number of parameters in the model.
         @type upper:                array of numbers
-        @keyword inc:               The increments for each dimension of the 
space for the grid search.
-                                    The number of elements in the array must 
equal to the number of
-                                    parameters in the model.
+        @keyword inc:               The increments for each dimension of the 
space for the grid
+                                    search.  The number of elements in the 
array must equal to the
+                                    number of parameters in the model.
         @type inc:                  array of int
         @keyword scaling_matrix:    The diagonal, square scaling matrix.
         @type scaling_matrix:       numpy diagonal matrix
+        @keyword verbosity:         A flag specifying the amount of 
information to print.  The
+                                    higher the value, the greater the 
verbosity.
+        @type verbosity:            int
         """
 
         # Make sure that the length of the parameter array is > 0.
@@ -513,7 +516,7 @@
         # Minimisation options for diffusion tensor parameters.
         if param_set == 'diff' or param_set == 'all':
             # Get the diffusion tensor specific configuration.
-            m = self.grid_search_config_diff(min_options, inc, m)
+            m = self.grid_search_config_diff(min_options, inc, m, 
verbosity=verbosity)
 
         # Model-free parameters (residue specific parameters).
         if param_set != 'diff':
@@ -533,7 +536,7 @@
                 m = self.grid_search_config_spin(min_options, spin, inc, m)
 
         # Test if the grid is too large.
-        self.test_grid_size(min_options)
+        self.test_grid_size(min_options, verbosity=verbosity)
 
         # Complete the grid search configuration.
         self.grid_search_config_fin(min_options, lower, upper, 
scaling_matrix)
@@ -858,38 +861,6 @@
                 if not hasattr(spin, 'relax_data') or not hasattr(spin, 
'relax_error'):
                     continue
 
-            # Parameter vector and diagonal scaling.
-            if min_algor == 'back_calc':
-                # Create the initial parameter vector.
-                param_vector = self.assemble_param_vector(spin=spin)
-
-                # Diagonal scaling.
-                scaling_matrix = None
-
-            else:
-                # Create the initial parameter vector.
-                param_vector = self.assemble_param_vector(spin=spin, 
sim_index=sim_index)
-
-                # The number of parameters.
-                num_params = len(param_vector)
-
-                # Diagonal scaling.
-                scaling_matrix = self.assemble_scaling_matrix(num_params, 
param_set=param_set, spin=spin, scaling=scaling)
-                if len(scaling_matrix):
-                    param_vector = dot(inv(scaling_matrix), param_vector)
-
-            # Configure the grid search.
-            if match('^[Gg]rid', min_algor):
-                min_options = self.grid_search_config(num_params, spin=spin, 
lower=lower, upper=upper, inc=inc, scaling_matrix=scaling_matrix)
-
-            # Scaling of values for the set function.
-            if match('^[Ss]et', min_algor):
-                min_options = dot(inv(scaling_matrix), min_options)
-
-            # Linear constraints.
-            if constraints:
-                A, b = self.linear_constraints(num_params, 
param_set=param_set, spin=spin, scaling_matrix=scaling_matrix)
-
             # Print out.
             if verbosity >= 1:
                 # Individual spin stuff.
@@ -899,8 +870,38 @@
                     string = "Fitting to spin " + `spin_id`
                     print "\n\n" + string
                     print len(string) * '~'
-                if match('^[Gg]rid', min_algor):
-                    print "Unconstrained grid search size: " + `grid_size` + 
" (constraints may decrease this size).\n"
+
+            # Parameter vector and diagonal scaling.
+            if min_algor == 'back_calc':
+                # Create the initial parameter vector.
+                param_vector = self.assemble_param_vector(spin=spin)
+
+                # Diagonal scaling.
+                scaling_matrix = None
+
+            else:
+                # Create the initial parameter vector.
+                param_vector = self.assemble_param_vector(spin=spin, 
sim_index=sim_index)
+
+                # The number of parameters.
+                num_params = len(param_vector)
+
+                # Diagonal scaling.
+                scaling_matrix = self.assemble_scaling_matrix(num_params, 
param_set=param_set, spin=spin, scaling=scaling)
+                if len(scaling_matrix):
+                    param_vector = dot(inv(scaling_matrix), param_vector)
+
+            # Configure the grid search.
+            if match('^[Gg]rid', min_algor):
+                min_options = self.grid_search_config(num_params, spin=spin, 
lower=lower, upper=upper, inc=inc, scaling_matrix=scaling_matrix)
+
+            # Scaling of values for the set function.
+            if match('^[Ss]et', min_algor):
+                min_options = dot(inv(scaling_matrix), min_options)
+
+            # Linear constraints.
+            if constraints:
+                A, b = self.linear_constraints(num_params, 
param_set=param_set, spin=spin, scaling_matrix=scaling_matrix)
 
             # Initialise the iteration counter and function, gradient, and 
Hessian call counters.
             iter_count = 0
@@ -1212,16 +1213,26 @@
         return relax_data, relax_error, equations, param_types, 
param_values, r, csa, num_frq, frq, num_ri, remap_table, noe_r1_table, 
ri_labels, num_params, xh_unit_vectors, diff_type, diff_params
 
 
-    def test_grid_size(self, min_options):
+    def test_grid_size(self, min_options, verbosity=1):
         """Test the size of the grid search.
 
         @param min_options: The grid search configuration.
         @type min_options:  list
+        @keyword verbosity: A flag specifying the amount of information to 
print.  The higher the
+                            value, the greater the verbosity.
+        @type verbosity:    int
         @raises RelaxError: If the grid size corresponds to a long int.
         """
 
+        # Determine the grid size.
         grid_size = 1
         for i in xrange(len(min_options)):
             grid_size = grid_size * min_options[i][0]
+
+        # Print out.
+        if verbosity >= 1:
+            print "Unconstrained grid search size: " + `grid_size` + " 
(constraints may decrease this size).\n"
+
+        # Too big.
         if type(grid_size) == long:
             raise RelaxError, "A grid search of size " + `grid_size` + " is 
too large."




Related Messages


Powered by MHonArc, Updated Sun Mar 23 16:00:24 2008