View Javadoc
1   package net.bmahe.genetics4j.gp;
2   
3   /**
4    * Factory interface for creating operations in genetic programming.
5    * 
6    * <p>An OperationFactory provides a way to create {@link Operation} instances with type information
7    * and context-dependent parameters. Factories are particularly useful when operations need to be
8    * configured based on input specifications or when operations require runtime information.
9    * 
10   * <p>The factory pattern allows for:
11   * <ul>
12   * <li>Dynamic operation creation based on input specifications</li>
13   * <li>Type-safe operation construction in strongly-typed GP</li>
14   * <li>Parameterized operations that adapt to problem context</li>
15   * <li>Lazy evaluation of expensive operation setup</li>
16   * </ul>
17   * 
18   * <p>Common use cases include:
19   * <ul>
20   * <li>Creating input operations that depend on input variable count</li>
21   * <li>Building coefficient operations with domain-specific ranges</li>
22   * <li>Constructing type-specific mathematical operations</li>
23   * <li>Generating random constants within specified bounds</li>
24   * </ul>
25   * 
26   * @see Operation
27   * @see InputSpec
28   * @see OperationFactories
29   */
30  @SuppressWarnings("rawtypes")
31  public interface OperationFactory {
32  
33  	/**
34  	 * Returns the types that operations created by this factory accept as arguments.
35  	 * 
36  	 * <p>This defines the type signature for the operation's arguments and is used
37  	 * for type checking in strongly-typed genetic programming.
38  	 * 
39  	 * @return an array of classes representing the accepted argument types
40  	 */
41  	//TODO make a List<Class>
42  	Class[] acceptedTypes();
43  
44  	/**
45  	 * Returns the type that operations created by this factory return.
46  	 * 
47  	 * @return the return type of operations created by this factory
48  	 */
49  	Class returnedType();
50  
51  	/**
52  	 * Creates a new operation instance using the provided input specification.
53  	 * 
54  	 * <p>The input specification provides context about the problem domain,
55  	 * such as the number and types of input variables, which can be used
56  	 * to customize the created operation.
57  	 * 
58  	 * @param inputSpec the input specification providing context for operation creation
59  	 * @return a new operation instance configured according to the input specification
60  	 */
61  	Operation build(final InputSpec inputSpec);
62  }