Author: bugman Date: Fri Jul 16 19:13:13 2010 New Revision: 11314 URL: http://svn.gna.org/viewcvs/relax?rev=11314&view=rev Log: Pre-defined probabilities can now be used in the 'fixed' N-state model optimisation. Modified: 1.3/maths_fns/n_state_model.py 1.3/specific_fns/n_state_model.py Modified: 1.3/maths_fns/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/1.3/maths_fns/n_state_model.py?rev=11314&r1=11313&r2=11314&view=diff ============================================================================== --- 1.3/maths_fns/n_state_model.py (original) +++ 1.3/maths_fns/n_state_model.py Fri Jul 16 19:13:13 2010 @@ -39,7 +39,7 @@ class N_state_opt: """Class containing the target function of the optimisation of the N-state model.""" - def __init__(self, model=None, N=None, init_params=None, full_tensors=None, red_data=None, red_errors=None, full_in_ref_frame=None, pcs=None, pcs_errors=None, pcs_weights=None, rdcs=None, rdc_errors=None, rdc_weights=None, xh_vect=None, temp=None, frq=None, dip_const=None, atomic_pos=None, paramag_centre=None, scaling_matrix=None, centre_fixed=True): + def __init__(self, model=None, N=None, init_params=None, probs=None, full_tensors=None, red_data=None, red_errors=None, full_in_ref_frame=None, pcs=None, pcs_errors=None, pcs_weights=None, rdcs=None, rdc_errors=None, rdc_weights=None, xh_vect=None, temp=None, frq=None, dip_const=None, atomic_pos=None, paramag_centre=None, scaling_matrix=None, centre_fixed=True): """Set up the class instance for optimisation. The N-state models @@ -107,6 +107,8 @@ @type N: int @keyword init_params: The initial parameter values. Optimisation must start at some point! @type init_params: numpy float64 array + @keyword probs: The probabilities for each state c. The length of this list should be equal to N. + @type probs: list of float @keyword full_tensors: An array of the {Sxx, Syy, Sxy, Sxz, Syz} values for all full tensors. The format is [Sxx1, Syy1, Sxy1, Sxz1, Syz1, Sxx2, Syy2, Sxy2, Sxz2, Syz2, ..., Sxxn, Syyn, Sxyn, Sxzn, Syzn] @type full_tensors: list of rank-2, 3D numpy arrays @keyword red_data: An array of the {Sxx, Syy, Sxy, Sxz, Syz} values for all reduced tensors. The format is the same as for full_tensors. @@ -361,9 +363,6 @@ # Set up the paramagnetic info. self.paramag_info() - # The probability array (all structures have initial equal probability). - self.probs = ones(self.N, float64) / self.N - # PCS function, gradient, and Hessian matrices. self.deltaij_theta = zeros((self.num_align, self.num_spins), float64) self.ddeltaij_theta = zeros((self.total_num_params, self.num_align, self.num_spins), float64) @@ -388,6 +387,14 @@ # Pure tensor optimisation overrides. if model == 'fixed' and self.centre_fixed: + # The probability array. + if probs: + self.probs = probs + + # All structures have initial equal probability. + else: + self.probs = ones(self.N, float64) / self.N + # The probs are unpacked by self.func in the population model, so just override that function. self.func = self.func_tensor_opt self.dfunc = self.dfunc_tensor_opt Modified: 1.3/specific_fns/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/n_state_model.py?rev=11314&r1=11313&r2=11314&view=diff ============================================================================== --- 1.3/specific_fns/n_state_model.py (original) +++ 1.3/specific_fns/n_state_model.py Fri Jul 16 19:13:13 2010 @@ -1416,6 +1416,11 @@ # Determine if alignment tensors or RDCs are to be used. data_types = self._base_data_types() + # The probabilities. + probs = None + if hasattr(cdp, 'probs'): + probs = cdp.probs + # Diagonal scaling. scaling_matrix = None if len(param_vector): @@ -1451,7 +1456,7 @@ centre_fixed = cdp.paramag_centre_fixed # Set up the class instance containing the target function. - model = N_state_opt(model=cdp.model, N=cdp.N, init_params=param_vector, full_tensors=full_tensors, red_data=red_tensor_elem, red_errors=red_tensor_err, full_in_ref_frame=full_in_ref_frame, pcs=pcs, rdcs=rdcs, pcs_errors=pcs_err, rdc_errors=rdc_err, pcs_weights=pcs_weight, rdc_weights=rdc_weight, xh_vect=xh_vect, temp=temp, frq=frq, dip_const=rdc_dj, atomic_pos=atomic_pos, paramag_centre=paramag_centre, scaling_matrix=scaling_matrix, centre_fixed=centre_fixed) + model = N_state_opt(model=cdp.model, N=cdp.N, init_params=param_vector, probs=probs, full_tensors=full_tensors, red_data=red_tensor_elem, red_errors=red_tensor_err, full_in_ref_frame=full_in_ref_frame, pcs=pcs, rdcs=rdcs, pcs_errors=pcs_err, rdc_errors=rdc_err, pcs_weights=pcs_weight, rdc_weights=rdc_weight, xh_vect=xh_vect, temp=temp, frq=frq, dip_const=rdc_dj, atomic_pos=atomic_pos, paramag_centre=paramag_centre, scaling_matrix=scaling_matrix, centre_fixed=centre_fixed) # Return the data. return model, param_vector, data_types, scaling_matrix