Changes

Jump to navigation Jump to search

Relax 3.3.0

45 bytes added, 07:49, 8 September 2014
m
Formatting of powers.
* Lowered the looping in [[NS CPMG 2-site 3D]], by preforming the initial dot product. [https://gna.org/task/?7807 Task #7807]: Speed-up of dispersion models for clustered analysis.
* Speeded up [[NS CPMG 2-site 3D]], by preforming the magnetisation. [https://gna.org/task/?7807 Task #7807]: Speed-up of dispersion models for clustered analysis.
* Got rid of the inner evolution of the magnetization. If the looping over the number of CPMG elements is given by the index l, and the initial magnetization has been formed, then the number of times for propagation of magnetization is l = power_si_mi_di-1. If the magnetization matrix "Mint" has the index Mint_(i,k) and the evolution matrix has the index Evol_(k,j), i=1, k=7, j=7 then the dot product is given by: Sum_{k=1}^{k} Mint_(1,k) * Evol_(k,j) = D_(1, j). The numpy einsum formula for this would be: einsum('ik,kj -> ij', Mint, Evol). Following evolution will be: Sum_{k=1}^{k} D_(1, j) * Evol_(k,j) = Mint_(1,k) * Evol_(k,j) * Evol_(k,j). We can then realize, that the evolution matrix can be raised to the power l. Evol_P = Evol**<sup>l</sup>. It will then be: einsum('ik,kj -> ij', Mint, Evol_P). Get which power to raise the matrix to. l = power_si_mi_di-1. Raise the square evolution matrix to the power l. evolution_matrix_T_pwer_i = matrix_power(evolution_matrix_T_i, l), Mint_T_i = dot(Mint_T_i, evolution_matrix_T_pwer_i) or Mint_T_i = einsum('ik,kj -> ij', Mint_T_i, evolution_matrix_T_pwer_i). [https://gna.org/task/?7807 Task #7807]: Speed-up of dispersion models for clustered analysis.
* Tried to implement using lib.linear_algebra.matrix_power.square_matrix_power instead of matrix_power from numpy in [[NS CPMG 2-site 3D]]. Strangely, then system test: test_hansen_cpmg_data_to_ns_cpmg_2site_3D_full starts to fail. [https://gna.org/task/?7807 Task #7807]: Speed-up of dispersion models for clustered analysis.
* Changes to unit test of [[NS CPMG 2-site 3D]]. This is after the new initiated M0 matrix in init of target function. [https://gna.org/task/?7807 Task #7807]: Speed-up of dispersion models for clustered analysis.
* Modified the behaviour of the parameter object units() method. If the unit is set to the default of None, this method will now return an empty string instead of None.
* The rx parameter of the relaxation curve-fitting analysis now has 'rad.s^-1' units defined.
* Implemented the zooming grid search. If the zoom level is set to any value other than 0, then the grid width will be divided by 2**<sup>zoom_level </sup> and centred at the current parameter values. If the new grid is outside of the bounds of the original grid, the entire grid will be translated so that it lies entirely within the original.
* Modified the zooming grid search algorithm. If the zoom level is negative, hence the grid will be larger than the original, the checks that the grid is within the original are no longer active.
* Changed the minimise.grid_zoom user function. The zoom level can now be any floating point number or integer, including negative values. The user function docstring has been significantly expanded to explain the entire zooming grid search concept.
* Fix for the script for calculating the numerical gradient for an exponential curve. The off-minimum derivative was not correctly calculated.
* Increased the printouts for the script for calculating the numerical gradient for an exponential curve.
* Bug fix for the chi-squared gradient calculation in the C module. The definition of the square() function needed extra brackets so that the 1/error**<sup>2 </sup> calculation would be 1/(error*error) rather than the incorrect 1/error*error form.
* Fix for the test_dfunc_off_minimum() unit test. This is the test class test_suite.unit_tests._target_functions.test_relax_fit.Test_relax_fit. The wrong gradient was being scaled.
* Switched the optimisation algorithm in test_suite/system_tests/scripts/relax_fit.py. This script, used by the Relax_fit.test_curve_fitting_height and Relax_fit.test_curve_fitting_volume system tests, now uses the BFGS optimisation. This is to demonstrate that the exponential curve gradient function dfunc() is implemented correctly and that more advanced optimisation algorithms can be used (excluding those that require the full Hessian d2func() function).
* Got the method of 'Steepest descent' to work properly, by specifying the Jacobian correctly. The Jacobian was derived according to the &chi;<sup>2</sup> function. The key point was to evaluate the two derivative arrays for all times points, and then sum each of the two arrays together, before constructing the Jacobian. This clearly shows the difference between minfx and scipy.optimize.leastsq. scipy.optimize.leastsq takes as input a function F(x0), which should return the array of weighted differences between function value and measured values: "1. / self.errors * (self.calc_exp(self.times, *params) - self.values)". This will be an array with number of elements 'i' corresponding to number of elements. scipy.optimize.leastsq then internally evaluates the sum of squares -> sum[ (O - E)**<sup>2 </sup> ], and minimises this. This is the &chi;<sup>2</sup>. Minfx requires the function to minimise before hand. So, the "func" should be &chi;<sup>2</sup>. Then the dfunc, and d2func, should be derivative of &chi;<sup>2</sup>, but all elements in the array should still be summed together. [https://gna.org/task/?7822 Task #7822]: Implement user function to estimate R<sub>2eff</sub> and associated errors for exponential curve fitting.
* Got the Quasi-Newton BFGS to work. This uses only the gradient, this gets the same results as 2000 Monte Carlo with simplex and scipy.optimize.leastsq. Error estimation still not provided. [https://gna.org/task/?7822 Task #7822]: Implement user function to estimate R<sub>2eff</sub> and associated errors for exponential curve fitting.
* Removed all code regarding scipy.optimize fmin_cg and fmin_ncg. This problem should soon be able to be solved with minfx. [https://gna.org/task/?7822 Task #7822]: Implement user function to estimate R<sub>2eff</sub> and associated errors for exponential curve fitting.
* Changed the relax_fit.py sample script to use Newton rather than Simplex optimisation. This can lead to significantly faster optimisation times, as shown in the commit message http://article.gmane.org/gmane.science.nmr.relax.scm/23081.
* Changed the optimisation description in the relaxation curve-fitting chapter of the manual. The script example has been converted to match the sample script, replacing the Nelder-Mead simplex algorithm with Newton optimisation, and removing the argument turning diagonal scaling off. All the text about only the simplex algorithm being supported due to the missing gradients and Hessians in the C module have been deleted. The text that linear constraints are not supported has also been removed - but this was fixed when the logarithmic barrier constraint algorithm was added to minfx.
* By using minfx, and the reported Jacobian, it is now possible to get the exact same error estimation as scipy.optimize.leastsq. The fatal error was to set the weighting matrix with diagonal elements as the error. There weights are 1/errors**<sup>2</sup>. There is though some unanswered questions left. The Jacobian used, is the direct derivative of the function. It is not the &chi;<sup>2</sup> derivative Jacobian. [https://gna.org/task/?7822 Task #7822]: Implement user function to estimate R<sub>2eff</sub> and associated errors for exponential curve fitting.
* Fixed naming of functions, to better represent what they do in module of estimating R<sub>2eff</sub>. [https://gna.org/task/?7822 Task #7822]: Implement user function to estimate R<sub>2eff</sub> and associated errors for exponential curve fitting.
* Implemented the Jacobian of exponential function in Python code. This now also gets the same error as leastsq and C code. [https://gna.org/task/?7822 Task #7822]: Implement user function to estimate R<sub>2eff</sub> and associated errors for exponential curve fitting.
Trusted, Bureaucrats
4,228

edits

Navigation menu