/// Shift the best points toward positive positions. private void MoveTowardPositive() { OptimizingPoint newPoint = _pointFactory.CreatePoint( 3 * _bestPoints[2].Position - 2 * _bestPoints[1].Position, _f); _bestPoints[0] = _bestPoints[1]; _bestPoints[1] = _bestPoints[2]; _bestPoints[2] = newPoint; }
/// Apply bisection on points 1 and n /// @param n int index of worst point of bisected interval private void ReducePoints(int n) { double x = _bestPoints[1].Position; x += GoldenSection * (_bestPoints[n].Position - x); OptimizingPoint newPoint = _pointFactory.CreatePoint(x, _f); if (newPoint.BetterThan(_bestPoints[1])) { _bestPoints[2 - n] = _bestPoints[1]; _bestPoints[1] = newPoint; } else { _bestPoints[n] = newPoint; } }
/// @return boolean true if the receiver is "better" than /// the supplied point /// @param point OptimizingPoint public override bool BetterThan(OptimizingPoint point) { return(this.Value < point.Value); }
/// @return boolean true if the receiver is "better" than /// the supplied point /// @param point OptimizingPoint public abstract bool BetterThan(OptimizingPoint entity);