public double FindMin(IFunction function) { double[] currentState = RandGenerator.RandomArray (dimensions, searchSpace[0], searchSpace[1]); double T = maxTemp; double alpha = 0.999; for (int i = 0; i < iterTreshold; i++) { double[] newState = new double[dimensions]; currentState.CopyTo(newState, 0); for (int j = 0; j < dimensions; j++) { newState[j] += RandGenerator.RandomNormal(-1.0, 1.0, 1) * T; } if (AcceptanceProb(function.Calculate(currentState), function.Calculate(newState), T) >= rand.NextDouble()) { currentState = newState; } T *= alpha; } return(function.Calculate(currentState)); }
private double[] Move(double[] start, int iteration) { double[] result = new double[start.Length]; start.CopyTo(result, 0); for (int i = 0; i < iteration; i++) { for (int j = 0; j < result.Length; j++) { result[j] += RandGenerator.RandomNormal(-1.0, 1.0, 100) * walkSize; } } return(result); }