LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to optimize matrix

My program begins with several 2D input arrays.
Some calculations are performed (matrix addittion multiplication etc.). 
The final output is a single value.
The matrix calculations involve several "parameters" that must be varied to make the output a minimum.
 
I have seen "Tst Downhill Simplex Fit.vi"  and the n variables are just a, b etc.
 
In my situation, changing the parameters results in changing the contents of the matrixes and thus the f(x) function.
The downhill simplex won't work as successive iterations would need different f(x) inputs to the VI.
 
What I really need to do is perform some external calculation (even another VI) then input this into the minimizing function at each iteration.
 
It is fairly simple in excel using "solver" as seperate cells related by a function f(x) will be updated when searching for a minima each time.
 
Is there a VI for this type of calculation.
Download All
0 Kudos
Message 1 of 6
(3,445 Views)
Well, if your model function can calculate these matrices as a function of the adjustable parameters, you're all set. It's just part of the model! I don't quite understand why you think there is a problem.
 
You could even use plain Levenberg Marquardt (Nonlinear fit, VI model) with x unwired and y being an array with a single element of zero. Your function calculates the sum of variances that will be brought as close to zero (your Y data!) as possible.
 
What you absolutely need to do is fix your VI, because it has race conditions. For example Jz must be an indicator, because it is determined exclusively by Zs. You also MUST eliminate the local variables because your code cannot guarantee that they are written in one place before being read at the second place (except for the displacement calc local variable where you force execution order via the sequence structure).
 
I am pretty sure the code is incorrect, but I don't have enough information to see what needs to be changed. I think some of the matrix dimensions are mismatched. Notice also the way to built the 2D arrays, you are doing it way too complicated. Attached is a quick draft how you could cleanup your code (no functional change except for  the missing race condition). 🙂
 
Do you have some more fundamental information of the problem. What is is all about? 🙂
0 Kudos
Message 2 of 6
(3,430 Views)
The experiment is to measure the curvature of a thin film as it is deposited onto the substrate.  An array of dots is reflected off the surface of the film.  The locations are compared to a reference image ( at the beginning of deposition ) and the change in displacement is measured.  Theoretical and practical results are compared.  The various parameters of the theoretical model must be adjusted so that there is a minimum error between theory and measured.  This will give the curvature.

Whilst it is probably possible to enter the function as a string - my current problem is that the equations use trigonometric functions.  I do not think downhill simplex can accommodate for these - would I have to convert these into a power series expansion (i.e. for sin, cos etc.)
0 Kudos
Message 3 of 6
(3,370 Views)


@sammy346 wrote:
Whilst it is probably possible to enter the function as a string - my current problem is that the equations use trigonometric functions.  I do not think downhill simplex can accommodate for these - would I have to convert these into a power series expansion (i.e. for sin, cos etc.)

Why???
0 Kudos
Message 4 of 6
(3,361 Views)
Basically I will rephrase my question:
How can I enter cos, sin functions into the input string f(x)  - in the downhill simplex VI ???
0 Kudos
Message 5 of 6
(3,347 Views)
Hi Sammy346,
 
You should be able to create a constant and type in the equation including your trigonometric functions.  If you are having problems with this, please post a simple VI that demonstrates the problem.
0 Kudos
Message 6 of 6
(3,331 Views)