[Polycasso-commit] SF.net SVN: polycasso:[235] trunk/polycasso/src/com/mebigfatguy/polycasso
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-07-25 07:08:10
|
Revision: 235
http://polycasso.svn.sourceforge.net/polycasso/?rev=235&view=rev
Author: dbrosius
Date: 2011-07-25 07:08:03 +0000 (Mon, 25 Jul 2011)
Log Message:
-----------
hook up annealing
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2011-07-25 05:45:14 UTC (rev 234)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2011-07-25 07:08:03 UTC (rev 235)
@@ -146,7 +146,7 @@
int r = random.nextInt(size);
- int idx = (r * r) / (size * size);
+ int idx = (int)(r * ((double) r / (double) size));
return generation.get(idx).data;
}
@@ -174,6 +174,25 @@
nextGeneration.add(generation.get(i));
}
+ if (settings.isUseAnnealing() && (annealingValue > 0.01)) {
+ int annealingReplacements = 0;
+ /* always keep the best, so start at 1 */
+ for (int i = 1; i < eliteSize; i++) {
+ int candidateIndex = random.nextInt(sz - eliteSize) + eliteSize;
+ Member candidate = generation.get(candidateIndex);
+ Member elite = generation.get(i);
+ double delta = candidate.score - elite.score;
+ if (delta < annealingValue) {
+ nextGeneration.set(i, candidate);
+ annealingReplacements++;
+ }
+ }
+
+ if (Polycasso.DEBUG) {
+ System.out.println("Generation " + generationNumber + " had " + annealingReplacements + " annealing replacements with annealing value: " + annealingValue);
+ }
+ }
+
generation = nextGeneration;
eliteCutOff = generation.get(eliteSize-1).score;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2011-07-25 05:45:14 UTC (rev 234)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2011-07-25 07:08:03 UTC (rev 235)
@@ -28,7 +28,7 @@
/**
* enable some console debugging, and show the target image
*/
- public static final boolean DEBUG = false;
+ public static final boolean DEBUG = true;
/**
* the main entry point to the web start app
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2011-07-25 05:45:14 UTC (rev 234)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2011-07-25 07:08:03 UTC (rev 235)
@@ -47,7 +47,7 @@
generationSize = 40;
eliteSize = 10;
useAnnealing = true;
- startTemperature = 1;
+ startTemperature = 10;
coolingRate = 0.01;
maxImageSize = new Dimension(800, 600);
maxPolygons = 100;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2011-07-25 05:45:14 UTC (rev 234)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2011-07-25 07:08:03 UTC (rev 235)
@@ -47,7 +47,7 @@
pc.starttemperature = Annealing Starting Temperature
pc.starttemperature.tt = The average pixel error (color difference) that an inferior image can have to be accepted
pc.coolingrate = Annealing cooling rate
-pc.coolingrate.tt = How the average error is decreased on each generation
+pc.coolingrate.tt = How the average pixel error is decreased by multiplication on each generation
pc.imageoptions = Image Options
pc.maximagesize = Maximum Image Size
pc.width = Width
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|