public double GetHV(Front front, Solution refPoint) { this.referencePoint = new Point(refPoint); double volume = 0.0; Sort(front); if (currentDimension == 2) { volume = Get2DHV(front); } else { volume = 0.0; currentDimension--; for (int i = front.NPoints - 1; i >= 0; i--) { volume += Math.Abs(front.Points[i].Objectives[currentDimension] - this.referencePoint.Objectives[currentDimension]) * this.GetExclusiveHV(front, i); } currentDimension++; } return(volume); }
public int GetLessContributorHV(SolutionSet set) { Front wholeFront = new Front(); wholeFront.LoadFront(set, -1); int index = 0; double contribution = double.PositiveInfinity; for (int i = 0; i < set.Size(); i++) { double[] v = new double[set.Get(i).NumberOfObjectives]; for (int j = 0; j < v.Length; j++) { v[j] = set.Get(i).Objective[j]; } Point p = new Point(v); double aux = this.GetExclusiveHV(wholeFront, i); if ((aux) < contribution) { index = i; contribution = aux; } set.Get(i).CrowdingDistance = aux; } return(index); }
public double Get2DHV(Front front) { double hv = 0.0; hv = Math.Abs((front.Points[0].Objectives[0] - referencePoint.Objectives[0]) * (front.Points[0].Objectives[1] - referencePoint.Objectives[1])); for (int i = 1; i < front.NPoints; i++) { hv += Math.Abs((front.Points[i].Objectives[0] - referencePoint.Objectives[0]) * (front.Points[i].Objectives[1] - front.Points[i - 1].Objectives[1])); } return(hv); }
public void MakeDominatedBit(Front front, int p) { int z = front.NPoints - 1 - p; for (int i = 0; i < z; i++) { for (int j = 0; j < currentDimension; j++) { fs[currentDeep].Points[i].Objectives[j] = Worse(front.Points[p].Objectives[j], front.Points[p + 1 + i].Objectives[j], false); } } Point t; fs[currentDeep].NPoints = 1; for (int i = 1; i < z; i++) { int j = 0; bool keep = true; while (j < fs[currentDeep].NPoints && keep) { switch (Dominates2way(fs[currentDeep].Points[i], fs[currentDeep].Points[j])) { case -1: t = fs[currentDeep].Points[j]; fs[currentDeep].NPoints--; fs[currentDeep].Points[j] = fs[currentDeep].Points[fs[currentDeep].NPoints]; fs[currentDeep].Points[fs[currentDeep].NPoints] = t; break; case 0: j++; break; default: keep = false; break; } } if (keep) { t = fs[currentDeep].Points[fs[currentDeep].NPoints]; fs[currentDeep].Points[fs[currentDeep].NPoints] = fs[currentDeep].Points[i]; fs[currentDeep].Points[i] = t; fs[currentDeep].NPoints++; } } currentDeep++; }
public double GetExclusiveHV(Front front, int point) { double volume; volume = GetInclusiveHV(front.Points[point]); if (front.NPoints > point + 1) { MakeDominatedBit(front, point); double v = GetHV(fs[currentDeep - 1]); volume -= v; currentDeep--; } return(volume); }
public WFGHV(int dimension, int maxNumberOfPoints, Solution referencePoint) { this.referencePoint = new Point(referencePoint); this.currentDeep = 0; this.currentDimension = dimension; this.maxNumberOfPoints = maxNumberOfPoints; this.maxNumberOfObjectives = dimension; this.pointComparator = new PointComparator(true); int maxd = maxNumberOfPoints - (OPT / 2 + 1); fs = new Front[maxd]; for (int i = 0; i < maxd; i++) { fs[i] = new Front(maxNumberOfPoints, dimension); } }
public void Sort(Front front) { Array.Sort(front.Points, 0, front.NPoints, pointComparator); }