LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

2D maximum in advanced analysis library

Hello, hello,

Say I have a function f(a,b). I'm looking for the 2 values of a and b within a certain range that will give the highest value for f.

I looked through the Advanced Analysis Library without finding anything (but sometimes the names aren't obvious). Any idea ?

Thanks

0 Kudos
Message 1 of 8
(2,066 Views)

Well, this is a simple 2D optimization problem (independent of programming language) and it really depends how the f(a,b) surface looks like. Is it a simple smooth surface? Is it highly convoluted with many local maxima? Are a,b integers or floating point values?

 

0 Kudos
Message 2 of 8
(2,049 Views)

Why doesn't MaxMin2D work for you?

 

Well, of course, you need to evaluate it for a range of values first, and that may cause some issues as Altenbach suggested, but what other option do we have until the Wolfram symbolic solver is implemented into CVI 🙂

S. Eren BALCI
IMESTEK
0 Kudos
Message 3 of 8
(1,987 Views)

@ebalci: it's a function, not an array.


@altenbach: yes, it's a highly convoluted function, with discontinuities, so non derivable. I've tried 2 methods so far:

- Limited memory BFGS with a fake derivatives Df/Da=(f(a+D, b)-f(a,b))/D and Df/Db=(f(a, b+D)-f(a,b))/D but it fails immediately to converge.

- Nelder-Mead, it kinda works but converges to a wrong solution.


I'm gonna do some 2D or 3D plotting of my function to try and understand why, unless someone has other methods I can try.

 

0 Kudos
Message 4 of 8
(1,965 Views)

The function also returns the indices that give the max/min value.

 

Isn't that enough? Or maybe I couldn't understand your question.

S. Eren BALCI
IMESTEK
0 Kudos
Message 5 of 8
(1,954 Views)

@ebalci wrote:

The function also returns the indices that give the max/min value.


Quantized to the chosen grid and the real solution could be completely elsewhere! 😄

 

For better accuracy, the NxM grid needs to be very fine. Your solution is also of O(N²) complexity and can get very expensive.

 

If the OP would attach the formula of the function and the the bounds for a and b, I could take a stab at it. 😄

0 Kudos
Message 6 of 8
(1,940 Views)

Indeed, the function is very CPU intensive, so it's important to minimize the number of calls. I can't give the function because it is itself a Linear fit between a large dataset and a set of theoretical points. Only 2 parameters control this matching, hence the 2D function I want to minimize.

0 Kudos
Message 7 of 8
(1,915 Views)

I've done some 2D and 3D plots of my function and it's pretty obvious that there are edge cases that are divergent, so I need to work on a better definition for now... Or even the best methods will be useless !

 

Anyway I've found a whole bunch of methods: Nelder-Mead, Powell, CG, BFGS, L-BFGS-B, Newton-CG, TNC, COBYLA, SLSQP, trust-constr, brute force, simulated/dual annealing... I'm just surprised not to see any in the Advanced Analysis Lib.

0 Kudos
Message 8 of 8
(1,897 Views)