Hacker News new | ask | show | jobs
by bumbledraven 3035 days ago
The doc uses x to refer to the new point, and x_i for the ith previously evaluated point. To reduce ambiguity, i'll use a capital X to refer to the new point.

The equation says that U(X) is equal to the minimum value of the expression f(x_i) + k * (Euclidean distance from x to x_i), where i ranges over integers 1 to t.

In Go pseudo-code:

  func U(X []float64, x [][]float64, f func([]float64) float64, k float64) float64 {
    min := math.Inf(1)
    for _, x_i := range x {
      e := f(x_i) + k * EuclideanDistance(X, x_i)
      if e < min {
        min := e
      }
    }
    return min
  }