LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Minima of function with controls as coefficients

I want to minimize a function with coeffecients that are driven by front panel controls.  Right now all the optimization VIs I can find have strings as formulas, so the coeffecients are fixed.
 
My specific application is modeling a heat exchanger.  I have three simultaneous equations and three unknowns (heat, T coolant out, T process out).  I can write a single equation that when minimized will solve for these three variables.  But if I want to change coolant flow rate as part of the simulation, I have to modify the coefficients in the string formula.  I can build the formula with the proper coefficients everytime, but that seems pretty awkward.  Is there another way?
 
(I did try the Find All Minima nD.  I thought if I made the coefficients variables themselves and set the start and end values to be equal, I could fix the coefficient but drive it with a control.  However, it seems that the start and end values are only initial values for the iterations.  I put in x^2+y^2, and set all the start and end values at 5, but the minimum was still 0.)
 
It's really easy in Excel Solver 😉
0 Kudos
Message 1 of 8
(2,973 Views)

Hi SCohen,

You can use convert the output from numeric controls into strings using the Number to Decimal String, and then concatenate them together using Concatenate Strings.  Is this what you're looking for?

Regards,

James R.
National Instruments
0 Kudos
Message 2 of 8
(2,947 Views)

James,

Yes, that is the awkward workaround,  I was hoping there was something more elegant. 

For example, if I make a subVI with three inputs and an output, is there some structure that will vary the inputs to drive the output to a specified value?  It could use algorithms similar to those in the available optimization VIs, but instead of varying formula inputs and reading formula outputs, it varies subVI inputs and reads subVI outputs.

Have you heard of anything like that?  It seems like it would be very useful.

Thanks,

Steve

0 Kudos
Message 3 of 8
(2,938 Views)
What version of LabVIEW are you using?  In LabVIEW 8.0 and later there is a VI called "Unconstrained Optimization.vi" that allows you to use either a string to model your problem, or to use a VI reference.

-Jim
0 Kudos
Message 4 of 8
(2,932 Views)

I'm using LabVIEW 7, but I looked up the VI you mentioned here.  From the description, it seems like the objective function is limited to a quadratic.  Is that correct? Or can I put any function into the VI?

Thanks,

Steve

0 Kudos
Message 5 of 8
(2,920 Views)
Yes, that is the VI, and you can input any model function, not just quadratic forms.  Please keep in mind the usual caveats with these algorithms:  namely that they make no guarantees of finding the global optimum.  If your function is continuous and smooth then Quasi-Newton or Conjugate-Gradient is a good choice.  If these two fail then try the Downhill Simplex algorithm (aka Nelder-Mead simplex).  Also added in LabVIEW 8 is a Constrained Nonlinear Optimization.vi that implements a SQP algorithm that allows general nonlinear equality and inequality contstraints, and a much improved Levenberg-Marquardt implementation that accepts a VI reference as the model function.  ODE solvers were also upgraded to utilize the same sort of VI interface.
Apologies for the sales pitch 🙂

-Jim
0 Kudos
Message 6 of 8
(2,913 Views)

Well, that looks like it's just what I need.  I don't mind the sales pitch, I'm just not sure I need it $1200 worth for an upgrade. 🙂

I may try to write a simple (but inefficient) VI to run through the design space and find the minimum.

Thanks,

Steve

0 Kudos
Message 7 of 8
(2,906 Views)

I found what I was looking for here.

You just need to substitute your VI for the FE VI in S Nate dx's Pattern Search. (You need to go another level down to the Explore.vi also) Since I wanted to have modifiable constants and don't completely understand VI references, I just used the earlier version on the previous page of that thread.  It works fine.  You may also look at altenbach's solution here.

0 Kudos
Message 8 of 8
(2,888 Views)