mailr4553 - in /branches/N_state_model: ./ generic_fns/minimise.py


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

Header


Content

Posted by edward on January 09, 2008 - 14:42:
Author: bugman
Date: Wed Jan  9 14:42:52 2008
New Revision: 4553

URL: http://svn.gna.org/viewcvs/relax?rev=4553&view=rev
Log:
Merged revisions 4549-4551 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r4549 | bugman | 2008-01-09 14:38:00 +0100 (Wed, 09 Jan 2008) | 3 lines
  
  Changed all instances of the 'print_flag' arg to 'verbosity' in the 
generic_fns.minimise module.
........
  r4550 | bugman | 2008-01-09 14:39:09 +0100 (Wed, 09 Jan 2008) | 3 lines
  
  Removed some unused imports.
........
  r4551 | bugman | 2008-01-09 14:41:03 +0100 (Wed, 09 Jan 2008) | 3 lines
  
  Changed all the 'constraints' and 'scaling' args to be of bool type.
........

Modified:
    branches/N_state_model/   (props changed)
    branches/N_state_model/generic_fns/minimise.py

Propchange: branches/N_state_model/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: branches/N_state_model/generic_fns/minimise.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/N_state_model/generic_fns/minimise.py?rev=4553&r1=4552&r2=4553&view=diff
==============================================================================
--- branches/N_state_model/generic_fns/minimise.py (original)
+++ branches/N_state_model/generic_fns/minimise.py Wed Jan  9 14:42:52 2008
@@ -21,13 +21,12 @@
 
###############################################################################
 
 # Python module imports.
-from Queue import Queue
 from re import search
 
 # relax module imports.
 from data import Data as relax_data_store
 from selection import spin_loop
-from relax_errors import RelaxError, RelaxNoPipeError
+from relax_errors import RelaxError
 from specific_fns import get_specific_fn
 
 
@@ -108,12 +107,12 @@
 
 
 
-def calc(print_flag=1):
+def calc(verbosity=1):
     """Function for calculating the function value.
 
-    @param print_flag:  A flag specifying the amount of information to 
print.  The higher the value,
-                        the greater the verbosity.
-    @type print_flag:   int
+    @param verbosity:   The amount of information to print.  The higher the 
value, the greater
+                        the verbosity.
+    @type verbosity:    int
     """
 
     # Alias the current data pipe.
@@ -130,16 +129,16 @@
     if hasattr(cdp, 'sim_state') and cdp.sim_state == 1:
         # Loop over the simulations.
         for i in xrange(cdp.sim_number):
-            if print_flag:
+            if verbosity:
                 print "Simulation " + `i+1`
-            calculate(print_flag=print_flag-1, sim_index=i)
+            calculate(verbosity=verbosity-1, sim_index=i)
 
     # Minimisation.
     else:
-        calculate(print_flag=print_flag)
-
-
-def grid_search(lower=None, upper=None, inc=None, constraints=1, 
print_flag=1):
+        calculate(verbosity=verbosity)
+
+
+def grid_search(lower=None, upper=None, inc=None, constraints=True, 
verbosity=1):
     """The grid search function.
 
     @param lower:       The lower bounds of the grid search which must be 
equal to the number of
@@ -152,12 +151,12 @@
                         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 (elinating parts of
-                        the grid).  If false, no constraints are used.
+    @param constraints: If True, constraints are applied during the grid 
search (elinating parts of
+                        the grid).  If False, no constraints are used.
     @type constraints:  bool
-    @param print_flag:  A flag specifying the amount of information to 
print.  The higher the value,
-                        the greater the verbosity.
-    @type print_flag:   int
+    @param verbosity:   The amount of information to print.  The higher the 
value, the greater
+                        the verbosity.
+    @type verbosity:    int
     """
 
     # Alias the current data pipe.
@@ -174,16 +173,16 @@
     if hasattr(cdp, 'sim_state') and cdp.sim_state == 1:
         # Loop over the simulations.
         for i in xrange(cdp.sim_number):
-            if print_flag:
+            if verbosity:
                 print "Simulation " + `i+1`
-            grid_search(lower=lower, upper=upper, inc=inc, 
constraints=constraints, print_flag=print_flag-1, sim_index=i)
+            grid_search(lower=lower, upper=upper, inc=inc, 
constraints=constraints, verbosity=verbosity-1, sim_index=i)
 
     # Grid search.
     else:
-        grid_search(lower=lower, upper=upper, inc=inc, 
constraints=constraints, print_flag=print_flag)
-
-
-def minimise(min_algor=None, min_options=None, func_tol=None, grad_tol=None, 
max_iterations=None, constraints=1, scaling=1, print_flag=1, sim_index=None):
+        grid_search(lower=lower, upper=upper, inc=inc, 
constraints=constraints, verbosity=verbosity)
+
+
+def minimise(min_algor=None, min_options=None, func_tol=None, grad_tol=None, 
max_iterations=None, constraints=True, scaling=True, verbosity=1, 
sim_index=None):
     """Minimisation function.
 
     @param min_algor:       The minimisation algorithm to use.
@@ -198,14 +197,14 @@
     @type grad_tol:         None or float
     @param max_iterations:  The maximum number of iterations for the 
algorithm.
     @type max_iterations:   int
-    @param constraints:     If true, constraints are used during 
optimisation.
+    @param constraints:     If True, constraints are used during 
optimisation.
     @type constraints:      bool
-    @param scaling:         If true, diagonal scaling is enabled during 
optimisation to allow the
+    @param scaling:         If True, diagonal scaling is enabled during 
optimisation to allow the
                             problem to be better conditioned.
     @type scaling:          bool
-    @param print_flag:      A flag specifying the amount of information to 
print.  The higher the
-                            value, the greater the verbosity.
-    @type print_flag:       int
+    @param verbosity:       The amount of information to print.  The higher 
the value, the greater
+                            the verbosity.
+    @type verbosity:        int
     @param sim_index:       The index of the simulation to optimise.  This 
should be None if normal
                             optimisation is desired.
     @type sim_index:        None or int
@@ -223,18 +222,18 @@
 
     # Single Monte Carlo simulation.
     if sim_index != None:
-        minimise(min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, print_flag=print_flag, 
sim_index=sim_index)
+        minimise(min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, verbosity=verbosity, 
sim_index=sim_index)
 
     # Monte Carlo simulation minimisation.
     elif hasattr(relax_data_store, 'sim_state') and 
relax_data_store.sim_state == 1:
         for i in xrange(relax_data_store.sim_number):
-            if print_flag:
+            if verbosity:
                 print "Simulation " + `i+1`
-            minimise(min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, print_flag=print_flag-1, 
sim_index=i)
+            minimise(min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, verbosity=verbosity-1, sim_index=i)
 
     # Standard minimisation.
     else:
-        minimise(min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, print_flag=print_flag)
+        minimise(min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, verbosity=verbosity)
 
 
 def return_conversion_factor(stat_type):




Related Messages


Powered by MHonArc, Updated Wed Jan 09 15:20:23 2008