leeping/forcebalance — pull request #48 by leeping (2014-02-21 00:38:53+00:00)
Title: Parameter mask

With this PR, the "parameter mask" feature is implemented. The motivation is that we are going to do some optimizations with very large numbers of parameters (hundreds to thousands), but each target might depend on only a few parameters. Since many of our derivatives are calculated using finite difference, a loop over the irrelevant parameters for a target would be a huge waste of time.

The solution implemented here is to calculate the full gradient vector just once, and we save the parameter names for which the target gradient is exactly zero. Future iterations will skip over these parameters instead of calculating the gradient, because it is known to be zero. The parameter names are written to a file in the `targets/target_name` folder, so subsequent calculations know to skip over these parameter names as well.

The trouble is that we might run into situations where the true gradient really is zero, but not because it's irrelevant (instead we might be at a critical point). I can't think of too many situations where this would be true though.

This is a moderately large change; most targets have been modified because I had previously assumed a loop over all of the parameters. Also I had to pass the `pgrad` vector (containing active parameters for gradients) into `npt.py`, `npt-lipid.py` and `md-chain.py`. I'll leave the PR open for a day or so and then merge it. There's a small chance a few things will break, hopefully not.