mailr9087 - /branches/frame_order/specific_fns/frame_order.py


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

Header


Content

Posted by edward on June 19, 2009 - 10:43:
Author: bugman
Date: Fri Jun 19 10:43:37 2009
New Revision: 9087

URL: http://svn.gna.org/viewcvs/relax?rev=9087&view=rev
Log:
Implemented most of the grid_search() method.


Modified:
    branches/frame_order/specific_fns/frame_order.py

Modified: branches/frame_order/specific_fns/frame_order.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order/specific_fns/frame_order.py?rev=9087&r1=9086&r2=9087&view=diff
==============================================================================
--- branches/frame_order/specific_fns/frame_order.py (original)
+++ branches/frame_order/specific_fns/frame_order.py Fri Jun 19 10:43:37 2009
@@ -24,8 +24,70 @@
 """Module for the specific methods of the Frame Order theories."""
 
 # relax module imports.
+from generic_fns import pipes
+from relax_errors import RelaxNoModelError
 from specific_fns.base_class import Common_functions
 
 
 class Frame_order(Common_functions):
     """Class containing the specific methods of the Frame Order theories."""
+
+    def grid_search(self, lower, upper, inc, constraints=False, verbosity=0, 
sim_index=None):
+        """Perform a grid search.
+
+        @param lower:       The lower bounds of the grid search which must 
be equal to the number of
+                            parameters in the model.
+        @type lower:        array of numbers
+        @param 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
+        @param 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
+        @param constraints: If True, constraints are applied during the grid 
search (eliminating
+                            parts of the grid).  If False, no constraints 
are used.
+        @type constraints:  bool
+        @param verbosity:   A flag specifying the amount of information to 
print.  The higher the
+                            value, the greater the verbosity.
+        @type verbosity:    int
+        """
+
+        # Alias the current data pipe.
+        cdp = pipes.get_pipe()
+
+        # Test if the Frame Order model has been set up.
+        if not hasattr(cdp, 'model'):
+            raise RelaxNoModelError, 'Frame Order'
+
+        # The number of parameters.
+        n = len(cdp.params)
+
+        # Initialise the grid_ops structure.
+        grid_ops = []
+        """This structure is a list of lists.  The first dimension 
corresponds to the model
+        parameter.  The second dimension has the elements: 0, the number of 
increments in that
+        dimension; 1, the lower limit of the grid; 2, the upper limit of the 
grid."""
+
+        # Set the grid search options.
+        for i in xrange(n):
+            # Euler angles.
+            if cdp.params[i] in ['alpha', 'gamma']:
+                grid_ops.append([inc[i], 0.0, 2*pi])
+            if cdp.params[i] == 'beta':
+                grid_ops.append([inc[i], 0.0, pi])
+
+            # The cone angle.
+            if cdp.params[i] == 'theta':
+                grid_ops.append([inc[i], 0.0, pi])
+
+            # Lower bound (if supplied).
+            if lower:
+                grid_ops[i][1] = lower[i]
+
+            # Upper bound (if supplied).
+            if upper:
+                grid_ops[i][1] = upper[i]
+
+        # Minimisation.
+        self.minimise(min_algor='grid', min_options=grid_ops, 
constraints=constraints, verbosity=verbosity, sim_index=sim_index)




Related Messages


Powered by MHonArc, Updated Fri Jun 19 11:00:03 2009