LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic constants for optimization problems

Hi, I have a question about how to use LabVIEW's built-in nonlinear optimization VIs. 

 

I'm using one of the VIs that accepts a VI reference for the objective function, because my objective function is too complex to define in a single string. However, I'd like my objective function to have fixed constants, that are determined at runtime, not at the time when the objective function VI is being programmed. 

 

As a very simple example, let's say I want to minimize the function f(x) = (x-k)^2 using the Quasi Newton VI, but the user can type in the value of k during runtime. 

 

What is the easiest way to do this in LabVIEW? I only know how to pass a VI reference into the Quasi Newton VI, for example, but I'm not sure how to get this VI reference to have additional constants. 

 

Thanks! 

0 Kudos
Message 1 of 3
(261 Views)

You can create a cluster with all your "constants" and convert to a variant and wire it to the "data" input. Inside the model convert the variant back to a cluster and unbundle whatever you need.

0 Kudos
Message 2 of 3
(220 Views)

Here's a quick draft. You should make the cluster a typedef, of course. (note that the "to variant" on the left is not really needed, it will coerce the cluster anyway)

 

altenbach_0-1753728898635.png

 

0 Kudos
Message 3 of 3
(217 Views)