mailr25837 - in /branches/frame_order_cleanup/specific_analyses/frame_order: api.py optimisation.py


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

Header


Content

Posted by edward on September 14, 2014 - 15:38:
Author: bugman
Date: Sun Sep 14 15:38:39 2014
New Revision: 25837

URL: http://svn.gna.org/viewcvs/relax?rev=25837&view=rev
Log:
The frame order count_sobol_points() function is now being called by all of 
minimise user functions.

This occurs at the end of the minimise.calculate, minimise.grid_search, and 
minimise.execute user
function backends to provide more feedback to the user as to the quality of 
the optimisation.  To
avoid initialising the target function twice, the count_sobol_points() 
function now accepts the
initialised target function as an optional argument.


Modified:
    branches/frame_order_cleanup/specific_analyses/frame_order/api.py
    branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py

Modified: branches/frame_order_cleanup/specific_analyses/frame_order/api.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/frame_order/api.py?rev=25837&r1=25836&r2=25837&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/frame_order/api.py   
(original)
+++ branches/frame_order_cleanup/specific_analyses/frame_order/api.py   Sun 
Sep 14 15:38:39 2014
@@ -41,7 +41,7 @@
 from specific_analyses.api_common import API_common
 from specific_analyses.frame_order.checks import check_pivot
 from specific_analyses.frame_order.data import domain_moving
-from specific_analyses.frame_order.optimisation import 
Frame_order_grid_command, Frame_order_memo, Frame_order_minimise_command, 
grid_row, store_bc_data, target_fn_data_setup
+from specific_analyses.frame_order.optimisation import 
Frame_order_grid_command, Frame_order_memo, Frame_order_minimise_command, 
count_sobol_points, grid_row, store_bc_data, target_fn_data_setup
 from specific_analyses.frame_order.parameter_object import Frame_order_params
 from specific_analyses.frame_order.parameters import assemble_param_vector, 
linear_constraints, param_num, update_model
 from specific_analyses.frame_order.variables import MODEL_ISO_CONE_FREE_ROTOR
@@ -140,6 +140,9 @@
 
         # Store the back-calculated data.
         store_bc_data(A_5D_bc=target_fn.A_5D_bc, 
pcs_theta=target_fn.pcs_theta, rdc_theta=target_fn.rdc_theta)
+
+        # Feedback on the number of integration points used.
+        count_sobol_points(target_fn=target_fn)
 
         # Printout.
         print("Chi2:  %s" % chi2)

Modified: 
branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py?rev=25837&r1=25836&r2=25837&view=diff
==============================================================================
--- 
branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py  
(original)
+++ 
branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py  
Sun Sep 14 15:38:39 2014
@@ -52,33 +52,39 @@
 from target_functions.frame_order import Frame_order
 
 
-def count_sobol_points():
+def count_sobol_points(target_fn=None):
     """Count the number of Sobol' points for the current parameter values of 
the model.
 
     The count will be stored in the current data pipe and printed out.
+
+
+    @keyword target_fn:     The pre-initialised frame order target function 
class.
+    @type target_fn:        target_functions.frame_order.Frame_order instance
     """
 
     # Printout.
     print("Sobol' quasi-random integration point counting for the current 
parameter values.")
-
-    # Checks.
-    if not check_model(escalate=1):
-        return
-    if not check_parameters(escalate=1):
-        return
-    if not check_domain(escalate=1):
-        return
 
     # Handle the rigid model.
     if cdp.model == MODEL_RIGID:
         print("\nSobol' quasi-random integration points are not used for the 
rigid frame order model.")
         return
 
-    # Set up the data structures for the target function.
-    param_vector, full_tensors, full_in_ref_frame, rdcs, rdc_err, 
rdc_weight, rdc_vect, rdc_const, pcs, pcs_err, pcs_weight, atomic_pos, temp, 
frq, paramag_centre, com, ave_pos_pivot, pivot, pivot_opt = 
target_fn_data_setup(verbosity=0, unset_fail=True)
-
-    # Set up the optimisation target function class.
-    target_fn = Frame_order(model=cdp.model, init_params=param_vector, 
full_tensors=full_tensors, full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, 
rdc_errors=rdc_err, rdc_weights=rdc_weight, rdc_vect=rdc_vect, 
dip_const=rdc_const, pcs=pcs, pcs_errors=pcs_err, pcs_weights=pcs_weight, 
atomic_pos=atomic_pos, temp=temp, frq=frq, paramag_centre=paramag_centre, 
scaling_matrix=None, com=com, ave_pos_pivot=ave_pos_pivot, pivot=pivot, 
pivot_opt=pivot_opt, num_int_pts=cdp.num_int_pts)
+    # Set up the target function, if required.
+    if target_fn == None:
+        # Checks.
+        if not check_model(escalate=1):
+            return
+        if not check_parameters(escalate=1):
+            return
+        if not check_domain(escalate=1):
+            return
+
+        # Set up the data structures for the target function.
+        param_vector, full_tensors, full_in_ref_frame, rdcs, rdc_err, 
rdc_weight, rdc_vect, rdc_const, pcs, pcs_err, pcs_weight, atomic_pos, temp, 
frq, paramag_centre, com, ave_pos_pivot, pivot, pivot_opt = 
target_fn_data_setup(verbosity=0, unset_fail=True)
+
+        # Set up the optimisation target function class.
+        target_fn = Frame_order(model=cdp.model, init_params=param_vector, 
full_tensors=full_tensors, full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, 
rdc_errors=rdc_err, rdc_weights=rdc_weight, rdc_vect=rdc_vect, 
dip_const=rdc_const, pcs=pcs, pcs_errors=pcs_err, pcs_weights=pcs_weight, 
atomic_pos=atomic_pos, temp=temp, frq=frq, paramag_centre=paramag_centre, 
scaling_matrix=None, com=com, ave_pos_pivot=ave_pos_pivot, pivot=pivot, 
pivot_opt=pivot_opt, num_int_pts=cdp.num_int_pts)
 
     # The Sobol' sequence dimensions.
     if cdp.model in [MODEL_ISO_CONE, MODEL_ISO_CONE_FREE_ROTOR, 
MODEL_PSEUDO_ELLIPSE, MODEL_PSEUDO_ELLIPSE_FREE_ROTOR]:
@@ -1150,6 +1156,9 @@
         # Minimisation.
         results = generic_minimise(func=target_fn.func, args=(), 
x0=self.param_vector, min_algor=self.min_algor, min_options=self.min_options, 
func_tol=self.func_tol, grad_tol=self.grad_tol, maxiter=self.max_iterations, 
A=self.A, b=self.b, full_output=True, print_flag=self.verbosity)
 
+        # Feedback on the number of integration points used.
+        count_sobol_points(target_fn=target_fn)
+
         # Create the result command object on the slave to send back to the 
master.
         
processor.return_object(Frame_order_result_command(processor=processor, 
memo_id=self.memo_id, results=results, A_5D_bc=target_fn.A_5D_bc, 
pcs_theta=target_fn.pcs_theta, rdc_theta=target_fn.rdc_theta, 
completed=completed))
 




Related Messages


Powered by MHonArc, Updated Sun Sep 14 16:00:02 2014