gpufit / Gpufit

GPU-accelerated Levenberg-Marquardt curve fitting in CUDA
MIT License
309 stars 91 forks source link

gpufit_constrained missing in the documentation #80

Closed SebHam closed 3 years ago

SebHam commented 4 years ago

Hi,

I've started using GPUFit, and I wanted to have constraints on my parameters. In the code, this seems to be possible, as there is a function "gpufit_constrained" inside gpufit.h. But there is no mention of this in the documentation (https://gpufit.readthedocs.io/en/latest/index.html). How can we use that function, or is it still in development and therefore not in the documentation ?

superchromix commented 4 years ago

Hi,

Yes, the capability to do constrained fitting is there, but not yet documented. To use constraints, you need to use the gpufit_constrained interface, as you thought.

You need to provide two additional arrays. One array specifies the constraint type (None, Lower bound, Upper bound, Lower and Upper bound) and a second array specifies the bounds. The size of the first array is equal to n_parameters. The size of the second array (contraints) is equal to 2*n_parameters. For all constraint types, you provide two numbers in the contraints array. The format of the constraints array is : [parameter 1 lower bound, parameter 1 upper bound, parameter 2 lower bound, parameter 2 upper bound, ...]

SebHam commented 4 years ago

Okay, thanks for the quick response 😄

I am also correct to assume there is no constrained_cuda_interface ? To implement it myself, is it as easy as to copy gpufit_constrained, to paste it with another name and to change "HOST" to "DEVICE" in the FitInterface ? Or is there some expectation that the constraints are HOST variables ?

gpufit commented 4 years ago

The constraints are built into the main fitting engine, which all of the interfaces use. So, yes, they are there in the cuda interface.

jkfindeisen commented 3 years ago

The constrained fit is documented and available with examples in the Matlab, Python and CUDA interface in 0338846334f767f9783ac3b0d09ddeef67ed6370. It can be used