GP: if-function with void-typed child node

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GP: if-function with void-typed child node

haimat
Hi all,

for a GP problem I am currently working on I need to create an if-like
function that uses a boolean-typed node as first child (i.e. the
if-clause). The second child should be a void-typed node (i.e. one of
my custom side-effect functions). Thus this custom if-function should
check the boolean value of the first child and then, if true, execute
the second child that has not return type (it should simply be
executed).

Is there a way to achieve this? If I set the standard if-function to a
void-typed child node, how is ensured then that the first child node
is of boolean type? Or do I need to create a custom if-function; if so
then how?

Thanks in advance for your help!

Kind regards, Matthias


--
Matthias F. Brandstetter
[hidden email]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: GP: if-function with void-typed child node

Klaus Meffert-5
Hi Matthias,

the If function in package org.jgap.gp.function alomost does what you need.
I think you only have to change the execute_void function to:
  public void execute_void(ProgramChromosome c, int n, Object[] args) {
    boolean x = c.execute_boolean(n, 0, args);//this is changed
    if (x) { //this is changed
      c.execute_void(n, 1, args);
    }
  }

Then, you can use If with a boolean type first child and a void type second
child.

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: Matthias F. Brandstetter [mailto:[hidden email]]
> Sent: Thursday, April 07, 2011 1:54 PM
> To: [hidden email]
> Subject: [jgap-users] GP: if-function with void-typed child node
>
> Hi all,
>
> for a GP problem I am currently working on I need to create
> an if-like function that uses a boolean-typed node as first
> child (i.e. the if-clause). The second child should be a
> void-typed node (i.e. one of my custom side-effect
> functions). Thus this custom if-function should check the
> boolean value of the first child and then, if true, execute
> the second child that has not return type (it should simply
> be executed).
>
> Is there a way to achieve this? If I set the standard
> if-function to a void-typed child node, how is ensured then
> that the first child node is of boolean type? Or do I need to
> create a custom if-function; if so then how?
>
> Thanks in advance for your help!
>
> Kind regards, Matthias
>
>
> --
> Matthias F. Brandstetter
> [hidden email]
>
> --------------------------------------------------------------
> ----------------
> Xperia(TM) PLAY
> It's a major breakthrough. An authentic gaming smartphone on
> the nation's most reliable network.
> And it wants your games.
> http://p.sf.net/sfu/verizon-sfdev
> _______________________________________________
> jgap-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jgap-users


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users