LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Downhill Simplex nD.vi

I have a single mode laser beam coming out of a fiber, collimated, and reflected back to the fiber.  The measured intensity of the reflected laser light is my function f(x) with bounded x,y,z stage positions as the function inputs.  By approaching any positions from high to low consistently (two steps forward and one step back for each stage), I can minimize stage hysteresis.  

 

I am looking for a hill climb vi that will move x, y, z stages simultaneously with good initial guesses and locate the maximum intensity.  I looked at Downhill Simplex nD.vi. I realized that I would have to write my own subvi to generate f(x) for any given x, y, z (negate measured intensity), search and replace all parsed f(x) in the Downhill Simplex nD.vi and its subsequent vis.  Has anyone already done this?  Downhill Simplex nD.vi doesn't have inputs for boundaries of the inputs for f(x) while the x,y,z stages have fixed ranges.

 

NI should have an example for users to provide their own f(x) from measurements instead of a functional expression written in string and parsed later everywhere.

 

I have Labivew Full 2012.

 

Thanks in advance for any inputs and suggestions.

 

Fang

0 Kudos
Message 1 of 7
(3,839 Views)

Fang,

 

Attached is a very simple example using downhill simplex to minimize a simple 3D quadratic function:

F(x,y,z)=(x-1)^2 + (y-1)^2 + (z-1)^2 + 3

 

This should get you started.

 

-Jim

Download All
0 Kudos
Message 2 of 7
(3,824 Views)

Hi Jim,

 

Thanks for the reply.

 

NI's Downhill Simplex nD.vi requires that a user must have a mathematical functional expression.  On the other hand, NI has Labiview to control experimental inputs and DAQ experimental output.  In this case, there are no explicit mathematical expressions to write in that string input, but a time consuming scans of all the input parameters show that there is an optimal value.

 

I am starting from ground to understand Downhill Simplex nD.vi and try to rewrite it to just use f(X(x1, x2, x3, ...)) to replace the parsed strings where x1, x2, xi... are experimentally controlled parameters and f(X) is the measured response.  I am afraid that I am reinventing the wheels as I suspect that many Labview users might have this need and some of them already implemented it in their works.

 

Regards.

 

Fang

0 Kudos
Message 3 of 7
(3,814 Views)

Fang,

 

The example implements the formula inside a VI (3D Quadratic function.vi)

model.png

 

 

A reference to this model VI is passed to the optimization VI. 

top level.png

 

 

You can replace the formula implementation with calls to your hardware, as I think you wish to do.  After indexing your three parameters (presumably x,y,z coordinates) simply pass them to your hardware, then read the output intensity and negate this value (to make the problem a minimization instead of a maximization). All this can happen inside the model VI. 

 

-Jim

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

fzhong,

 

If I am understanding your concern correctly, the code below should use the Downhill Simplex nD VI correctly with the equation you want:

 

VI.png

 

If you need the equation to be dynamic, you can always dynamically create the string and array of strings for the equation and variable names, respectively, and feed them into here as well. 

 

If this isn't what you are looking for and you still need some help, please post more details, and we will see what we can do for you.

 

Finally, if you feel that the API for this VI is not intuitive, and have ideas for how it can be improved, feel free to drop it off at our IdeaExchange at http://forums.ni.com/t5/LabVIEW-Idea-Exchange/idb-p/labviewideas. Our R&D department regularly implements features from the IdeaExchange, so you can trust that there are people looking at those ideas and considering them for a future release of LabVIEW.

David M.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 7
(3,799 Views)

Hi David,

 

What Jim showed is what I wanted for Downhill Simplex nD.vi.  Instead of passing a function in string to parse, it will be much more flexible to pass an objective function and user can either return a mathematical function value or a measured value for a given set of inputs.

 

I hope that someone already implemented this in a modified Downhill Simplex nD.vi.

 

Regards.

 

Fang

0 Kudos
Message 6 of 7
(3,765 Views)

Fang,

 

What you want is implemented, and has been for several LabVIEW releases.  Please open the VIs from my first post.  Their diagrams are what I showed on my second post.  If you have problems opening these VIs because of your LabVIEW version please post a request for a copy of these example VIs for your version of LabVIEW.

 

-Jim

0 Kudos
Message 7 of 7
(3,759 Views)