KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > gp > impl > GPProgramInfo


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.gp.impl;
11
12 /**
13  * Holds information about a program. Used for caching GP programs during GP
14  * evolution.
15  *
16  * @author Klaus Meffert
17  * @since 3.2
18  */

19 public class GPProgramInfo {
20   /** String containing the CVS revision. Read out via reflection!*/
21   private final static String JavaDoc CVS_REVISION = "$Revision: 1.2 $";
22
23   private double m_fitnessValue;
24
25   private String JavaDoc m_toStringNorm;
26
27   private boolean m_found;
28
29   public GPProgramInfo(GPProgram a_prog, boolean a_found) {
30     m_fitnessValue = a_prog.getFitnessValueDirectly();
31     m_toStringNorm = a_prog.toStringNorm(0);
32     m_found = a_found;
33   }
34
35   public String JavaDoc getToStringNorm() {
36     return m_toStringNorm;
37   }
38
39   public double getFitnessValue() {
40     return m_fitnessValue;
41   }
42
43   public boolean isFound() {
44     return m_found;
45   }
46
47   public void setFound(boolean a_found) {
48     m_found = a_found;
49   }
50
51   public boolean equals(Object JavaDoc a_other) {
52     GPProgramInfo other = (GPProgramInfo) a_other;
53     if (m_toStringNorm == null) {
54       if (other.m_toStringNorm == null) {
55         return true;
56       }
57       return false;
58     }
59     return m_toStringNorm.equals(other.m_toStringNorm);
60   }
61
62   public int compareTo(Object JavaDoc a_other) {
63     GPProgramInfo other = (GPProgramInfo) a_other;
64     if (m_toStringNorm == null) {
65       if (other.m_toStringNorm == null) {
66         return 0;
67       }
68     }
69     return m_toStringNorm.compareTo(other.m_toStringNorm);
70   }
71 }
72
Popular Tags