LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formula parser

Hi!
I've got the following problem:
I'm trying to write a routine to fit my experimental data with theoretical function and to determine the parameter in this formula. Thus, I have
X array
Y array
and formula f(x,T) (written as string).
I wanted to apply Levenberg Marquardt.vi, which is supposed to do this job. But...
The point is that f(x,T) is huge (summation of the many terms) and I wrote a separate subroutine to generate this string. So, it takes about 10 minutes to complete the task. I looked through the Levenberg Marquardt.vi and found out that the bottle neck is Parse Formula String.vi. Actually, in order to verify my formula I substituted T by some value (say 600) and applied Eval Single-Variable Array.vi. It took ~ the same to draw the picture, but after ~10 minutes I got a desired graph. I can make the only conclusion that the program runs correctly but parser works EXTREMELY slow.
The question is:
Is there any way to improve the situation with parser?
Why does it work so slow?
Thanks in advance!
Sergey.
 
0 Kudos
Message 1 of 7
(4,204 Views)
We've just been talking about the same thing (http://forums.ni.com/ni/board/message?board.id=170&message.id=185522)  though by the sounds of your post, you are working with a <V8.0 copy of Labview. The problem is the same. As I recently became aware, the formula string parser is very expensive. The solution to this with version 8 is to write a separate VI to calculate the function to be fit. With previous versions of Labview, however, I did not work with the Levenberg-Marquardt fitting routines so I can't say if there is similar functionality. If there is, then certainly go that route and make a separate subVI to calculate your parameters and feed that reference to the LM vi. Aside from that, what is the parser connected to? The parser digests the formula string and outputs a cluster with two arrays I believe. If you can replicate its output, you can manually parse the formula and create the necessary arrays yourself, allowing you to bypass the parser. This should eliminate the overhead associated with that function, but would only work if your equation is not changing dynamically. As to why its so slow in the first place, dunno, I would think it shouldn't be..

Brian.
Message 2 of 7
(4,198 Views)

Thanks for reply!

Unfortunately, I use 6.1 version of LabVIEW.  So, I'm not familiar with this VI interface concept (I didn't catch how it works without parsing).

I wonder whether C or Matlab parsers work in the same manner.  Another words, if I use CIN or Matlab to parse my formula for LM routine will it work faster? Actually my formula models rotational Raman spectrum. I posted text file with the formula. If You could test it with another parser it would be interesting! Anyway I started writing my own fitting procedure. It will evaluate this formula without converting it into string (for some specified T and array of X), and then I'll try several T to minimize mde. So I'll avoid parsing! Hopefully it will work.

Sergey. 

0 Kudos
Message 3 of 7
(4,197 Views)

Thanks for asking the questions, but I would recommend that you move any comments or questions to the above forum listed. You will find better help there. Thanks.

Tyler H.

National Instruments

0 Kudos
Message 4 of 7
(4,178 Views)
?
0 Kudos
Message 5 of 7
(4,170 Views)
Sergey,

there are two varieties of Levenberg-Marquardt VI. You tried Levenberg-Marquardt.vi which uses formula parsing for function evaluation. However the other is Nonlinear Lev-Mar Fit.vi and it uses a target VI for function evaluation. To input your function, edit the VI Target Fnc & Deriv NonLin.vi that is called from the Nonlinear Lev-Mar Fit.vi. You can input your text formula in the formula node there and then it will be much faster since the formula node is compiled, not parsed.

Message Edité par JeanPierre le 05-20-2006 09:08 PM



LabVIEW, C'est LabVIEW

Message 6 of 7
(4,159 Views)
JeanPierre,
Thank You very much! I'll try to do it. Actually, I've already written my own fitting subroutine. This subVI also compiles formula, but not parses. It takes ~8 seconds to make fitting with one parameter (also depends on accuracy) and ~ 1 minute for two parameters.  8 seconds is definitely better than 8 minutesSmiley Happy!  
Sergey. 
0 Kudos
Message 7 of 7
(4,152 Views)