LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unconstrained Optimization VI

Solved!
Go to solution

Hello everyone, I have been practicing Unconstrained Optimization VI recently. I'm wondering if it can find the maximum value and F (maximum value).

0 Kudos
Message 1 of 10
(410 Views)

Unconstrained Optimization is a "minimization" algorithm, so it by default always looks for the smallest value, not largest.

 

But since you pass in your own function, you should just be able to either set your function to output either its reciprocal or inverse, and then it will essentially search in reverse.

Message 2 of 10
(359 Views)

Oh thank for your reply!

 

I think I understand what you mean.

If you can give me a simple example maybe I can understand it more clearly!

0 Kudos
Message 3 of 10
(320 Views)
Solution
Accepted by topic author boabao

Sure...

 

If you do a "create constant" on its "objective function" input, it shows you a reference to a VI with a certain connection pane:

 

Kyle97330_1-1749573280376.png

I then created that VI myself, and created a static reference to it.  I have a call to the VI here.  I chose "Downhill simplex" because it gave the best results, but for yours, check them all.

 

Kyle97330_0-1749573162863.png

This is that VI:

 

Kyle97330_2-1749573493140.png

Most details are unimportant.  It's an optical calculation designed to minimize area.  But you can see the function has an output directed at the f(x) indicator, and that's what the "Unconstrained Optimization VI" tries to make as small as possible.

 

If I had wanted to make it as large as possible instead, I could have just inserted a reciprocal function right at the very end:

 

Kyle97330_4-1749573771815.png

A "Negate" node to make it negative would likely work too.  

0 Kudos
Message 4 of 10
(301 Views)
Solution
Accepted by topic author boabao

Of course of the function is a paraboloid, there is exactly one minimum, but an infinite number of infinite maxima. 😄

0 Kudos
Message 5 of 10
(298 Views)

I understand your idea. After using your method, my function will indeed become infinite.

 

In addition, I have another problem. I would like to have my two variables perform from 0 to 100 and find the maximum F(X) and the best variable solution therein.

0 Kudos
Message 6 of 10
(278 Views)

You can just calculate your function in a grid, iterating over the two variables in a stack of two FOR loops.

Array max will give you the maximum array element (quantized to the 100x100 grid) and its indices. You can use the indices to get the corresponding value of the two input ramps.

 

I don't understand your term "best variable therein" Do you want to do a bounded search in the grid square around that max?

0 Kudos
Message 7 of 10
(274 Views)

Row 0 is variable A, and row 1 is variable B.

I hope that every item in A can be matched with every item in B and brought into my function.
Just like the following:

(A,B) = (1,0.1), (1,0.2), (1,0.3)...

boabao_2-1749587245249.png

So according to the above example, there will be 25 sets of answers.

 

I hope to find the maximum value F(X) among these 25 solutions, and what is the (A,B) of the solution?

 

 

0 Kudos
Message 8 of 10
(250 Views)

Hello, I would also like to ask you about the meaning of the value of the "start" input in Unconstrained Optimization.

boabao_0-1749621508431.png

 

0 Kudos
Message 9 of 10
(226 Views)

The attached file is my simple example. I hope to find the maximum solution, as well as the Q and a0 of the solution.

0 Kudos
Message 10 of 10
(216 Views)