LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unconstraned Optimization

Hi,

 

Can anybody tell me a starting point to know how to develop vis using Constrained Optimization. And will 124MHz processor on Ni sbRIO 9631 support it?

 

The links I am getting discuss examples that I am unable to understand and I am looking for something really basic so that I know what's happening with Constrained Optimization. Please do let me know if there are any good tutorials out there that I somehow missed.

 

Thanks in advance!!

0 Kudos
Message 1 of 15
(5,151 Views)

Hi Robot,

 

We have a help file. that talks about constrained nonlinear optimization. If you look at the bottom of that help document, you will see the location of an example. This location is labview\examples\math\curvefit.llb and called Estimate Nonlinear Spring Constant VI. This could be a good starting point for this optimization in LabVIEW.

 

If you're looking for more specific informatoin about what constrained optimization is, this link explains it in a more mathematical way, and this link is the wikipedia page for it. 

 

Hope this helps!

Lea D.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 15
(5,117 Views)

Hi Lea,

 

Thanks a lot for your reply. I went through that example but am unable to understand what's going on. Is there a much simpler example? I actually understand what unconstrained and constrained optimizations are. I wote a program that performas this in MATLAB using fmincon(). I am trying to replicate the same program in LabVIEW so that I can get that on to NI-sbRIO 9631 hardware which is required for me to get some things done in my project.

 

Is there a simpler example so that I know what to do where in the constrained optimization vi? If that is difficult is there a way to get the m file to tranform to a vi using RT module etc?

 

Thanks!!

0 Kudos
Message 3 of 15
(5,109 Views)

Hi Robot, 

 

You are the second person I have noticed with this question in the past few months. The advanced math libraries use a fundamentally different method of calling functions than the rest of labview. Essentially you give the optimization VI a VI that implements your function and some information about bounds. The optimization VI then repeatedly calls that VI to find a minimum. This paradigm makes sense when you realize the optimization VI just calls the VI repeatedly and knows nothing about the actual mathematical structure of it. If you just start from the template VI (the path is in the help) and make a simple function it is might be easier than decoding the labview example. 

 

Altenbach started a tutorial on a similar topic (here) and I had an exchange with navmeet about this a few weeks ago, but the tutorial hasn't gotten to the point of examples yet. 

 

What are you trying to do with this?  

Jesse Dennis
Engineer
INTP
0 Kudos
Message 4 of 15
(5,095 Views)

There is also a suggestion in the Idea Exchange to improve access to the templates for these VIs.

 

Lynn

0 Kudos
Message 5 of 15
(5,081 Views)

I am sorry I just now notices that the thread is named Unconstrained Optimization and I am having trouble with Constrained Optimization...I changed it in the reply subject now!!

 

This is for implementing phased array antennas.

 

I am trying to minimize a function (Noise to Signal Ratio) subject to constraints on weights that is absolute value of weights=1.

 

Signal to noise ratio is calculated using the idea that if we want a main beam at a desired direction say 30deg then the steering vector for that direction can be found and so signal gain becomes 10log(w'*a(30deg)), where w are the weights. The gain in the remaining directions is taken as the noise gain.

 

In fmincon(), it takes a function reference as its first parameter just as Constrained Optimization takes a vi where we implement our function (in this case NSR). 

 

In the objective and constraint function input it asks us to use the template located in labview\vi.lib\gmath\NumericalOptimization\cno_objective function template.vit

 

If the add that vi to my block diagram it gives me multiple outputs and takes in multiple inputs but how can I connect the same to my Constrained Optimization vi that takes a vi as an input, in otherwords am I missing something like function reference in MATLAB here??

 

Please give me a small example like minimizing the norm of Ax-b constrained to |x|==1 with starting point x=[0,0,0,0] and then I think I can follow what's happening so that I can then write my own code to achieve my objective. 

0 Kudos
Message 6 of 15
(5,076 Views)

Hello Robot77,

 

To make a quick example, you can start with the function template located here: labview\vi.lib\gmath\NumericalOptimization\cno_objective function template.vit, as pointed out by Jesse. Then you would use this function as your objective and constraint function when calling the Constrained Nonlinear Optimization VI. 

 

Another method would just be to use MathScript RT and use the fmincon in the same way you used it on your .m file. Here's the NI function help for reference:

http://zone.ni.com/reference/en-XX/help/371361E-01/lvtextmath/msfunc_fmincon/

 

Also, here are some options for working with MATLAB and LabVIEW: http://www.ni.com/analysis/matlab.htm

 

I hope this helps

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 7 of 15
(5,023 Views)

Hi Robot, 

 

Here is a small example. My only reservation with using fmin_nonlincon in the RT module might be speed, which is just something you would have to check. If it is fast enough for you though it might be as simple as adding one line of code to a mathscript module and re-using your old matlab code. You also will want to be careful with your starting conditions. The LV optimization algorithms are just numerical and can fail to converge under the wrong conditions. 

 

 

Jesse Dennis
Engineer
INTP
Message 8 of 15
(5,006 Views)

Hi Jesse_D,

 

Thanks a lot for your reply and the attachment but unfortunately I am using LabVIEW 2010 and since you saved it as 2011 I am unable to open the same here. Can you please save it as LabVIEW 2010 compatible and attach the files again.

 

I dropped the idea of using RT Module as I need to have MATLAB and the vi that I develop at the end will eventually go onto sbRIO-9631 which has only LabVIEW platform on it and no MATLAB.  I will learn to use unconstrained optimization vi and see if I can model my objective function in LabVIEW.

 

Thanks again for your help!

0 Kudos
Message 9 of 15
(4,992 Views)

Oops, my bad, 

 

It should be in 2009 now. There also is an downconvert thread if you ever get in a pinch. 

 

Take a look at it and let me know if it is what you are looking for. I would love to help you get this project going, let me know how things progress. 

 

 

Jesse Dennis
Engineer
INTP
Message 10 of 15
(4,984 Views)