Commits

dan mackinlay committed 5177134

bring closer to Bob's actual standards

  • Participants
  • Parent commits e6601fc

Comments (0)

Files changed (3)

File risky_business/TODO.rst

 TODOs
 ======
 
-  * bitwise float merge - make it work better
-  * work out why the fittest candidate seems to be badly correlated with known best value
+  * bitwise float merge - make it work as a 1-point crossover
+  * work out why the fittest candidate seems to be badly correlated with known best value
+  * PArameterise everthing - number of lotteries, number of markets, number of agents, genome aprameters and so on 
+  * allow agents to choose not to play the game
+  *

File risky_business/market.py

 
 def value_of_one_trade(trader):
     "one round of market trading"
-    lottery = trader.choose_lottery([lotteries.get_lottery() for i in range(2)])
+    lottery = trader.choose_lottery([lotteries.get_lottery() for i in range(3)])
     return lottery.decide()
 
-def value_of_lifetime(genome, Klass=privateers.CARATrader, rounds=10):
+def value_of_lifetime(genome, Klass=privateers.CARATrader, rounds=1000):
     "several rounds of market trading"
     trader = Klass(genome)
     for round in range(rounds):

File risky_business/privateer_sim.py

 import PrivateerMutators
 
 import argparse
-
    
 def main():
     import privateers
     run_sim(trader_class, values.seed)
     
 def run_sim(trader_class, seed):
+    mean_fitness = []
+    peak_fitness = []
+    gamma_of_leader = []
+    median_gamma = []
     # Genome instance, 1D List of 1 element
+    population = 100
+    elitism_rate = .6*population
     genome = G1DList.G1DList(1)
-
+    generations = 1150
+    
     # Sets the range max and min of the 1D List
-    genome.setParams(rangemin=-20.0, rangemax=20.0)
+    genome.setParams(rangemin=-8.0, rangemax=8.0)
         
     genome.initializator.set(Initializators.G1DListInitializatorReal)
     
     # Set the selector method, the number of generations and
     # the termination criteria
         
-    ga_engine.setGenerations(500)
+    ga_engine.setGenerations(generations)
     
     #Don't check to convergence - it converges on false minima all the time
     # ga_engine.terminationCriteria.set(GSimplega_engine.ConvergenceCriteria)
     pop = ga_engine.getPopulation()
     pop.scaleMethod.set(Scaling.SigmaTruncScaling)
     
-    ga_engine.stepCallback.set(update_plot)
+    ga_engine.stepCallback.add(update_plot)
     
     ga_engine.setMutationRate(0.01)
-    # 
-    # ga_engine.setElitism(True)
-    # ga_engine.setElitismReplacement(80)
+    
+    ga_engine.setPopulationSize(population)
+    ga_engine.setElitism(True)
+    ga_engine.setElitismReplacement(elitism_rate)
     
     # # Sets the DB Adapter, the resetDB flag will make the Adapter recreate
     # # the database and erase all data every run, you should use this flag
     plot_line.set_xdata(genomes)
     plt.draw()
 
-    
     return False
 
+    
 if __name__ == "__main__":
    main()