Page 176 - 49A Field Guide to Genetic Programming
P. 176

162                                                      B TinyGP


        364         newind = cr o s s o ve r ( pop [ parent1 ] , pop [ parent2 ] ) ;
        365       }
        366       else {
        367         parent = tournament ( f i t n e s s , TSIZE ) ;
        368         newind = mutation ( pop [ parent ] , PMUT PER NODE ) ;
        369       }
        370       newfit = f i t n e s s f u n c t i o n ( newind ) ;
        371       o f f s p r i n g = negative tournament ( f i t n e s s , TSIZE ) ;
        372       pop [ o f f s p r i n g ] = newind ;
        373       f i t n e s s [ o f f s p r i n g ] = newfit ;
        374       }
        375       s t a t s ( f i t n e s s , pop , gen ) ;
        376     }
        377     System . out . print ( ”PROBLEM ∗NOT∗ SOLVED\n” ) ;
        378     System . e x i t ( 1 ) ;
        379   }
        380
        381   public static void main ( String [ ] args ) {
        382     String fname = ”problem . dat” ;
        383     long s = −1;
        384
        385     i f ( args . length == 2 ) {
        386       s = Integer . valueOf ( args [ 0 ] ) . intValue () ;
        387       fname = args [ 1 ] ;
        388     }
        389     i f ( args . length == 1 ) {
        390       fname = args [ 0 ] ;
        391     }
        392
        393     tiny gp gp = new tiny gp ( fname , s ) ;
        394     gp . evolve () ;
        395   }
        396  };


            B.4     Compiling and Running TinyGP


            It is very common, nowadays, for people to write and execute code within
            some development environment. Each has its own way of doing these oper-
            ations, but the process is typically very straightforward.
               If one wants to compile TinyGP from the operating system’s shell, this
            can be done by issuing the command javac -O tiny gp.java. This applies
            to both Unix and Windows users. Windows users will have to click on
            Start→Run and then issue the command cmd to launch a shell. Of course,
            if the javac Java compiler and/or the tiny gp.java source file are not in
            the current directory/folder, then full path names must be provided when
            issuing the compilation command.
               If the dataset is stored in a file problem.dat, the program can then
            simply be launched with the command java tiny gp. Otherwise, the user
            can specify a different datafile on the command line, by giving the command
   171   172   173   174   175   176   177   178   179   180   181