]> git.gag.com Git - debian/openrocket/blob - src/net/sf/openrocket/optimization/Function.java
enhanced motor handling, bug fixes, initial optimization code
[debian/openrocket] / src / net / sf / openrocket / optimization / Function.java
1 package net.sf.openrocket.optimization;
2
3 /**
4  * An interface defining an optimizable function.
5  * <p>
6  * Some function optimizers require that the function is thread-safe.
7  * 
8  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
9  */
10 public interface Function {
11         
12         /**
13          * Evaluate the function at the specified point.
14          * <p>
15          * If the function evaluation is slow, then this method should abort the computation if
16          * the thread is interrupted.
17          * 
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.
21          */
22         public double evaluate(Point point) throws InterruptedException;
23         
24         
25         /**
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
29          * function domain).
30          * <p>
31          * Note that it is allowed to always allowed to return <code>Double.NaN</code>, especially
32          * for functions that are fast to evaluate.
33          * 
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.
37          */
38         public double preComputed(Point point);
39         
40 }