07-28-2025 01:50 AM
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!
07-28-2025 01:46 PM
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.
07-28-2025 01:55 PM - edited 07-28-2025 01:56 PM
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)