Author: bugman
Date: Wed Sep 17 17:11:20 2014
New Revision: 25867
URL: http://svn.gna.org/viewcvs/relax?rev=25867&view=rev
Log:
Converted all of the specific_analyses.frame_order package to the Sobol' point
oversampling design.
The correct values are now sent into the target function and all references to
cdp.num_int_pts has
been replaced with the cdp.sobol_max_points and cdp.sobol_oversample pair of
variables.
The frame_order.count_sobol_points user function backend has also been updated
to show the total
number of oversampling points and the number of points used.
Modified:
branches/frame_order_cleanup/specific_analyses/frame_order/api.py
branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py
branches/frame_order_cleanup/specific_analyses/frame_order/uf.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=25867&r1=25866&r2=25867&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/frame_order/api.py
(original)
+++ branches/frame_order_cleanup/specific_analyses/frame_order/api.py Wed Sep
17 17:11:20 2014
@@ -130,7 +130,7 @@
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(sim_index=sim_index, verbosity=verbosity, unset_fail=True)
# Set up the optimisation target function class.
- target_fn = frame_order.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=scaling_matrix[0],
com=com, ave_pos_pivot=ave_pos_pivot, pivot=pivot, pivot_opt=pivot_opt,
num_int_pts=cdp.num_int_pts)
+ target_fn = frame_order.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=scaling_matrix[0],
com=com, ave_pos_pivot=ave_pos_pivot, pivot=pivot, pivot_opt=pivot_opt,
sobol_max_points=cdp.sobol_max_points, sobol_oversample=cdp.sobol_oversample)
# Make a single function call. This will cause back calculation and
the data will be stored in the class instance.
chi2 = target_fn.func(param_vector)
@@ -481,7 +481,7 @@
memo = Frame_order_memo(sim_index=sim_index,
scaling_matrix=scaling_matrix[0])
# Set up the command object to send to the slave and execute.
- command = Frame_order_grid_command(points=subdivision,
scaling_matrix=scaling_matrix[0], sim_index=sim_index, model=cdp.model,
param_vector=param_vector, full_tensors=full_tensors,
full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_err=rdc_err,
rdc_weight=rdc_weight, rdc_vect=rdc_vect, rdc_const=rdc_const, pcs=pcs,
pcs_err=pcs_err, pcs_weight=pcs_weight, atomic_pos=atomic_pos, temp=temp,
frq=frq, paramag_centre=paramag_centre, com=com, ave_pos_pivot=ave_pos_pivot,
pivot=pivot, pivot_opt=pivot_opt, num_int_pts=cdp.num_int_pts,
verbosity=verbosity)
+ command = Frame_order_grid_command(points=subdivision,
scaling_matrix=scaling_matrix[0], sim_index=sim_index, model=cdp.model,
param_vector=param_vector, full_tensors=full_tensors,
full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_err=rdc_err,
rdc_weight=rdc_weight, rdc_vect=rdc_vect, rdc_const=rdc_const, pcs=pcs,
pcs_err=pcs_err, pcs_weight=pcs_weight, atomic_pos=atomic_pos, temp=temp,
frq=frq, paramag_centre=paramag_centre, com=com, ave_pos_pivot=ave_pos_pivot,
pivot=pivot, pivot_opt=pivot_opt, sobol_max_points=cdp.sobol_max_points,
sobol_oversample=cdp.sobol_oversample, verbosity=verbosity)
# Add the slave command and memo to the processor queue.
processor.add_to_queue(command, memo)
@@ -572,7 +572,7 @@
memo = Frame_order_memo(sim_index=sim_index,
scaling_matrix=scaling_matrix[0])
# Set up the command object to send to the slave and execute.
- command = Frame_order_minimise_command(min_algor=min_algor,
min_options=min_options, func_tol=func_tol, grad_tol=grad_tol,
max_iterations=max_iterations, scaling_matrix=scaling_matrix[0],
constraints=constraints, sim_index=sim_index, model=cdp.model,
param_vector=param_vector, full_tensors=full_tensors,
full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_err=rdc_err,
rdc_weight=rdc_weight, rdc_vect=rdc_vect, rdc_const=rdc_const, pcs=pcs,
pcs_err=pcs_err, pcs_weight=pcs_weight, atomic_pos=atomic_pos, temp=temp,
frq=frq, paramag_centre=paramag_centre, com=com, ave_pos_pivot=ave_pos_pivot,
pivot=pivot, pivot_opt=pivot_opt, num_int_pts=cdp.num_int_pts,
verbosity=verbosity)
+ command = Frame_order_minimise_command(min_algor=min_algor,
min_options=min_options, func_tol=func_tol, grad_tol=grad_tol,
max_iterations=max_iterations, scaling_matrix=scaling_matrix[0],
constraints=constraints, sim_index=sim_index, model=cdp.model,
param_vector=param_vector, full_tensors=full_tensors,
full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_err=rdc_err,
rdc_weight=rdc_weight, rdc_vect=rdc_vect, rdc_const=rdc_const, pcs=pcs,
pcs_err=pcs_err, pcs_weight=pcs_weight, atomic_pos=atomic_pos, temp=temp,
frq=frq, paramag_centre=paramag_centre, com=com, ave_pos_pivot=ave_pos_pivot,
pivot=pivot, pivot_opt=pivot_opt, sobol_max_points=cdp.sobol_max_points,
sobol_oversample=cdp.sobol_oversample, verbosity=verbosity)
# Add the slave command and memo to the processor queue.
processor.add_to_queue(command, memo)
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=25867&r1=25866&r2=25867&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py
(original)
+++ branches/frame_order_cleanup/specific_analyses/frame_order/optimisation.py
Wed Sep 17 17:11:20 2014
@@ -84,7 +84,7 @@
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)
+ 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, sobol_max_points=cdp.sobol_max_points,
sobol_oversample=cdp.sobol_oversample)
# The Sobol' sequence dimensions.
if cdp.model in [MODEL_ISO_CONE, MODEL_ISO_CONE_FREE_ROTOR,
MODEL_PSEUDO_ELLIPSE, MODEL_PSEUDO_ELLIPSE_FREE_ROTOR]:
@@ -128,8 +128,9 @@
cone_theta = cdp.cone_theta
# Loop over the Sobol' points to count them.
+ total_num = len(target_fn.sobol_angles)
count = 0
- for i in range(len(target_fn.sobol_angles)):
+ for i in range(total_num):
# Pseudo-elliptic cone opening angle.
if pe and theta[i] > theta_max[i]:
continue
@@ -149,13 +150,17 @@
# Increment the point count.
count += 1
+ # Maximum reached.
+ if count == cdp.sobol_max_points:
+ break
+
# Store the count.
cdp.used_sobol_points = count
# Printout.
- print("\n%-20s %20s" % ("Total points:", cdp.num_int_pts))
+ print("\n%-20s %20s" % ("Total points:", total_num))
print("%-20s %20s" % ("Used points:", count))
- percent = "%s" % (float(count)/float(cdp.num_int_pts)*100) + '%'
+ percent = "%s" % (float(count)/float(total_num)*100) + '%'
print("%-20s %20s" % ("Percentage:", percent))
@@ -778,10 +783,6 @@
if pivot_fixed():
pivot_opt = False
- # The number of integration points.
- if not hasattr(cdp, 'num_int_pts'):
- cdp.num_int_pts = 200000
-
# The centre of mass of the moving domain - to use as the centroid for the
average domain position rotation.
ave_pos_pivot = pipe_centre_of_mass(atom_id=domain_moving(), verbosity=0)
@@ -799,7 +800,6 @@
sys.stdout.write("The centre of mass reference coordinate for the
rotor models is:\n %s\n" % list(com))
if cdp.model != MODEL_RIGID:
sys.stdout.write("Numerical integration: Quasi-random Sobol'
sequence.\n")
- sys.stdout.write("Number of integration points: %s\n" %
cdp.num_int_pts)
base_data = []
if rdcs != None and len(rdcs):
base_data.append("RDCs")
@@ -914,7 +914,7 @@
class Frame_order_grid_command(Slave_command):
"""Command class for relaxation dispersion optimisation on the slave
processor."""
- def __init__(self, points=None, scaling_matrix=None, sim_index=None,
model=None, param_vector=None, full_tensors=None, full_in_ref_frame=None,
rdcs=None, rdc_err=None, rdc_weight=None, rdc_vect=None, rdc_const=None,
pcs=None, pcs_err=None, pcs_weight=None, atomic_pos=None, temp=None, frq=None,
paramag_centre=None, com=None, ave_pos_pivot=None, pivot=None, pivot_opt=None,
num_int_pts=None, verbosity=None):
+ def __init__(self, points=None, scaling_matrix=None, sim_index=None,
model=None, param_vector=None, full_tensors=None, full_in_ref_frame=None,
rdcs=None, rdc_err=None, rdc_weight=None, rdc_vect=None, rdc_const=None,
pcs=None, pcs_err=None, pcs_weight=None, atomic_pos=None, temp=None, frq=None,
paramag_centre=None, com=None, ave_pos_pivot=None, pivot=None, pivot_opt=None,
sobol_max_points=None, sobol_oversample=None, verbosity=None):
"""Initialise the base class, storing all the master data to be sent
to the slave processor.
This method is run on the master processor whereas the run() method is
run on the slave processor.
@@ -965,8 +965,10 @@
@type pivot: numpy rank-1, 3D array or None
@keyword pivot_opt: A flag which if True will allow the pivot
point of the motion to be optimised.
@type pivot_opt: bool
- @keyword num_int_pts: The number of points to use for the
numerical integration technique.
- @type num_int_pts: int
+ @keyword sobol_max_points: The maximum number of Sobol' points to use
for the numerical PCS integration technique.
+ @type sobol_max_points: int
+ @keyword sobol_oversample: The oversampling factor Ov used for the
total number of points N * Ov * 10**M, where N is the maximum number of Sobol'
points and M is the number of dimensions or torsion-tilt angles for the system.
+ @type sobol_oversample: int
@keyword verbosity: The verbosity level. This is used by the
result command returned to the master for printouts.
@type verbosity: int
"""
@@ -994,7 +996,8 @@
self.ave_pos_pivot = ave_pos_pivot
self.pivot = pivot
self.pivot_opt = pivot_opt
- self.num_int_pts = num_int_pts
+ self.sobol_max_points = sobol_max_points
+ self.sobol_oversample = sobol_oversample
self.verbosity = verbosity
@@ -1002,7 +1005,7 @@
"""Set up and perform the optimisation."""
# Set up the optimisation target function class.
- target_fn = Frame_order(model=self.model,
init_params=self.param_vector, full_tensors=self.full_tensors,
full_in_ref_frame=self.full_in_ref_frame, rdcs=self.rdcs,
rdc_errors=self.rdc_err, rdc_weights=self.rdc_weight, rdc_vect=self.rdc_vect,
dip_const=self.rdc_const, pcs=self.pcs, pcs_errors=self.pcs_err,
pcs_weights=self.pcs_weight, atomic_pos=self.atomic_pos, temp=self.temp,
frq=self.frq, paramag_centre=self.paramag_centre,
scaling_matrix=self.scaling_matrix, com=self.com,
ave_pos_pivot=self.ave_pos_pivot, pivot=self.pivot, pivot_opt=self.pivot_opt,
num_int_pts=self.num_int_pts)
+ target_fn = Frame_order(model=self.model,
init_params=self.param_vector, full_tensors=self.full_tensors,
full_in_ref_frame=self.full_in_ref_frame, rdcs=self.rdcs,
rdc_errors=self.rdc_err, rdc_weights=self.rdc_weight, rdc_vect=self.rdc_vect,
dip_const=self.rdc_const, pcs=self.pcs, pcs_errors=self.pcs_err,
pcs_weights=self.pcs_weight, atomic_pos=self.atomic_pos, temp=self.temp,
frq=self.frq, paramag_centre=self.paramag_centre,
scaling_matrix=self.scaling_matrix, com=self.com,
ave_pos_pivot=self.ave_pos_pivot, pivot=self.pivot, pivot_opt=self.pivot_opt,
sobol_max_points=self.sobol_max_points, sobol_oversample=self.sobol_oversample)
# Grid search.
results = grid_point_array(func=target_fn.func, args=(),
points=self.points, verbosity=self.verbosity)
@@ -1047,7 +1050,7 @@
class Frame_order_minimise_command(Slave_command):
"""Command class for relaxation dispersion optimisation on the slave
processor."""
- def __init__(self, min_algor=None, min_options=None, func_tol=None,
grad_tol=None, max_iterations=None, scaling_matrix=None, constraints=False,
sim_index=None, model=None, param_vector=None, full_tensors=None,
full_in_ref_frame=None, rdcs=None, rdc_err=None, rdc_weight=None,
rdc_vect=None, rdc_const=None, pcs=None, pcs_err=None, pcs_weight=None,
atomic_pos=None, temp=None, frq=None, paramag_centre=None, com=None,
ave_pos_pivot=None, pivot=None, pivot_opt=None, num_int_pts=None,
verbosity=None):
+ def __init__(self, min_algor=None, min_options=None, func_tol=None,
grad_tol=None, max_iterations=None, scaling_matrix=None, constraints=False,
sim_index=None, model=None, param_vector=None, full_tensors=None,
full_in_ref_frame=None, rdcs=None, rdc_err=None, rdc_weight=None,
rdc_vect=None, rdc_const=None, pcs=None, pcs_err=None, pcs_weight=None,
atomic_pos=None, temp=None, frq=None, paramag_centre=None, com=None,
ave_pos_pivot=None, pivot=None, pivot_opt=None, sobol_max_points=None,
sobol_oversample=None, verbosity=None):
"""Initialise the base class, storing all the master data to be sent
to the slave processor.
This method is run on the master processor whereas the run() method is
run on the slave processor.
@@ -1106,8 +1109,10 @@
@type pivot: numpy rank-1, 3D array or None
@keyword pivot_opt: A flag which if True will allow the pivot
point of the motion to be optimised.
@type pivot_opt: bool
- @keyword num_int_pts: The number of points to use for the
numerical integration technique.
- @type num_int_pts: int
+ @keyword sobol_max_points: The maximum number of Sobol' points to use
for the numerical PCS integration technique.
+ @type sobol_max_points: int
+ @keyword sobol_oversample: The oversampling factor Ov used for the
total number of points N * Ov * 10**M, where N is the maximum number of Sobol'
points and M is the number of dimensions or torsion-tilt angles for the system.
+ @type sobol_oversample: int
@keyword scaling_matrix: The diagonal, square scaling matrix.
@type scaling_matrix: numpy diagonal matrix
"""
@@ -1139,7 +1144,8 @@
self.ave_pos_pivot = ave_pos_pivot
self.pivot = pivot
self.pivot_opt = pivot_opt
- self.num_int_pts = num_int_pts
+ self.sobol_max_points = sobol_max_points
+ self.sobol_oversample = sobol_oversample
self.verbosity = verbosity
# Linear constraints.
@@ -1163,7 +1169,7 @@
"""Set up and perform the optimisation."""
# Set up the optimisation target function class.
- target_fn = Frame_order(model=self.model,
init_params=self.param_vector, full_tensors=self.full_tensors,
full_in_ref_frame=self.full_in_ref_frame, rdcs=self.rdcs,
rdc_errors=self.rdc_err, rdc_weights=self.rdc_weight, rdc_vect=self.rdc_vect,
dip_const=self.rdc_const, pcs=self.pcs, pcs_errors=self.pcs_err,
pcs_weights=self.pcs_weight, atomic_pos=self.atomic_pos, temp=self.temp,
frq=self.frq, paramag_centre=self.paramag_centre,
scaling_matrix=self.scaling_matrix, com=self.com,
ave_pos_pivot=self.ave_pos_pivot, pivot=self.pivot, pivot_opt=self.pivot_opt,
num_int_pts=self.num_int_pts)
+ target_fn = Frame_order(model=self.model,
init_params=self.param_vector, full_tensors=self.full_tensors,
full_in_ref_frame=self.full_in_ref_frame, rdcs=self.rdcs,
rdc_errors=self.rdc_err, rdc_weights=self.rdc_weight, rdc_vect=self.rdc_vect,
dip_const=self.rdc_const, pcs=self.pcs, pcs_errors=self.pcs_err,
pcs_weights=self.pcs_weight, atomic_pos=self.atomic_pos, temp=self.temp,
frq=self.frq, paramag_centre=self.paramag_centre,
scaling_matrix=self.scaling_matrix, com=self.com,
ave_pos_pivot=self.ave_pos_pivot, pivot=self.pivot, pivot_opt=self.pivot_opt,
sobol_max_points=self.sobol_max_points, sobol_oversample=self.sobol_oversample)
# 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)
Modified: branches/frame_order_cleanup/specific_analyses/frame_order/uf.py
URL:
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/frame_order/uf.py?rev=25867&r1=25866&r2=25867&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/frame_order/uf.py
(original)
+++ branches/frame_order_cleanup/specific_analyses/frame_order/uf.py Wed Sep
17 17:11:20 2014
@@ -385,7 +385,7 @@
# Store the values.
cdp.sobol_max_points = max_num
- cdp.sobol_oversample_factor = oversample
+ cdp.sobol_oversample = oversample
# Count the number of Sobol' points for the current model.
count_sobol_points()
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits