Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Type GP's #616

Open
3Fish opened this issue Dec 5, 2019 · 9 comments
Open

Multi Type GP's #616

3Fish opened this issue Dec 5, 2019 · 9 comments

Comments

@3Fish
Copy link

3Fish commented Dec 5, 2019

It would be nice if it would be possible to assign OP's different Types for each Input and the output and let the Mutator check for matching input and output type.

I know that this takes a lot of performance, but it would be possible to shrink the search space significantly.

For Example if building a Rule Generator I have:
operators: AND, OR, >=, NOT
terminals: Ephemeral(1,0), VAR(for each attribute)

But the >= Op should only take terminals as input since it does not make sense to use it further up the tree. And the Not Operator does not make sense with the Ephemeral since it converts just one into the other. Also, double NOT-NOT combinations should be invalid, but I could fix that with a Rewriter.

Example for a generated Tree:

AND
├─AND
│ ├─NOT
│ │ └─>=
│ │   ├─>=
│ │   │ ├─C
│ │   │ └─B
│ │   └─OR
│ │     ├─FALSE
│ │     └─TRUE
│ └─NOT
│   └─>=
│     ├─NOT
│     │ └─TRUE
│     └─AND
│       ├─TRUE
│       └─C
└─>=
  ├─NOT
  │ └─NOT
  │   └─>=
  │     ├─A
  │     └─TRUE
  └─NOT
    └─>=
      ├─A
      └─NOT
        └─FALSE

Kind Regards
Dirk Peters

@jenetics
Copy link
Owner

jenetics commented Dec 9, 2019

I already thought about relaxing the GP constraint. It is not only the mutation, which can destroy the constraints. Also, the initial tree generation must obey the (implicitly) given rules. I haven't found a way of modeling such trees in an intuitive way. It's on my list, but with not the highest priority.

@3Fish
Copy link
Author

3Fish commented Dec 23, 2019

Where could I start when I would like to implement such a mechanism myself? Could you suggest me a starting point?

@tr8dr
Copy link

tr8dr commented Aug 21, 2020

I also need this facility (typed GP sub-trees). A cross-over operator will do the wrong thing when there is more than one "type" involved. DEAP (the python GP project), presents a simple interface to declare operators and typing.

https://deap.readthedocs.io/en/master/tutorials/advanced/gp.html

Obviously would need to have a more java / jenetics idiomatic representation. Like @3Fish above, I would like to get something like this implemented soonest and will volunteer my time, given some pointers.

@jenetics
Copy link
Owner

You are welcome, if you want to try to implement this feature. I think we will need an additional Op interface.

interface GenericOp extends Op<Object> {
    public Class<?> returnType();
    public Class<?> parameterTypeAt(final int index);

    public String name();
    public int arity();
    public Object apply(Object[] args);
}

Additionally we will need

  • A function builder which obeys the type information of the GenericOp
  • Genetic operators which obeys the type information

@tr8dr
Copy link

tr8dr commented Aug 21, 2020

I was not think of of Type in the sense of java types, rather that may have Ops and Leaf nodes that belong to a different subset of evolutionary operators (where they may all return Double for example). One could have an operation that expects:

(op23 <tree of type A> <tree of type B> <tree of type B>)

but where both types A and B evaluate to Double for example.

I suppose one could wrap Double into different classes to create this distinction. I'll have a closer look at the code to better understand what this would entail. I already noticed that the mutation / crossover operators for GP are not in prog, rather in ext. So understanding what is bound with GP or related to the core GA core is a bit more difficult ...

@c2v4
Copy link

c2v4 commented Apr 10, 2021

Is there any update in this field? I tried to figure out a way to plug it in, but the type system in jenetics.prog seems to give no chance of doing that. Instead of proposes GenericOp I thought of Op<T,U>. Unfortunately, I am far not knowledgeable to implement such change

@jenetics
Copy link
Owner

@c2v4 there is no progress regarding this issue. I have to do some research work myself, which I haven't had the time to do so far. I don't think this will change in the near future. But it's still in the backlog. ;-)

@c2v4
Copy link

c2v4 commented Apr 11, 2021

@jenetics Thanks for the update. I guess I'll have to learn the internals of jenetics.prog and maybe I'll be able to craft something. Unfortunately, I cannot promise to deliver that.

@jenetics
Copy link
Owner

jenetics commented Jun 15, 2022

@3Fish, release 7.1.0 contains classes for Grammatical Evolution (GE), which might be a possibility to do multi type GP. A simple example is given in the GrammaticalJavaScriptEvolution example.

Is related with #815

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants