001 package org.jaga.exampleApplications;
002
003 import org.jaga.definitions.*;
004 import org.jaga.util.*;
005 import org.jaga.masterAlgorithm.*;
006 import org.jaga.individualRepresentation.greycodedNumbers.*;
007 import org.jaga.hooks.*;
008
009 /**
010 * TODO: Complete these comments.
011 *
012 * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
013 *
014 * <p><u>Company:</u> University College London and JAGA.Org
015 * (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
016 * </p>
017 *
018 * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
019 * This program is free software; you can redistribute it and/or modify
020 * it under the terms of the GNU General Public License as published by
021 * the Free Software Foundation, ONLY if you include a note of the original
022 * author(s) in any redistributed/modified copy.<br/>
023 * This program is distributed in the hope that it will be useful,
024 * but WITHOUT ANY WARRANTY; without even the implied warranty of
025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026 * GNU General Public License for more details.<br/>
027 * You should have received a copy of the GNU General Public License
028 * along with this program; if not, write to the Free Software
029 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030 * or see http://www.gnu.org/licenses/gpl.html</p>
031 *
032 * @author Greg Paperin (greg@jaga.org)
033 *
034 * @version JAGA public release 1.0 beta
035 */
036
037 public class SimpleImplementationDemo {
038
039 public SimpleImplementationDemo() {
040 }
041
042 public void exec() {
043
044 GAParameterSet params = new DefaultParameterSet();
045 params.setPopulationSize(5);
046 ((NDecimalsIndividualSimpleFactory) params.getIndividualsFactory()).setConstraint(0, new RangeConstraint(-10, 10));
047
048 ReusableSimpleGA ga = new ReusableSimpleGA(params);
049 ga.addHook(new DebugHook());
050
051 int repeat = 1;
052 System.out.println("\n\n");
053 System.out.println("This is a simple demo for the \"Genetic Algorithms in Java\"-Package.");
054 System.out.println("This software is developed by Greg Paperin at the University College London.");
055 System.out.println("All materials connected to this software are under the GNU licence.");
056 System.out.println("\n");
057 System.out.println("Running the algorithm " + repeat + " times.");
058 System.out.println("The parameters are: \n" + params);
059 System.out.println("\n\n");
060 for (int i = 0; i < repeat; i++) {
061 System.out.println("** Run " + i + ". **");
062 GAResult result = ((ReusableSimpleGA) ga).exec();
063 System.out.println("Result is: " + result);
064 System.out.println("\n");
065 }
066 System.out.println("\nDemo finished.");
067 System.out.println("Please, visit http://www.jaga.org to check for latest updates.");
068 }
069
070 public static void main(String[] unusedArgs) {
071 SimpleImplementationDemo demo = new SimpleImplementationDemo();
072 demo.exec();
073
074 }
075 }