1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
From: Christian Kastner <debian@kvr.at>
Date: Mon, 28 Jun 2010 15:17:11 +0200
Subject: [PATCH] Fix broken example 12
Psyco is not available on 64-bit systems, so we transfer a hard import
requirement to a soft one. Also, the example attempts to use a directory
which does not exist.
Forwarded: yes
Last-Update: 2010-06-28
---
examples/pyevolve_ex12_tsp.py | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/examples/pyevolve_ex12_tsp.py b/examples/pyevolve_ex12_tsp.py
index 385bf46..2a4c5b8 100644
--- a/examples/pyevolve_ex12_tsp.py
+++ b/examples/pyevolve_ex12_tsp.py
@@ -5,9 +5,11 @@ from pyevolve import Crossovers
from pyevolve import Consts
import sys, random
+import os
random.seed(1024)
from math import sqrt
+
PIL_SUPPORT = None
try:
@@ -104,6 +106,13 @@ def main_run():
genome.crossover.set(Crossovers.G1DListCrossoverEdge)
genome.initializator.set(G1DListTSPInitializator)
+ if not os.path.isdir("tspimg"):
+ try:
+ os.mkdir("tspimg")
+ except:
+ print "Could not create directory tspimg"
+ return
+
# 3662.69
ga = GSimpleGA.GSimpleGA(genome)
ga.setGenerations(200000)
@@ -115,8 +124,13 @@ def main_run():
# This is to make a video
ga.stepCallback.set(evolve_callback)
# 21666.49
- import psyco
- psyco.full()
+
+ # Don't fail on 64-bit
+ try:
+ import psyco
+ psyco.full()
+ except ImportError:
+ pass
ga.evolve(freq_stats=500)
best = ga.bestIndividual()
--
|