/// Create a Simplex by finding the optimum in each direction /// starting from the initial value.. public override void InitializeIterations() { double[] v = new double[_result.Length]; for (int i = 0; i < _result.Length; i++) { v[i] = 0; } VectorProjectedFunction projection = new VectorProjectedFunction(_f, _result, v); OneVariableFunctionOptimizer unidimensionalFinder = new OneVariableFunctionOptimizer(projection, _pointFactory); unidimensionalFinder.DesiredPrecision = this.DesiredPrecision; _simplex = new OptimizingVector[_result.Length + 1]; try { for (int i = 0; i < _result.Length; i++) { v[i] = 1; projection.SetDirection(v); v[i] = 0; unidimensionalFinder.InitialValue = 0; unidimensionalFinder.Evaluate(); _simplex[i] = _pointFactory.CreateVector( projection.ArgumentAt( unidimensionalFinder.Result), _f); } } catch (DhbIllegalDimension) { }; _simplex[_result.Length] = _pointFactory.CreateVector(_result, _f); SortPoints(_simplex); }
private void AdjustLastDirection(DhbVector start) { try { int n = _projections.Length - 1; _projections[n].SetOrigin(_result); DhbVector newDirection = _projections[n].Origin - start; double norm = newDirection.Norm; if (norm > this.DesiredPrecision) { newDirection.ScaledBy(1 / norm); _projections[n].Direction = newDirection; _unidimensionalFinder.Function = _projections[n]; _unidimensionalFinder.InitialValue = 0; _unidimensionalFinder.Evaluate(); _result = _projections[n].ArgumentAt( _unidimensionalFinder.Result).ToComponents(); } } catch (DhbIllegalDimension) { }; }