MOEAFramework / MOEAFramework

A Free and Open Source Java Framework for Multiobjective Optimization
http://moeaframework.org
Other
328 stars 128 forks source link

Are there examples using Grammar or ContextFreeGrammar? #137

Closed orsjb closed 1 year ago

orsjb commented 7 years ago

Awesome library. I purchased the tutorial in the hope that it would contain examples of using Grammar or ContextFreeGrammar. I need to define my own grammar for a solution. Hoping there are examples out there somewhere.

dhadka commented 7 years ago

Hi, here's an old example I have: https://gist.github.com/dhadka/a6fda25e12610712ac31894955de4153

This is similar to the examples/org/moeaframework/examples/gp/regression examples but uses a grammar to generate the function. In this case, the grammar is a JavaScript expression, which we evaluate using Java's built-in scripting engine.

orsjb commented 7 years ago

Thanks!

On 9 Nov 2017, at 1:42 am, David Hadka notifications@github.com wrote:

Hi, here's an old example I have: https://gist.github.com/dhadka/a6fda25e12610712ac31894955de4153 https://gist.github.com/dhadka/a6fda25e12610712ac31894955de4153 This is similar to the examples/org/moeaframework/examples/gp/regression examples but uses a grammar to generate the function. In this case, the grammar is a JavaScript expression, which we evaluate using Java's built-in scripting engine.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MOEAFramework/MOEAFramework/issues/137#issuecomment-342837688, or mute the thread https://github.com/notifications/unsubscribe-auth/AABsIkuzOY8d0n1FbWKFOMv_ZEkQ-QxOks5s0b3JgaJpZM4QQzOh.

orsjb commented 7 years ago

Do you also have an example that shows using Rule, Symbol and Production with ContextFreeGrammar? I want to make my own custom grammar and then create something to parse it. I assume I can construct the grammar with these classes instead of a String. Is that right?

orsjb commented 7 years ago

PS: I'm using this issue tracker more like it's a discussion forum. There's not a MOEA framework forum is there? Don't want to abuse the purpose of the issue tracker!

Specifically what I want to do is evolve a grammar, but within that grammar have various real valued numbers between 0-1 that specify parameters.

My grammar looks something like this: (Condition,paramX,paramY,(Condition,paramX,paramY,(Action,paramA,paramB),(Action,paramA,paramB)).

So currently I'm using the grammar to specify the possible parameters values as a set of possible values. But I want the evolution to smoothly search the space of parameter values instead.

Here's my current grammar (it's a type of decision tree where each leaf specifies a variable-length array of actions):

"<expr> ::= (<decision>)\n"
            + "<node> ::= (<decision>)|(<leaf>)\n"
            + "<decision> ::= D <index>,<thresh>,<node>,<node>\n"
            + "<index> ::= '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'10'|'11'|'12'|'13'|'14'|'15'|'16'|'17'|'18'|'19'\n"
            + "<thresh> ::= '0.0'|'0.1'|'0.2'|'0.3'|'0.3'|'0.4'|'0.5'|'0.6'|'0.7'|'0.8'|'0.9'|'1.0'\n"
            + "<leaf> ::= <index>,<op>,<index>|<leaf>,<leaf>\n"
            + "<op> ::= '*'|'+'|'-'|'LOW'|'HIGH'\n";
orsjb commented 7 years ago

Lastly, OT, I wonder if you have plans to implement Lehman and Stanley's Novelty Search.

github-actions[bot] commented 1 year ago

This is an automated message. This issue is flagged as stale and will be closed in 7 days. If you feel this issue is still relevant, leave a comment to keep the issue open. Please also consider contributing a fix for the issue.