LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare mixed-data clusters that include some floats

Solved!
Go to solution

Has anyone come up with what they consider to be a slick way to compare mixed-data (including floats) clusters for functional (close enough) equality? All I've manged to come up with are specific-to-the-cluster VIs that use a while loop with a internal index-driven case statement to step through the clusters element by element to make the comparisons, using an appropriate method for comparing the floats that will accept a tolerance.  I thought perhaps that someone may have already built a more generic solution built on converting the clusters to variant data and then steering each data element to a correct comparison for its data type.

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

Well, you can use the "Close-enough" methods in the note you cite, just expand to fit your cluster.  I'm assuming the Cluster is all numeric (you can certainly compare a really-mixed Cluster with strings, booleans, and numerics, but then my method would fail).

 

I'm using the "less than an absolute threshold" method for illustration.  The one "catch" is you need to create the "base cluster" more-or-less by hand, though you can set all of the threshold values the same, as shown here:

Compare Clusters.png

Bob Schor

0 Kudos
Message 2 of 8
(4,588 Views)

Thanks Bob but my clusters generally fall into the "really mixed" category.  The current one I'm working with has a string plus an array-of-cluster at the upper level with the array's cluster elements consisting of DBLs, various-sized INTs, a couple of ENUMs and a string.  Using some pieces from the AutoTestWare toolkit I have spent the morning cobbling together something that seems to be working for the few clusters I've thrown at it. At the moment I'm trying to figure out what to do with some of the more left-field variant data types that can be produced.

0 Kudos
Message 3 of 8
(4,580 Views)

Unfortunately, there is no catch all method for doing a functional equals method.

If you see the method that works the best for you, you could create subVIs that meet your needs, and that would decrease your work in the long run for each mixed cluster that you have.

 

If you find that the cluster doesn't require any functional equals, then you can compare the entire cluster to get a cluster of booleans for each value. But as far as I can see, you are on the right track of creating a loop to iterate through each one. 

 

What 'left-field' data types are you running into?

0 Kudos
Message 4 of 8
(4,532 Views)

What 'left-field' data types are you running into?

These are what stand out so far. I don't think I'm missing much by ignoring them. They vary by LabVIEW version as the later versions pick up more esoteric datatypes. I think I have the other cases handled well enough but no guarantees as I have not tested them all.

 

v8.0:

Clipboard01.jpg

 

v2014:

Clipboard02.jpg

 

I've attached the 8.0 & 2014 versions of the VI to this post in case it might prove useful for anyone else. The paint's not dry on it yet but it does work with the few clusters, arrays and simple values which I've thrown at it.  The attached code, rather than using the AutoTestWare toolkit mentioned before, instead is built on (what I think to be) the more generally used OpenG toolkit and you will need to have that installed to be able to use the VI.

Message 5 of 8
(4,517 Views)

I believe that you are on the right track with this. Because of the complicated and specific nature, there isn't much out there to compare clusters to be functionally close in a 'slick' manner.

 

This may be something really good to upload as a community example when you are finished, though!

0 Kudos
Message 6 of 8
(4,483 Views)