Physics usage
mikevitz opened this issue · 5 comments
Hi,
I will be trying to use this package for function interpolation in 4 dimensions of spacetime. That is, there is a function f(x,y,z,t) that I can evaluate easily on a 4-d grid in parallel. But to find the minimum of the function I need to have a continuous evaluation, so I will use interpolation to get the value of f at arbitrary points.
I have some questions/requests:
-
Is the limitation to 100,000 sample points coming from processing time or memory allocation? If it is memory allocation, I have access to a machine that has several TBs of RAM. But if it is processing time, I can plan to have the program run for weeks, but not months.
-
Is it possible to include a basic gcc compilation command for the test functions in the cpp interface? I have installed splinter version 3, but am having trouble compiling anything to an executable.
Hi @mikevitz,
-
The limitation of N=100,000 sample points is only a practical rule-of-thumb. When building a B-spline, the main workload is the solving of a sparse linear system of equations, which is roughly O(N^3). Processing time will be your limiting factor, not memory. A good advise is to try with fewer samples first. When you increase the number of samples (or resolution of your grid), you will get a feeling of how the solve time scales. The increase in accuracy from processing for, say 1 day, compared to 10 minutes, may not be worth the wait. It depends on your application/requirements, of course.
-
Not sure if I understood you correctly, but you can use Catch-flags to (dis-)enable certain tests. I think @gablank can better help you with this.
Please make sure that you are able to store the B-spline after processing. In the master-branch (v3.0), it is possible to store the B-spline in a binary format. This format is due to change, and I would advise that you also store the resulting knots, degrees, and control points in a non-serialized/text format to ensure that you can reuse them in a later version. In the upcoming release we will provide storage in JSON format.
Lastly, for optimization of the resulting spline you may use a multi-start gradient descent heuristic for local optimization using the gradients supplied by SPLINTER. Alternatively, you may attempt to use CENSO for global optimization, but this will require some effort to set up.
Best regards,
Bjarne
PS: Out of curiosity, what kind of system does your function represent?
Hi @bgrimstad,
I'll play around more with it to understand the answer to my first question. Thanks!
For #2 I just mean that for the simple test program, in the section on cpp interface, you say
"Below is a simple example demonstrating the use of SPLINTER. Remember to compile with a C++11 compatible compiler!"
Could you provide a simple compilation command example with known good compiler, like
g++ -I/path_to_include -o testSplinter.x testSplinter.cpp -L/path_to_lib
I will be sure to work on the Bspline storage, but maybe wait for version 4.0 :) But as you may guess, I am just beginning to understand the software...
Many thanks for the attention!
Best Regards,
Mike
P.S. I have two uses. One is to calculate the probability from quantum field theory the probability of a particular event (muon decays), given the values of phase space (they are actually energy variables, not positions, so f(px,py,pz,E) not f(x,y,z,t)...) The formula is hugely complicated to take into account higher order effects. I could pass this directly to the minimization, but this results in a huge slowdown. If I evaluate on a grid, I can parallelize it, but then must recover a continuous structure to use in the minimization. So I interpolate...
The other use is finding a minimum of a chi-square function. Again, the evaluation at each point in parameter space takes a long time, so I would like to parallelize the calculation, i.e. just scan over chi-squared values. Intermediate values can be interpolated, creating a continuous structure. Then I can feed the scan into a canned minimization routine.
Hello @mikevitz!
Maybe I can be of help with your second question. First of all, what operating system are you using? Assuming you are using some version of Debian (Ubuntu++), these are the steps to compile SPLINTER with an example program (tested with a fresh Ubuntu 14.04):
- Install git, cmake and build-essential (
sudo apt-get install git cmake build-essential
) - Clone the repository:
git clone https://github.com/bgrimstad/splinter.git
- Create a directory for building the library (in-source builds are not recommended):
mkdir splinter-build && cd splinter-build
- Run CMake:
cmake -DCMAKE_BUILD_TYPE=release ../splinter
(assuming SPLINTER was cloned to ../splinter relative to our current working directory) - Run the compiler:
make
(to speed up the process you can use the -j flag followed by an integer to indicate how many threads you want to use for compiling. A useful heuristic here is the same amount of threads your CPU can run concurrently). - After compiling, you can run
sudo make install
, which will copy the library binaries to/usr/local/lib/
and the headers to/usr/local/include/SPLINTER/
(the install locations may vary, but during the install the locations are output) - Create a file named main.cpp and fill it with the contents of the first example at https://github.com/bgrimstad/splinter/blob/69836dff75a7d35c69e54e5880ab272bb38570f6/docs/cpp_interface.md
- Compile the example program using
g++ -L/usr/local/lib/ --std=c++11 main.cpp -lsplinter-3-0 -I/usr/local/include/SPLINTER -o splinter-example
- You should now (hopefully) have an executable called splinter-example in your current directory.
I hope this was of use to you!
That seems to have got it exactly! I get a lot of warnings during compilation of the main.cpp to executable. They are all of the form
warning: ignoring attributes on template argument
or else deprecated declarations.
It seems to mostly be problems in Eigen. And they are warnings that can be turned off with the right flags. But I attach the warnings
warnings.txt
for completeness.
Many thanks for the help!