Skip to content

Instantly share code, notes, and snippets.

@NickCarneiro
Created November 25, 2011 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickCarneiro/1392614 to your computer and use it in GitHub Desktop.
Save NickCarneiro/1392614 to your computer and use it in GitHub Desktop.
float minDot = Float.MAX_VALUE;
//apply logic from above else loop here also
for (PointWithRSSI p : compare) {
float currDot = 0;
Set<String> c = p.getAccessPoints().keySet();
for (String s: keys) {
if (c.contains(s)) {
currDot += p.getAccessPoints().get(s)*p.getAccessPoints().get(s) ;
currDot -= (Math.abs(temp.getCurrentPoint().getWeightedaccessPoints().get(s).getRssi()) * Math.abs(p.getAccessPoints().get(s))); //add to the dot product
}
else { //the penalty for non-containment
currDot += (temp.getCurrentPoint().getWeightedaccessPoints().get(s).getRssi()*temp.getCurrentPoint().getWeightedaccessPoints().get(s).getRssi());
}
}
currDot = Math.abs(currDot);
if (currDot < minDot) {
minDot = currDot;
minPoint = p;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment