001 package org.jaga.hooks;
002
003 import org.jaga.definitions.*;
004 import org.jaga.masterAlgorithm.*;
005
006
007 /**
008 * TODO: Complete these comments.
009 *
010 * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
011 *
012 * <p><u>Company:</u> University College London and JAGA.Org
013 * (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
014 * </p>
015 *
016 * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
017 * This program is free software; you can redistribute it and/or modify
018 * it under the terms of the GNU General Public License as published by
019 * the Free Software Foundation, ONLY if you include a note of the original
020 * author(s) in any redistributed/modified copy.<br/>
021 * This program is distributed in the hope that it will be useful,
022 * but WITHOUT ANY WARRANTY; without even the implied warranty of
023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
024 * GNU General Public License for more details.<br/>
025 * You should have received a copy of the GNU General Public License
026 * along with this program; if not, write to the Free Software
027 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
028 * or see http://www.gnu.org/licenses/gpl.html</p>
029 *
030 * @author Greg Paperin (greg@jaga.org)
031 *
032 * @version JAGA public release 1.0 beta
033 */
034
035 public class BetterResultHook extends DebugHook {
036
037 private long countFitnessEvaluations = 0;
038
039 public BetterResultHook() {}
040
041 /*
042 public void foundNewResult(SimpleGA caller, Population pop, int age,
043 GAResult result, GAParameterSet params) {
044 ;// IS SWITCHED ON.
045 }
046 */
047
048 /*
049 public void initialisationDone(SimpleGA caller, Population pop, int age,
050 GAResult result, GAParameterSet params) {
051 ;// IS SWITCHED ON.
052 }
053 */
054
055 public void generationChanged(SimpleGA caller, Population pop, int age,
056 GAResult result, GAParameterSet paramss) {
057 ;// IS SWITCHED OFF.
058 }
059
060 /*
061 public void terminationConditionApplies(SimpleGA caller, Population pop, int age,
062 GAResult result, GAParameterSet params) {
063 ;// IS SWITCHED ON.
064 }
065 */
066
067 public void selectedForReproduction(SimpleGA caller, Individual [] selectedParents,
068 Population pop, int age, GAResult result,
069 GAParameterSet params) {
070 ;// IS SWITCHED OFF.
071 }
072
073 public void reproduced(SimpleGA caller, Individual [] children, Individual [] parents,
074 Population pop, int age, GAResult result, GAParameterSet params) {
075 ;// IS SWITCHED OFF.
076 }
077
078 public void fitnessCalculated(SimpleGA caller, Individual updatedIndividual,
079 Population pop, int age, GAParameterSet params) {
080 ++countFitnessEvaluations;// IS ADOPTED.
081 }
082
083 public long getFitnessEvaluations() {
084 return this.countFitnessEvaluations;
085 }
086
087 public void resetEvaluationsCounter() {
088 this.countFitnessEvaluations = 0;
089 }
090
091 }