Jump to content

LM fit taking too long


Recommended Posts

I must fit some nonlinear data.

I am using LM with a Vi reference. The model inside the reference must be dynamic, so the user can modify it at runtime. I have figured out a way of evaluating an experssion passed through the data (variant) node from the main Vi. I am passing through the data node the expression of the function in a string variable and an array of string parameters.

Although the fit is very good, it is taking too long: 45-58 seconds for a 2-parameter function.

Did anybody encountered this problem?

(Using LV 8.0 on a Athlon XP 2500+ machine.)

Link to comment

QUOTE (Pollux @ Mar 25 2008, 05:19 PM)

I must fit some nonlinear data.

I am using LM with a Vi reference. The model inside the reference must be dynamic, so the user can modify it at runtime. I have figured out a way of evaluating an experssion passed through the data (variant) node from the main Vi. I am passing through the data node the expression of the function in a string variable and an array of string parameters.

Although the fit is very good, it is taking too long: 45-58 seconds for a 2-parameter function.

Did anybody encountered this problem?

(Using LV 8.0 on a Athlon XP 2500+ machine.)

It's a common problem if you are entering a text-based model. It's not the most efficient way, even though it is very flexible.

You COULD write some hard-coded model VIs which can be switched at run-time by passing a different reference to the LM function. This requires that a change in the model recorrelates to creating a new VI for that model. You can then optimise the code within the respective VI.

The gains in speed by using a hard-coded model versus an interpreted one must be weighed against the flexibility enjoyed by the string method.

I had the situation once where I started doing multi gauss fits via text-based LM (LabVIEW 6.1) and the fits were taking something like 20 or 30 minutes to complete. After switching to a hard-coded model (And making a few optimisations) I got the fitting time down to something like 5 seconds. Without my extra optimisations (in the LM module itself) I was timing it at about 30 seconds. Even that is a 60-fold increase in speed.

If you NEED the flexibility of a string model, you will always be slower than a hard-coded model.

How are you interpreting / entering the model string?

Shane.

Link to comment

QUOTE (shoneill @ Mar 26 2008, 10:04 AM)

It's a common problem if you are entering a text-based model. It's not the most efficient way, even though it is very flexible.

You COULD write some hard-coded model VIs which can be switched at run-time by passing a different reference to the LM function. This requires that a change in the model recorrelates to creating a new VI for that model. You can then optimise the code within the respective VI.

The gains in speed by using a hard-coded model versus an interpreted one must be weighed against the flexibility enjoyed by the string method.

I had the situation once where I started doing multi gauss fits via text-based LM (LabVIEW 6.1) and the fits were taking something like 20 or 30 minutes to complete. After switching to a hard-coded model (And making a few optimisations) I got the fitting time down to something like 5 seconds. Without my extra optimisations (in the LM module itself) I was timing it at about 30 seconds. Even that is a 60-fold increase in speed.

If you NEED the flexibility of a string model, you will always be slower than a hard-coded model.

How are you interpreting / entering the model string?

Shane.

Thank you for your answer.

I don't mind being slower, but not that slow... :D

I am using some VIs from Mathematics/Scripts and formulas/1D&2D Evaluation.

Acctualy, my model subvi was porely coded. I had lots of for structers wich where not necessary.

Today i have recoded the whole thing so I reduced the time from 45 seconds to 0.5 seconds/fit. (That is 10-15ms/iteration.) That's a satisfying result.

I think that I can do bether if I use the "eval multivariable array" vi. Frydai I will put it to the test.

If you are interested to see the thing I can send it to you.

Link to comment

QUOTE (Pollux @ Mar 26 2008, 06:34 PM)

Thank you for your answer.

I don't mind being slower, but not that slow... :D

I am using some VIs from Mathematics/Scripts and formulas/1D&2D Evaluation.

Acctualy, my model subvi was porely coded. I had lots of for structers wich where not necessary.

Today i have recoded the whole thing so I reduced the time from 45 seconds to 0.5 seconds/fit. (That is 10-15ms/iteration.) That's a satisfying result.

I think that I can do bether if I use the "eval multivariable array" vi. Frydai I will put it to the test.

If you are interested to see the thing I can send it to you.

Sounds like you have a workable solution. My problem back then with LM involved up to 17 Gauss peaks with 3 coefficients each. That makes a 51x51 matrix for reduction within the LM model. The effort required to solve the model increases rapidly with increasing number of coefficients......

I'm familiar with the formula approach to things. This is how the 6.1 version used to work before the reference-based version was implemented. Thanks for the offer though. Good luck with the rest of your work,

La revedere,

Shane.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.