public IIteration DoIteration(IIteration prevIter) { it = (HJIteration)prevIter; double f = ip.GetFuncValue(it.arrX); while (it.arrE == null) { f = ip.GetFuncValue(it.arrX); double[] arrENext, arrXNext; double fNext = Research(it.arrX, out arrENext, out arrXNext); if (Math.Abs(fNext - f) < ip.fEpsilon) { for (int i = 0; i < it.arrXDelta.Length; i++) { it.arrXDelta[i] /= 2; } for (int i = 0; i < it.arrXDelta.Length; i++) { if (it.arrXDelta[i] < ip.xEpsilon) { it.CalcResult(ip); return(null); } } } else { it.arrE = arrENext; } } double[] arrXSmp = new double[it.arrX.Length]; for (int i = 0; i < arrXSmp.Length; i++) { arrXSmp[i] = it.arrX[i] + it.arrE[i] * it.mult; } double fSmp = ip.GetFuncValue(arrXSmp); if (Math.Abs(fSmp - f) < ip.fEpsilon || fSmp > f) { it.fRes = f; return(new HJIteration(it.arrX, it.arrXDelta, null, 1)); } double[] arrXRes, arrERes; double fRes = Research(arrXSmp, out arrERes, out arrXRes); HJIteration itNext; if (Math.Abs(fRes - f) < ip.fEpsilon) { it.fRes = f; itNext = new HJIteration(it.arrX, it.arrXDelta, null, 1); } else { it.fRes = fSmp; itNext = new HJIteration(arrXSmp, it.arrXDelta, it.arrE, it.mult + 1); } return(itNext); }
public void CalcResult(HJInitialParams ip) { fRes = ip.GetFuncValue(arrX); }