private void EnlargeContinuousInterval(HyperRectangleBuilder builder, Array <float> instance, int dimensionIndex) { var(Start, End) = builder.GetContinuousDimensionPreview(dimensionIndex); var target = instance[dimensionIndex]; if (target < Start) { builder.UpdateContinuousDimensionIntervalStart( dimensionIndex: dimensionIndex, value: target); return; } if (target >= End) { var possibleValues = _dataset.GetSortedUniqueFeatureValues(featureIndex: dimensionIndex); var indexOfStart = possibleValues.BinarySearch(target); if (indexOfStart == possibleValues.Length - 1) { builder.UpdateContinuousDimensionIntervalEnd( dimensionIndex: dimensionIndex, value: float.PositiveInfinity); } else { var nextLarger = possibleValues[indexOfStart + 1]; builder.UpdateContinuousDimensionIntervalEnd( dimensionIndex: dimensionIndex, value: nextLarger); } } }
private void UpdateContinuousDimension(HyperRectangleBuilder builder, Array <HyperRectangle> existingHyperRectangles, int dimensionIndex, Array <float> seed) { var min = float.NegativeInfinity; var max = float.PositiveInfinity; for (int i = 0; i < existingHyperRectangles.Length; i++) { var currentRectangle = existingHyperRectangles[i]; var intersects = _intersector.IntersectsInAllButOneDimension( builder: builder, rect: currentRectangle, dimensionToSkip: dimensionIndex); if (!intersects) { continue; } var dimension = (ContinuousInterval)currentRectangle.GetDimensionInterval(dimensionIndex); var otherEnd = dimension.End; var otherStart = dimension.Start; var seedValue = seed[dimensionIndex]; if (seedValue >= otherEnd) { min = Math.Max(min, otherEnd); } else { max = Math.Min(max, otherStart); } } builder.UpdateContinuousDimensionIntervalStart(dimensionIndex: dimensionIndex, value: min); builder.UpdateContinuousDimensionIntervalEnd(dimensionIndex: dimensionIndex, value: max); }