[jgap-users] Problems with InvalidConfigurationException
Brought to you by:
klausikm
From: jimsbr <ji...@ho...> - 2009-03-17 03:03:15
|
Hello - I[m new to JGap and am trying to implement an ADF that accepts a CommandGene.BooleanClass and returns a CommandGene.FloatClass. The startup code is listed below - public GPGenotype create() throws InvalidConfigurationException { GPConfiguration conf = getGPConfiguration(); // At first, we define the return type of the GP program. // ------------------------------------------------------ Class[] types = { // Return type of result-producing chromosome CommandGene.FloatClass, // ADF-relevant: // Return type of ADF 1 CommandGene.FloatClass}; // ----------------------------------------------------------------------- Class[][] argTypes = { // Arguments of result-producing chromosome: none {}, // ADF-relevant: // Arguments of ADF1 {CommandGene.BooleanClass} }; // Next, we define the set of available GP commands and terminals to use. // Please see package org.jgap.gp.function and org.jgap.gp.terminal // You can easily add commands and terminals of your own. // ---------------------------------------------------------------------- CommandGene[][] nodeSets = { { // We use a variable that can be set in the fitness function. // ---------------------------------------------------------- new Add(conf, CommandGene.FloatClass), new Or(conf), new Terminal(conf, CommandGene.FloatClass, 2.0d, 10.0d, true), new True(conf), // ADF-relevant: // Construct a reference to the ADF defined in the second nodeset // which has index 1 (second parameter of ADF-constructor). // Furthermore, the ADF expects three input parameters (see argTypes[1]) new ADF(conf, 1 , 1) } , // ADF-relevant: // and now the definition of ADF(1) { new MyIfStatement(conf, CommandGene.BooleanClass) } }; The program returns a Exception in thread "main" org.jgap.InvalidConfigurationException: java.lang.IllegalStateException: Chromosome (depth 0, index 1) requires a function or terminal of return type class java.lang.Float (sub return type 0) but there is no such node available The error is occurring because isPossible(Class a_returnType, int a_subReturnType, CommandGene[] a_nodeSet, boolean a_function, boolean a_growing) is returning false. The CommandGene[0] type is MyIfStatement, CommandGene[1] is Argument. Can you give me some idea as to what I am doing wrong? Thanks, Jim -- View this message in context: http://www.nabble.com/Problems-with-InvalidConfigurationException-tp22551835p22551835.html Sent from the jgap-users mailing list archive at Nabble.com. |