LMS fertig
This commit is contained in:
parent
b37b4564a5
commit
9055177bab
|
@ -66,6 +66,7 @@ public class LeastMedianOfSquaresEstimator extends Algorithm {
|
||||||
slabs = new PriorityQueue<>(comparator);
|
slabs = new PriorityQueue<>(comparator);
|
||||||
slabs.add(new Slab(-100000, 100000));
|
slabs.add(new Slab(-100000, 100000));
|
||||||
heightsigmaMin = Double.MAX_VALUE;
|
heightsigmaMin = Double.MAX_VALUE;
|
||||||
|
LinkedList<Point> tmpIntersections = intersections;
|
||||||
|
|
||||||
//(3.) Apply the following steps as long as the exists active slabs
|
//(3.) Apply the following steps as long as the exists active slabs
|
||||||
boolean active = true;
|
boolean active = true;
|
||||||
|
@ -82,19 +83,32 @@ public class LeastMedianOfSquaresEstimator extends Algorithm {
|
||||||
sigmaMin = planeSweep(slab);
|
sigmaMin = planeSweep(slab);
|
||||||
} else {//(c.) otherwise....
|
} else {//(c.) otherwise....
|
||||||
//get random intersections point...
|
//get random intersections point...
|
||||||
splitActiveSlab(intersectionsPoint, slab);
|
Double randomIntersection = null;
|
||||||
|
Collections.shuffle(tmpIntersections, new Random());
|
||||||
//(d.) this may update sigma min
|
for (Point point : tmpIntersections) {
|
||||||
upperBound(intersectionsPoint);
|
if (point.getX() > slab.getLower() && point.getX() < slab.getUpper()) {
|
||||||
//(e.) for i={1,2}, call lower bound(Ui)
|
randomIntersection = point.getX();
|
||||||
lowerBound(subSlabU1);
|
break;
|
||||||
lowerBound(subSlabU2);
|
}
|
||||||
|
|
||||||
if (subSlabU1.getActivity()){
|
|
||||||
this.slabs.add(subSlabU1);
|
|
||||||
}
|
}
|
||||||
if (subSlabU2.getActivity()){
|
|
||||||
this.slabs.add(subSlabU2);
|
if (randomIntersection != null){
|
||||||
|
splitActiveSlab(randomIntersection, slab);
|
||||||
|
|
||||||
|
//(d.) this may update sigma min
|
||||||
|
upperBound(intersectionsPoint);
|
||||||
|
//(e.) for i={1,2}, call lower bound(Ui)
|
||||||
|
lowerBound(subSlabU1);
|
||||||
|
lowerBound(subSlabU2);
|
||||||
|
|
||||||
|
if (subSlabU1.getActivity()){
|
||||||
|
this.slabs.add(subSlabU1);
|
||||||
|
}
|
||||||
|
if (subSlabU2.getActivity()){
|
||||||
|
this.slabs.add(subSlabU2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.slabs.poll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,23 +138,9 @@ public class LeastMedianOfSquaresEstimator extends Algorithm {
|
||||||
|
|
||||||
numberOfInversions = mergeSort(umin, 0, umin.size() - 1, umax);
|
numberOfInversions = mergeSort(umin, 0, umin.size() - 1, umax);
|
||||||
|
|
||||||
for (Point point : intersections) {
|
|
||||||
if (point.getX() > slab.getLower() && point.getX() < slab.getUpper()) {
|
|
||||||
randomIntersection.add(point.getX());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.shuffle(randomIntersection);
|
|
||||||
int access = (int) ( randomIntersection.size() * 0.5);
|
|
||||||
if (!randomIntersection.isEmpty()){
|
|
||||||
intersectionsPoint = randomIntersection.get(access);
|
|
||||||
}
|
|
||||||
|
|
||||||
return numberOfInversions;
|
return numberOfInversions;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Parameter anpassen
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Angepasster Merge-Sort Algorithmus.
|
* Angepasster Merge-Sort Algorithmus.
|
||||||
* Die Funktion bekommt neben den standard Parametern zusätzlich eine Liste mit Elementen
|
* Die Funktion bekommt neben den standard Parametern zusätzlich eine Liste mit Elementen
|
||||||
|
|
Loading…
Reference in New Issue