# Commits

committed d969698

better bitwise crossover for floats

• Participants
• Parent commits 77e7994

# privateer_pyevolve/PrivateerCrossovers.py

mantissaMom, expMom = math.frexp(gMom[i])
-        mantissaMom = int(MANTISSA_DENOM*mantissaMom)
+        # import pdb; pdb.set_trace()
+
+        mantissaMom = int(mantissaMom*2.**(MANTISSA_BITS-baseExp+expMom))

#Not quite sure why i seem to need the -1 in here, but it makes me
#distrust the function
+          2.**(baseExp-MANTISSA_BITS)
-          2.**(expMom-MANTISSA_BITS-1)
-        # if abs(sister[i])>20 or abs(brother[i])>20:
-        #     import pdb; pdb.set_trace()
-        sister[i] = clip(sister[i],
-          gMom.getParam('rangemin'),
-          gMom.getParam('rangemax'))
-        brother[i] = clip(brother[i],
-          gMom.getParam('rangemin'),
-          gMom.getParam('rangemax'))
+          2.**(baseExp-MANTISSA_BITS)
+
+        # sister[i] = clip(sister[i],
+        #   gMom.getParam('rangemin'),
+        #   gMom.getParam('rangemax'))
+        # brother[i] = clip(brother[i],
+        #   gMom.getParam('rangemin'),
+        #   gMom.getParam('rangemax'))
+
return (sister, brother)

f=rndtrip(f)

def clip(f, lbound, ubound):
-    return min(max(f, lbound), ubound)
+    return min(max(f, lbound), ubound)

# privateer_pyevolve/privateer_sim.py

#genome.mutator.set(Mutators.G1DListMutatorRealRange)

# Crossover function must be set to something that can handle 1-elem list
-    genome.crossover.set(Crossovers.G1DListCrossoverUniform)
+    # genome.crossover.set(Crossovers.G1DListCrossoverUniform)
# genome.crossover.set(PrivateerCrossovers.G1DListCrossoverMean)
-    # genome.crossover.set(PrivateerCrossovers.G1DListCrossoverBitwise)
+    genome.crossover.set(PrivateerCrossovers.G1DListCrossoverBitwise)

# Genetic Algorithm Instance
ga_engine = GSimpleGA.GSimpleGA(genome,seed=seed)