LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview's Constrained Nonlinear Optimization VI and Matlab's fmincon function

Dear Community Members,

 

I sometimes encounter different results with Matlab's fmincon function and Labview's constrained nonlinear optimization vi. Objective functions, bounds and constraints are checked numerous times and they are all same in both programs. 

 

In Matlab, I get the same minimum output for different starting points of the optimization problem. However, the minimum changes with respect to different starting points in Labview. 

 

I run the algorithms in both programs step by step to see the difference. Hence, I observed that Matlab does more iterations with less function calls. Contrarily, Labview does less iterations with more function calls. This made me think of difference of tolerance setups (ie. function and parameter tolerance etc) but they have different names for both programs For that reason, I could not totally match the parameters to set up at the same way. As a reference you can check support documents for both algorithms from the links below. 

 

https://zone.ni.com/reference/en-XX/help/371361R-01/gmath/constrained_nonlinear_optimization/

https://www.mathworks.com/help/optim/ug/fmincon.html#busog7r-options

 

Maybe the difference is something else, I am not sure about my above statement about tolerance setup. If there is anybody who can help me to setup the functions at the same way to get same results all the time from both program's functions, I look forward to get some help. 

 

Best, 

Sertan 

0 Kudos
Message 1 of 4
(1,266 Views)

Hi Sertan,

You're going to need to post a matlab cmd, what you think the equivalent LabVIEW VI looks like (VI upload for the community to see) is and the dataset it's being run on for anyone to even be able to consider commenting. all you've done is say you've got a problem and link the help files.

without seeing how you're setting things up no one can help.

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 2 of 4
(1,234 Views)

Hi James,

 

Thanks for your response, you are totally right! Here are my setups for the both algorithms. 

 

In Matlab, I have one main function and an objective function. As you can observe, main function calls the objective function and makes optimization related to my setup. 

 

In Labview, I have two different VI's that work in totally same manner line Matlab. "nonlinear_main.vi" works as a main function to do optimization and "objective_function.vi" has a basic quadratic cost function setup. 

 

To observe the problem that I explained in my first post, you just need to change the initial guess of inputs from x = [1 1 0]' to x = [1 1 0.1]'. When you do this, you can see that in Matlab the optimization output does not change. However, the output changes in Labview. 

 

I hope anybody will help me with this problem! If you need anymore info please let me know. 

 

Best,

Sertan 

Download All
0 Kudos
Message 3 of 4
(1,202 Views)

Additionally, here are the screenshots of the setups and results, if it is more convenient for you to analyze.

 

0 Kudos
Message 4 of 4
(1,183 Views)