The basic issue is that matrix multiplication involves several varying constraints.  Basically you're saying that if the left child produces an AxB matrix and the right child produces a CxD matrix, and the parent produces an ExF matrix, then it must be the case that B=C, E=A, and F=D.  Notice it doesn't say that A, B, C, D, E, or F must be any *specific* values, just that there are functional constraints on them.  Essentially you have a countably infinite number of types.  Furthermore, you don't specify how these constraints will be enforced -- by forcing children to match a given parent or the other way around?  By forcing the right child to match the left child, or the other way around?

ECJ's typing is meant for situations where parents and children may have a small and finite set of types, children are forced to be constrained by their parents, and there are no constraints between children.  You have a much uglier situation which requires a form of polymorphic typing.

Polymorphic typing systems are nontrivial to implement, and nearly impossible to implement without putting strong restrictions on the tree builders and breeding operators available.  I decided it was not worth the downsides to implement as standard in ECJ's GP facility.   I believe that Maarten Keijzer did polymorphic typing for EO, you might look into that.  Tina Yu did her thesis on polymorphic typing but I don't know what system she used.  Otherwise you're probably stuck with GE [which ECJ can do, along with certain other systems].


On Nov 24, 2015, at 4:53 PM, Márcio Basgalupp <[log in to unmask]> wrote:

> Dear all,
> I'm using GP for combining 'matrix objects' (for example, matrix A, B and C). I also have a node representing a number (extending ERC class). Then, I would like to evolve individuals such as 'A*B', '2*A + B', 'C*A + 2*B', etc, i.e., my 'complete individual' must return a matrix. I can not, for example, have an individual like '2 + 2' or '3 * 2', because it would return a number (not a matrix). If I use a GE (Grammatical Evolution) I can easily avoid it by using the grammar. How can I avoid it by using GP in ECJ? Is there any way to ensure that I will always have at least one matrix as a terminal node? 
> Best,
> Márcio
> --------
> Prof. Dr. Márcio Porto Basgalupp
> Instituto de Ciência e Tecnologia (ICT)
> Universidade Federal de São Paulo (UNIFESP)
> Tel: +55 12 3309-9500 (r: 9762)