1 package net.sf.openrocket.optimization;
4 * An interface defining an optimizable function.
6 * Some function optimizers require that the function is thread-safe.
8 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
10 public interface Function {
13 * Evaluate the function at the specified point.
15 * If the function evaluation is slow, then this method should abort the computation if
16 * the thread is interrupted.
18 * @param point the point at which to evaluate the function.
19 * @return the function value.
20 * @throws InterruptedException if the thread was interrupted before function evaluation was completed.
22 public double evaluate(Point point) throws InterruptedException;
26 * Return a cached value of the function at the specified point. This allows efficient
27 * caching of old values even between calls to optimization methods. This method should
28 * NOT evaluate the function except in special cases (e.g. the point is outside of the
31 * Note that it is allowed to always allowed to return <code>Double.NaN</code>, especially
32 * for functions that are fast to evaluate.
34 * @param point the point of function evaluation.
35 * @return the function value, or <code>Double.NaN</code> if the function value has not been
36 * evaluated at this point.
38 public double preComputed(Point point);