public static <T> Codec<Tree<Op<T>, ?>, ProgramGene<T>>
	codecOf(
		final ISeq<Op<T>> operations,
		final ISeq<Op<T>> terminals,
		final int depth
	) {
		// Average arity of tree nodes.
		final double k = operations.stream()
			.collect(Collectors.averagingDouble(Op::arity));

		// The average node count between treeDepth and treeDepth + 1.
		// 2^(k + 1) - 1 + 2^(k + 2) - 1)/2 == 3*2^k - 1
		final int max = (int)(3*pow(k, depth) - 1);

		return codecOf(
			operations,
			terminals,
			depth,
			ch -> ch.root().size() <= max
		);
	}
Create a new <em>codec</em>, usable for <em>symbolic regression</em>
problems, with the given parameters.

@param <T> the operation type
@param operations the operations used for the symbolic regression
@param terminals the terminal operations of the program tree
@param depth the maximal tree depth (height) of newly created program
       trees
@return a new codec, usable for symbolic regression
@throws IllegalArgumentException if the tree {@code depth} is not in the
        valid range of {@code [0, 30)}
@throws NullPointerException if the {@code operations} or {@code terminals}
        are {@code null}
jenetics.prog/src/main/java/io/jenetics/prog/regression/Regression.java