Commits

dan mackinlay committed c445417

move all risk-aversion-agents code into the newly named project "risky business"

  • Participants
  • Parent commits 9c5be17

Comments (0)

Files changed (32)

File privateer_pyevolve/PrivateerCrossovers.py

-from __future__ import division
-import random
-import math
-from bitwise_utils import MANTISSA_BITS, bitcross
-
-def G1DListCrossoverMean(genome, **args):
-    """Ultra-stupid crossover taking the mean of both parents. Not very useful -
-    AFAICT it results in pressure to converge to the population mean rather than
-    to the solution."""
-
-    sister = None
-    brother = None
-    gMom = args["mom"]
-    gDad = args["dad"]
-
-    sister = gMom.clone()
-    brother = gDad.clone()
-    sister.resetStats()
-    brother.resetStats()
-
-    for i in xrange(len(gMom)):
-      sister[i] = brother[i] = (gMom[i]+gDad[i])/2.0
-        
-    return (sister, brother)
-
-def bitcross(i1, i2, mask):
-    """return a new int, containing its chosen from i1 or i2 depending on whther the mask string is 1 or 0"""
-    return (i1 & mask) | (i2 & ~mask)
-    
-def G1DListCrossoverBitwise(genome, **args):
-    """bitwise uniform crossover for floats. Warning, potentially breaks range
-    constraints."""
-    sister = None
-    brother = None
-    gMom = args["mom"]
-    gDad = args["dad"]
-
-    sister = gMom.clone()
-    brother = gDad.clone()
-    sister.resetStats()
-    brother.resetStats()
-    
-    for i in xrange(len(gMom)):
-        mask = random.getrandbits(MANTISSA_BITS) 
-        mantissaDad, expDad = math.frexp(gDad[i])
-        mantissaMom, expMom = math.frexp(gMom[i])
-        baseExp = max(expMom, expDad)
-        # import pdb; pdb.set_trace()
-        
-        mantissaDad = int(mantissaDad*2.**(MANTISSA_BITS-baseExp+expDad))
-        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
-        sister[i] = bitcross(mantissaDad, mantissaMom, mask) *\
-          2.**(baseExp-MANTISSA_BITS)
-        brother[i] = bitcross(mantissaMom, mantissaDad, mask) *\
-          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)
-
-
-########
-def test_mantissa_mathematics():
-    """does all my mantisssa maths work? well, if this is stable it does"""
-    def rndtrip(f): return int((2<<53)*f)/float(2<<53)
-    f=1.0/3.0
-    for i in range(100):
-       print f.hex()
-       f=rndtrip(f)
-
-def clip(f, lbound, ubound):
-    return min(max(f, lbound), ubound)

File privateer_pyevolve/PrivateerMutators.py

-from __future__ import division
-import random
-import math
-import sys
-from bitwise_utils import MANTISSA_BITS, bitcross, clip
-from pyevolve import Util
-from pyevolve import Consts
-
-def G1DListMutatorRealPseudoBitwiseAuto(genome, **args):
-    """ The mutator of G1DList, pseudo-bitwise Mutator. only permute sign and mantissa. Careful about using this to converge to zero, since mutation size decreases as the mutation rate does
-    """
-    if args["pmut"] <= 0.0: return 0
-    mutations = int(random.expovariate(1./args["pmut"])*53. + 0.5)
-
-    for it in range(mutations):
-        listSize = len(genome)
-        target_i = random.randint(0, listSize-1)
-        source = genome[target_i]
-        
-        if  Util.randomFlipCoin(1/53.):
-            #sign flip
-            genome[target_i] *= -1
-            continue
-        #else
-        delta_exp_ceiling = math.frexp(source)[1]
-        delta_exp = delta_exp_ceiling-random.randint(0,52)
-        if delta_exp < sys.float_info.min_exp:
-            continue
-        delta = 2.**(delta_exp)
-        delta *= (2.*random.randint(0, 1)-1)
-        print "delta:", delta
-        final_value = source + delta
-        final_value = min(final_value, genome.getParam("rangemax", Consts.CDefRangeMax))
-        final_value = max(final_value, genome.getParam("rangemin", Consts.CDefRangeMin))
-        genome[target_i] = final_value
-        
-    return mutations
-    
-def G1DListMutatorRealPseudoBitwise(genome, **args):
-    """ The mutator of G1DList, pseudo-bitwise Mutator. Gets range from genome
-    properties
-    """
-    if args["pmut"] <= 0.0: return 0
-    mutations = int(random.expovariate(1./args["pmut"])*53. + 0.5)
-
-    delta_exp_ceiling = math.frexp(
-      genome.getParam("rangemax", Consts.CDefRangeMax)-
-      genome.getParam("rangemin", Consts.CDefRangeMax)
-    )[1]
-
-    for it in range(mutations):
-        listSize = len(genome)
-        target_i = random.randint(0, listSize-1)
-        source = genome[target_i]
-        
-        if  Util.randomFlipCoin(1/53.):
-            #sign flip
-            genome[target_i] *= -1
-            continue
-        #else
-        delta_exp = delta_exp_ceiling-random.randint(0,52)
-        if delta_exp < sys.float_info.min_exp:
-            continue
-        delta = 2.**(delta_exp)
-        delta *= (2.*random.randint(0, 1)-1)
-        print "delta:", delta
-        final_value = source + delta
-        final_value = min(final_value, genome.getParam("rangemax", Consts.CDefRangeMax))
-        final_value = max(final_value, genome.getParam("rangemin", Consts.CDefRangeMin))
-        genome[target_i] = final_value
-        
-    return mutations

File privateer_pyevolve/__init__.py

Empty file removed.

File privateer_pyevolve/bitwise_utils.py

-from __future__ import division
-import random
-import math
-
-TOTAL_BITS = 64
-MANTISSA_BITS = 53 #max python 64 bit mantissa size
-MANTISSA_DENOM = 2<<MANTISSA_BITS
-
-def bitcross(i1, i2, mask):
-    """return a new int, containing its chosen from i1 or i2 depending on whther the mask string is 1 or 0"""
-    return (i1 & mask) | (i2 & ~mask)
-
-def test_mantissa_mathematics():
-    """does all my mantisssa maths work? well, if this is stable it does"""
-    def rndtrip(f): return int((2<<53)*f)/float(2<<53)
-    f=1.0/3.0
-    for i in range(100):
-       print f.hex()
-       f=rndtrip(f)
-
-def clip(f, lbound, ubound):
-    return min(max(f, lbound), ubound)
-
-def float2bitsNexp(f):
-    """
-    we want to flip float bits contextually, i.e. not using the whole range of the float. a bit flip is only allowed to at most double the magnitufe of the thing.
-    doesn't work yet
-    """
-    mantissa, fexp = math.frexp(f)
-    mantissa = int(mantissa * 2.**(MANTISSA_BITS + 1))
-    
-
-def bits2float(mantissa, exp):
-    """doesn't work yet"""
-    pass

File privateer_pyevolve/lotteries.py

-#!/usr/bin/env python
-# encoding: utf-8
-"""
-market.py
-
-Created by dan mackinlay on 2010-09-24.
-Copyright (c) 2010 __MyCompanyName__. All rights reserved.
-"""
-
-import random  
-from math import sqrt
-# DEFAULT_RNG = random.Random(seed=7) - #Don't do this w/out setting a seed or it causes the system RNG to take a new seed from clock.
-DEFAULT_RNG = random
-
-class Lottery(dict):
-    """
-    A namespace into which to stash information about this particular type of lottery. Lotteries are just dicts of fn variables
-    """
-    def __init__(self, *args, **kwargs):
-        super(Lottery, self).__init__(*args, **kwargs)
-    
-    def decide(self, *args, **kwargs):
-        raise NotImplementedError
-    
-    def std_dev(self, *args, **kwargs):
-        raise NotImplementedError
-    
-    def expectation(self, *args, **kwargs):
-        raise NotImplementedError
-
-class WeightedCoinToss(Lottery):
-    """
-    toss a biased coin and return either the lower or upper bound
-    should have keys of 'upper', 'lower' and 0<'lowerweight'<1
-    """
-        
-    def decide(self, *args, **kwargs):
-        rng = self.get('rng', DEFAULT_RNG)
-        return self['lower'] if rng.random()<self['lowerweight'] else self['upper']
-    
-    def expectation(self, *args, **kwargs):
-        return (self['lower']*self['lowerweight'] +
-           self['upper']*(1-self['lowerweight']))
-
-class UniformLottery(Lottery):
-    """
-    toss a coin and return either the lower or upper bound
-    should have keys.upper and keys.lower
-    
-    Not currently used
-    """
-    def decide(self, *args, **kwargs):
-        rng = self.get('rng', DEFAULT_RNG)
-        return rng.random()*(self['upper']-self['lower'])+self['lower']
-    
-    def std_dev(self, *args, **kwargs):
-        return (self['upper'] - self['lower'])/(2.0*sqrt(3))
-    
-    def expectation(self, *args, **kwargs):
-        return (self['lower']+self['lower'])*0.5
-
-
-def get_lottery(max_abs_prize_val=10, rng=None):
-    if rng is None:
-        rng=DEFAULT_RNG
-    return WeightedCoinToss(
-        lower=max_abs_prize_val*(2*rng.random()-1),
-        upper=max_abs_prize_val*(2*rng.random()-1),
-        lowerweight=rng.random()
-    )
-
-      
-    
-    

File privateer_pyevolve/market.py

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

File privateer_pyevolve/plot.py

-import matplotlib.pyplot as plt
-#from random import choice, shuffle
-from pylab import clf
-
-def draw_graph(self):
-
-  #carrying_edges =[(u,v) for (u,v,d) in self.dag.edges(data=True) if d['carrying_info'] == True and d['sender'] == True]
-  #noncarrying_edges =[(u,v) for (u,v,d) in self.dag.edges(data=True) if d['carrying_info'] == False and d['sender'] == True]
-  #nonsending =[(u,v) for (u,v,d) in self.dag.edges(data=True) if d['sender'] == False]
-
-  pos = nx.shell_layout(self.dag)
-
-  nx.draw_networkx_nodes(self.dag,pos,node_size=150, nodelist=self.others, node_color='aquamarine')
-  nx.draw_networkx_nodes(self.dag,pos,node_size=300, nodelist=[self.focal], node_color='red')
-  nx.draw_networkx_nodes(self.dag,pos,node_size=300, nodelist=self.focal_neighbors, node_color='orange')
-
-  sender_nodes = [node for node in self.dag.nodes() if self.dag.node[node]['sender'] == True]
-  nx.draw_networkx_nodes(self.dag,pos,node_size=300, nodelist=sender_nodes, node_color='purple')
-
-  true_gossip_nodes = []
-  false_gossip_nodes = []
-  for node in self.dag.nodes():
-    try:
-      if self.dag.node[node]['gossip'] == True:
-        true_gossip_nodes.append(node)
-      elif self.dag.node[node]['gossip'] == False:
-        false_gossip_nodes.append(node)
-    except KeyError:
-      pass
-
-  nx.draw_networkx_nodes(self.dag,pos,node_size=300, 
-            nodelist=true_gossip_nodes, node_color='white',
-            node_shape='d')
-  nx.draw_networkx_nodes(self.dag,pos,node_size=300, 
-            nodelist=false_gossip_nodes, node_color='grey',
-            node_shape='d')
-
-  nx.draw_networkx_edges(self.dag,pos,edgelist=self.dag.edges(),
-                      width=1, edge_color='b', alpha=0.5, arrows=True)
-  nx.draw_networkx_edges(self.dag,pos,edgelist=self.removed_edges,
-                      width=1, edge_color='cyan', alpha=0.5, arrows=False, style='dotted')
-  nx.draw_networkx_edges(self.dag,pos,edgelist=self.observer_edges,
-                      width=1, edge_color='red', alpha=0.5, arrows=False, style='dotted')
-  #nx.draw_networkx_edges(self.dag,pos,edgelist=carrying_edges,
-  #                    width=1, edge_color='g', alpha=0.5, arrows=True)
-  #nx.draw_networkx_edges(self.dag,pos,edgelist=noncarrying_edges,
-  #                    width=1,alpha=0.5,edge_color='b',style='dashed', 
-  #                    arrows=True)
-
-  #nx.draw_networkx_edges(self.dag,pos,edgelist=nonsending,
-  #                    width=3,alpha=0.5,edge_color='r',style='dotted',
-  #                    arrows=True)
-
-  nx.draw_networkx_labels(self.dag,pos,font_size=14,font_family='sans-serif')
-
-  plt.axis('off')
-
-def record_graph_intermediates(self, outfile, iter):
-  clf()
-  self.draw_graph()
-  plt.savefig("%s-%03d.png" % (outfile, iter))
-
-def animate_graph(self, movie, pngfiles='animation', fps=2):
-
-  try:
-    os.remove(movie)
-  except OSError:
-    pass
-
-  command = 'ffmpeg -i %s-' % pngfiles + r'%03d.png ' + '-r %s ' % fps + movie
-  print command
-  os.system(command)

File privateer_pyevolve/privateer_sim.py

-# encoding: utf-8
-"""
-
-.. module:: privateer_sim
-   :synopsis: actual sim worker
-
-.. moduleauthor:: Dan MacKinlay <fillmewithspam@email.possumpalace.org>
-
-"""
-from pyevolve import G1DList
-from pyevolve import GSimpleGA
-from pyevolve import Selectors
-from pyevolve import Statistics
-# from pyevolve import DBAdapters
-from pyevolve import Selectors, Crossovers, Consts, Initializators, Mutators, Scaling
-
-
-import numpy as np
-import matplotlib.pyplot as plt
-import market
-import PrivateerCrossovers
-import PrivateerMutators
-
-import argparse
-
-   
-def main():
-    import privateers
-    parser = argparse.ArgumentParser(description="simulate some traders in a  stochastic market")
-    parser.add_argument('--trader-class', help='Trader class name', default='CARATrader' )
-    parser.add_argument('--seed', help='seed value', default=None )
-    values = parser.parse_args()
-    trader_class = getattr(privateers, values.trader_class)
-    run_sim(trader_class, values.seed)
-    
-def run_sim(trader_class, seed):
-    # Genome instance, 1D List of 1 element
-    genome = G1DList.G1DList(1)
-
-    # Sets the range max and min of the 1D List
-    genome.setParams(rangemin=-20.0, rangemax=20.0)
-        
-    genome.initializator.set(Initializators.G1DListInitializatorReal)
-    
-    # The evaluator function (evaluation function)
-    def value_of_lifetime(gen):        
-        return market.value_of_lifetime(gen, Klass=trader_class)
-    
-    genome.evaluator.set(value_of_lifetime)
-    
-    # Mutator function 
-    # genome.mutator.set(Mutators.G1DListMutatorRealGaussian)
-    # genome.mutator.set(Mutators.G1DListMutatorRealRange)
-    genome.mutator.set(PrivateerMutators.G1DListMutatorRealPseudoBitwise)
-    
-    # Crossover function must be set to something that can handle 1-elem list
-    # genome.crossover.set(Crossovers.G1DListCrossoverUniform)
-    # genome.crossover.set(PrivateerCrossovers.G1DListCrossoverMean)
-    genome.crossover.set(PrivateerCrossovers.G1DListCrossoverBitwise)
-    
-    # Genetic Algorithm Instance
-    ga_engine = GSimpleGA.GSimpleGA(genome,seed=seed)
-
-    ga_engine.selector.set(Selectors.GTournamentSelector)
-    # ga_engine.selector.set(Selectors.GRouletteWheel)
-    #ga_engine.selector.set(Selectors.GTournamentSelectorAlternative)
-
-    # Set the selector method, the number of generations and
-    # the termination criteria
-        
-    ga_engine.setGenerations(500)
-    
-    #Don't check to convergence - it converges on false minima all the time
-    # ga_engine.terminationCriteria.set(GSimplega_engine.ConvergenceCriteria)
-    
-    ga_engine.setMinimax(Consts.minimaxType["maximize"])
-    
-    pop = ga_engine.getPopulation()
-    pop.scaleMethod.set(Scaling.SigmaTruncScaling)
-    
-    ga_engine.stepCallback.set(update_plot)
-    
-    ga_engine.setMutationRate(0.01)
-    # 
-    # ga_engine.setElitism(True)
-    # ga_engine.setElitismReplacement(80)
-    
-    # # 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
-    # # just in the first time, after the pyevolve.db was created, you can
-    # # omit it.
-    # sqlite_adapter = DBAdapters.DBSQLite(identify="ex1", resetDB=True)
-    # ga_engine.setDBAdapter(sqlite_adapter)
-    
-    # ga_engine.setInteractiveMode(True)
-    
-    # Do the evolution, with stats dump
-    # frequency of 20 generations
-    ga_engine.evolve(freq_stats=0)
-    
-    # Best individual
-    print ga_engine.bestIndividual()
-
-
-plot_line = None
-plt.ion()
-
-def update_plot(ga_engine):
-    global plot_line
-    generation = ga_engine.getCurrentGeneration()
-
-    # import pdb; pdb.set_trace()
-    genomes = []
-    fitnesses = []
-    
-    for individual in ga_engine.getPopulation():
-        genomes.append(individual.genomeList[0])
-        fitnesses.append(individual.fitness)
-    # plt.clf()
-    # series = plt.gca().lines
-    # if len(series): del(series[0])
-    
-    if plot_line is None:
-        plot_line, = plt.plot(genomes, fitnesses)
-    plot_line.set_ydata(fitnesses)
-    plot_line.set_xdata(genomes)
-    plt.draw()
-
-    
-    return False
-
-if __name__ == "__main__":
-   main()
-
-    

File privateer_pyevolve/privateers.py

-from math import exp
-
-class Trader(object):
-    """encapsulate trader logic"""
-    def __init__(self, genome, *args, **kwargs):
-        super(Trader, self).__init__(*args, **kwargs)
-        self.genome = genome
-        self.wealth = 0
-    
-    def utility_of_lottery(self, lottery):
-        raise NotImplementedError
-    
-    def choose_lottery(self, lottery_list):
-        """look through a list of lotteries and choose the best one by my
-        utility function
-        
-        In fact, although this is written for arbitrary lists, it shouldn't be
-        used for lists of length>2, since that reduces selection pressure on
-        the utility function. Pfff."""
-        chosen = lottery_list.pop()
-        best_utility = self.utility_of_lottery(chosen)
-        for next_lottery in lottery_list:
-            next_utility = self.utility_of_lottery(next_lottery)
-            if next_utility>best_utility:
-                best_utility = next_utility
-                chosen = next_lottery
-        return chosen
-
-""";;; Bob Mark's reference impementation of CARA payoff values from
-;;; http://www.agsm.edu.au/bobm/teaching/SimSS/NetLogo4-models/RA-CARA-EU-3l2p.html
-;;;
-
-to-report lottery-values ; turtle procedure. Set up two three-outcome lotteries, where 
-                 ; each outcome is chosen randomly from [-10 +10], and the
-                 ; two probabilities of each of lottery are chosen.
-                 ; Calculate the mean and variance of the lotteries, and
-                 ; an outcome of the lotteries. The agent (turtle) chooses one of the
-                 ; two lotteries, based on a mean-variance ranking, which assumes a normal
-                 ; distribution for each lottery and an exponential (constant
-                 ; risk-profile) utility function.  The agent's fitness is its final
-                 ; wealth after N choices. If an agent's wealth falls below -10, then
-                 ; the agent becomes bankrupt, and "dies".  Each agent starts with an
-                 ; endowment of 50, before facing N pairs of lotteries to choose between.
-  
-   setup-prizes
-   create-lottery
-   ;; let lmean (((item 0 prizes) * (item 0 lottery)) + 
-             ;; ( (item 1 prizes) * (item 1 lottery)) )
-   ;; let lvar ((((item 0 prizes) - lmean) ^ 2) * (item 0 lottery) + 
-             ;; (((item 1 prizes) - lmean) ^ 2) * (item 1 lottery))
-   let utprize1      (1 - e ^ (- gamma * (item 0 prizes)))
-   let utprize2      (1 - e ^ (- gamma * (item 1 prizes)))
-   let exputil ((item 0 lottery) * utprize1) + ((item 1 lottery) * utprize2)               
-   let l-prob random-float 1
-   let act-val-lot   
-     ifelse-value (l-prob <= (item 0 lottery))
-        [(item 0 prizes)]
-        [ (item 1 prizes)]   
-    report (list  exputil act-val-lot  )   
-end
-
-to create-lottery
-  let probabilities n-values 2 [random-float 1]
-  let sum-of-probabilities (sum probabilities)
-  set lottery map [? / sum-of-probabilities] probabilities
-  ;; lottery is a list of two random probs summing to 1
-end
-
-to-report payoff    ;; turtle procedure. Choose the highest-utility lottery of three
- let lot1 lottery-values
- let lot2 lottery-values
- let lot3 lottery-values
- report ifelse-value (item 0 lot1 >= item 0 lot2)
-   [ifelse-value (item 0 lot1 >= item 0 lot3)
-     [(item 1 lot1)]
-     [(item 1 lot3)]]
-   [ifelse-value (item 0 lot2 >= item 0 lot3) 
-     [(item 1 lot2)]
-     [(item 1 lot3)]]
-   
-end"""
-
-class CARATrader(Trader):
-    """encapsulate trader logic"""
-    
-    def utility_of_lottery(self, lottery):
-        return cara_utility_of_lottery(self.genome, lottery)
-
-def cara_utility_of_prize(gamma, prize):
-    return (1.0 - exp(-gamma * prize))
-
-def cara_utility_of_lottery(genome, lottery):
-    [gamma] = genome
-    return cara_utility_of_prize(gamma, lottery['lower']) *\
-       lottery['lowerweight'] +\
-           cara_utility_of_prize(gamma, lottery['upper']) *\
-       (1.0-lottery['lowerweight'])
-
-
-
-""";;; The CRRA version of the aforementioned
-
-to-report lottery-values ; turtle procedure. Set up two three-outcome lotteries, where 
-                 ; each outcome is chosen randomly from [-10 +10], and the
-                 ; two probabilities of each of lottery are chosen.
-                 ; Calculate the mean and variance of the lotteries, and
-                 ; an outcome of the lotteries. The agent (turtle) chooses one of the
-                 ; two lotteries, based on a mean-variance ranking, which assumes a normal
-                 ; distribution for each lottery and a CRRA utility function.  
-                 ; The agent's fitness is its final wealth after N choices.
-                 ; (Not yet: If an agent's wealth falls below -10, then
-                 ; the agent becomes bankrupt, and "dies".  Each agent starts with an
-                 ; endowment of 50, before facing N pairs of lotteries to choose between.)
-  
-   setup-prizes
-   create-lottery
-   let utprize1 ((fitness + (item 0 prizes)) ^ (1 - rho )) / (1 - rho )
-   let utprize2 ((fitness + (item 1 prizes)) ^ (1 - rho )) / (1 - rho )
-   let exputil ((item 0 lottery) * utprize1) + ((item 1 lottery) * utprize2)          
-   let l-prob random-float 1
-   let act-val-lot   
-     ifelse-value (l-prob <= (item 0 lottery))
-        [(item 0 prizes)]
-        [(item 1 prizes)]
-   ;; show act-val-lot         
-   report (list exputil act-val-lot  )  
-end
-
-
-to setup-prizes
-  set prizes 0
-  set prizes n-values 2 [max-abs-prize - random (2 * max-abs-prize + 1)] 
-    ;; two random prizes between -max-abs-prize and +max-abs-prize
-    ;; show prizes
-end
-
-to create-lottery
-  let probabilities 0
-  set probabilities n-values 2 [random-float 1]
-  let sum-of-probabilities (sum probabilities)
-  set lottery map [? / sum-of-probabilities] probabilities
-  ;; show lottery
-  ;; lottery is a list of two random probs summing to 1
-end
- 
-
-to-report payoff    ;; turtle procedure. Choose the highest-utility (CRRA) lottery of three
- let lot1 lottery-values
- let lot2 lottery-values
- let lot3 lottery-values
- report ifelse-value (item 0 lot1 >= item 0 lot2)
-   [ifelse-value (item 0 lot1 >= item 0 lot3)
-     [(item 1 lot1)  ]
-     [(item 1 lot3)  ]]
-   [ifelse-value (item 0 lot2 >= item 0 lot3) 
-     [(item 1 lot2) ]
-     [(item 1 lot3) ]]
-   
-end"""
-

File privateer_pyevolve/run_base.py

-# encoding: utf-8
-"""run a simultion of some traders
-
-.. moduleauthor:: Dan MacKinlay <fillmewithspam@email.possumpalace.org>
-
-"""
-
-import argparse
-import paver
-import paver.doctools
-import paver.misctasks
-from paver.path import path
-#from subprocess import call
-
-