View Javadoc

1   /*
2    * Created on Sep 7, 2004
3    */
4   package yawn.nn.committee.functions;
5   
6   import yawn.util.Pattern;
7   
8   /***
9    * 
10   * <p>$Id: CommitteeFunction.java,v 1.4 2005/04/20 18:55:19 supermarti Exp $</p>
11   * 
12   * @author Luis Mart&iacute; (luis dot marti at uc3m dot es)
13   * @version $Revision: 1.4 $
14   */
15  public abstract class CommitteeFunction {
16      /***
17       * Builds a committe response from an array of outputs. For each feature of
18       * the output <code>piecewise()</code> is called.
19       * 
20       * @param x
21       *            outputs of the committe members
22       * @return the output of the committe
23       */
24      public Pattern assamble(Pattern[] x) {
25          Pattern res = new Pattern(x[0].size());
26          for (int i = 0; i < x[0].size(); i++) {
27              double[] piece = new double[x.length];
28              for (int j = 0; j < x.length; j++) {
29                  piece[j] = x[j].getComponent(i);
30              }
31              res.setComponent(piecewise(piece), i);
32          }
33          return res;
34      }
35  
36      /***
37       * Computes the value of an output feature of a committe.
38       * 
39       * @param x
40       *            the feature of each each committe member's output
41       * @return the resulting output feature
42       */
43      protected abstract double piecewise(double[] x);
44  }