Package jline.api.sim

Class SimFdEmcfd

java.lang.Object
jline.api.sim.SimFdEmcfd

public final class SimFdEmcfd extends Object
Gradient of a noisy function by central differences with a tuned step.

Implements the Estimation-Minimization Central Finite-Difference (EM-CFD) scheme of Li and Lam (2020). Port of MATLAB sim_fd_emcfd.m and sim_fd_emcfd_pilot_deltas.m, and of Python line_solver.api.sim.fdtune.

THE STEP IS NOT GUESSED, IT IS ESTIMATED. The MSE of the central difference averaged over n2 pairs at step d is B^2 d^4 + sigma^2/(2 n2 d^2) with B = f'''(x0)/6 and sigma^2 = Var fhat(x0), minimized at d* = (sigma^2/(4 n2 B^2))^(1/6). The E-stage spends n1 = max(3, floor(lambda n)) pairs at varied pilot steps and regresses the differences on 2d and 2d^3 (Li and Lam, eq. (2)) to estimate B; sigma^2 is estimated from the regression residuals. The M-stage runs the remaining n2 = n - n1 pairs at d* and returns their average quotient. For a vector output one step serves all components, d*^6 = sum_j w_j sigma_j^2 / (4 n2 sum_j w_j B_j^2), with default weights 1/fbar_j^2 (zero where the pilot mean fbar_j vanishes).

Reference: H. Li, H. Lam (2020). Optimally tuning finite-difference estimators. Proceedings of the 2020 Winter Simulation Conference, 457-468.

Since:
LINE 3.1.0
  • Method Details

    • sim_fd_emcfd_pilot_deltas

      public static double[] sim_fd_emcfd_pilot_deltas(int n1, double pilotScale, double maxStep)
      The E-stage perturbation sizes d_i = s n1^(-1/10) Phi^{-1}(1/2 + (i - 1/2)/(2 n1)), clipped to maxStep. Stratified half-normal quantiles replace the paper's i.i.d. normal draw: the same moments, and a bitwise reproducible estimate.
      Parameters:
      n1 - number of pilot pairs
      pilotScale - standard deviation of the pilot step law
      maxStep - upper bound on the steps
      Returns:
      the n1 pilot steps
    • sim_fd_emcfd

      public static SimFdEmcfd.Result sim_fd_emcfd(SimFdEmcfd.Evaluator fhat, double x0, int n)
      EM-CFD with the default options (lambda 0.2, pilot scale 0.1, no step bounds, default weights).
      Parameters:
      fhat - noisy evaluator
      x0 - point at which the derivative is wanted
      n - total number of differencing pairs, at least 4
      Returns:
      the gradient estimate and diagnostics
    • sim_fd_emcfd

      public static SimFdEmcfd.Result sim_fd_emcfd(SimFdEmcfd.Evaluator fhat, double x0, int n, double lambda, double pilotScale, double minStep, double maxStep, double[] weights)
      EM-CFD gradient estimate.
      Parameters:
      fhat - noisy evaluator
      x0 - point at which the derivative is wanted
      n - total number of differencing pairs (2n calls), at least 4
      lambda - E-stage allocation ratio in (0,1)
      pilotScale - standard deviation of the pilot step law, in units of x
      minStep - lower bound on every step used
      maxStep - upper bound on every step used
      weights - per-component weights of the step criterion, or null
      Returns:
      the gradient estimate and diagnostics