LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling vi from formula node

Hi all,

is it possible to call a (sub)-vi from the formula node?
Motivation:
I would like to minimize a pretty complicated function that I have already coded in G.
I thought about using the "Conjugate Gradient nD.vi" which should be well suited for this problem. Unfortunately the vi needs a formula-string as input. My (already coded) function is full of matrix operations with complex numbers and I can't easily re-write it in the formula-string-style 😞
So it would be a great benfit if I could call my sub-vi from the formula-string.
Are there any other solutions than calling Matlab (which I don't have availible) from LabView?

Have a nice day,

Toni
0 Kudos
Message 1 of 26
(4,364 Views)
I do not think you can do that. Could you split your formula node into two parts (two nodes) and put your subVI between them? That would give you most of the advantages of each approach with only a slight increase in complexity.

Lynn
0 Kudos
Message 2 of 26
(4,351 Views)
Hi Lynn,

thank you for your answer. I am sorry, my description of the problem was mistakable.
I attached a picture to better illustrate my problem. In the upper half the "Conjugate Gradient nD.vi" is used as described in the examples that ship with LabView and works just fine.
In the lower half of the picture I outlined what I would like to realize. Basically I want to do a curve fitting of a model to measurement values. So I would start a simulation with a rough guess of the variables which are fed into the simulation vi. After calculating the response of the model, the measured values care compared with the simulated ones and a cost function is caluclated. This cost function should be minimized by the "Conjugate Gradient nD.vi". The minimum output is fed into the simulatin vi again and after a few iterations the simulated values hopefully fit the measured values.
I cannot use the curve-fit vis that ship with LabView because I need a specialized model that I have to fit.
0 Kudos
Message 3 of 26
(4,335 Views)
0 Kudos
Message 4 of 26
(4,330 Views)
Toni,

I now have a clearer idea of what you are trying to do. Unfortunately, I do not see approach other than trying to implement you own version of the Conjugate Gradient VI for the equations of your model and complex variables.

Lynn
0 Kudos
Message 5 of 26
(4,322 Views)
Toni,

I am having a similar problem, essentially all of the optimization vi's are written for objective functions that are analytical. I am also fitting measured data, and thus have a non-analytical problem. I am actaully writing a simple but fast optimization routine based ona a pattern search optimization algorithm I wrote in MATLAB. I can send it to you and you can replace the function with your own when its done. If you already have a soltion to this then I would love to hear what you did.

- Nate
0 Kudos
Message 6 of 26
(4,273 Views)
I finished the Pattern Search vi and am attaching them here. Edit/Replace the FEfunction vi with a function that computes the error in the fit and this algorithm will quickly find the best fit (assuming there are no constraints). For more info see:

http://www.srl.gatech.edu/Members/nrolander/Class_Projects/Homework3.pdf

Hope this helps, if you have any questions e-mail me.

- Nate
Message 7 of 26
(4,264 Views)
Hi Nate,
thanks a lot for your answer, I'm still working on a solution and will test your vi.

Toni
0 Kudos
Message 8 of 26
(4,253 Views)
Toni,

I realized I did not set the default values in the VI before I posted it. The f(x) sub VI I have in it is a function of 2 variables, so use the following values for the Pattern Search front panel controls:

Max Ittr = 100
Min s = 0.001
s = 1
x0 = [ 5 10 ]

The f(x) subVI is used several places in both "Pattern Search" and "Explore", so when you replace it with your error calculation VI (it just needs to return the error in fit value at that point) be sure to get them all. I would be intersted to see this fit calculation to see how you are measuring this fit error, particularly if it changes with time.

- Nate

Message Edited by S Nate dx on 03-10-2005 09:26 AM

0 Kudos
Message 9 of 26
(4,246 Views)
Nate,
no problem, I started with different values 🙂
0 Kudos
Message 10 of 26
(4,241 Views)