Beispiel #1
0
def ST_Sweep(points=25, alpha=0):
    """Finds the ESS of the standard cooperative dilemma game for every point in ST space. And makes a graph."""
    data = np.zeros((points, points))

    Ss = np.linspace(-1, 4, points)
    Ts = np.linspace(0, 5, points)

    ##Sweep thourgh ST space
    for i, S in enumerate(Ss):
        for j, T in enumerate(Ts):

            G = np.array([[1, S], [T, 0]])
            R = replicator.replicator(G,
                                      makeGraphs=False,
                                      printInfo=False,
                                      alpha=alpha)
            ##Level of cooperation
            c = R.finalState[0]
            f = R.finalFit
            data[i, j] = f

    pl.imshow(data,
              vmin=0,
              vmax=2.5,
              origin='lower',
              interpolation='nearest',
              extent=[Ss[0], Ss[-1], Ts[0], Ts[-1]])
    pl.xlabel('S')
    pl.ylabel('T')
    pl.colorbar()
Beispiel #2
0
def ST_Sweep( points = 25, alpha = 0 ):
	"""Finds the ESS of the standard cooperative dilemma game for every point in ST space. And makes a graph."""
	data = np.zeros( (points,points) )

	Ss = np.linspace( -1,4,points )
	Ts = np.linspace( 0,5,points )

	##Sweep thourgh ST space
	for i,S in enumerate( Ss ):
		for j,T in enumerate( Ts ):

			G = np.array([[1,S],[T,0]])
			R = replicator.replicator(G, makeGraphs = False, printInfo = False, alpha = alpha)
			##Level of cooperation
			c = R.finalState[0]
			f = R.finalFit
			data[i,j] = f

	pl.imshow( data, vmin = 0, vmax = 2.5, origin = 'lower', interpolation = 'nearest', extent = [ Ss[0],Ss[-1],Ts[0],Ts[-1] ] )
	pl.xlabel('S')
	pl.ylabel('T')
	pl.colorbar()
Beispiel #3
0
def randomGame( dim = 2 ):
	"""Analyses a random game with a give dimention"""
	G = np.array( [ [ random.random() for _i in xrange(dim) ] for _j in xrange(dim) ] )
	print "Game:",G
	R = replicator.replicator( G )
Beispiel #4
0
import tflearn
from replicator import replicator
import h5py
from tflearn.data_utils import random_sequence_from_textfile
from trainMeta import path, maxlen, batch_size, internal_size, dropout, run_name, redundancy, dataset_name

dataset = h5py.File(dataset_name, 'r')
X = dataset['X']
Y = dataset['Y']
char_idx = {k: v for k, v in enumerate(dataset['charvector'])}

m = replicator(char_idx)

for i in range(100):
    seed = random_sequence_from_textfile(path, maxlen)
    run_identifier = run_name + '_epoch' + str(i)
    m.fit(X,
          Y,
          validation_set=0.2,
          batch_size=batch_size,
          n_epoch=1,
          run_id=run_identifier)
    m.save(run_identifier + '.sqg')
    print "-- TESTING..."
    print "-- Test with temperature of 1.0 --"
    print m.generate(140, temperature=1.0, seq_seed=seed)
    print "-- Test with temperature of 0.5 --"
    print m.generate(140, temperature=0.5, seq_seed=seed)
Beispiel #5
0
# 4. MAKE A PERFORCE INTERFACE AND A "DEFECT TRACKER" FOR PERFORCE

p4_interface = p4.p4(client = ('p4dti-%s' % socket.gethostname()),
                     client_executable = config.p4_client_executable,
                     password = config.p4_password,
                     port = config.p4_port,
                     user = config.p4_user,
		     config_file = config.p4_config_file,
                     logger = config.logger)



# 5. MAKE THE REPLICATOR AND INITIALIZE IT

r = replicator.replicator(dt, p4_interface, config)


# A. REFERENCES
#
# [GDR 2000-09-13] "Replicator design"; Gareth Rees; Ravenbrook Limited;
# 2000-09-13;
# <http://www.ravenbrook.com/project/p4dti/version/2.4/design/replicator/>.
#
# [GDR 2001-03-14] "test_p4dti.py -- Test the P4DTI"; Gareth Rees;
# Ravenbrook Limited; 2001-03-14;
# <http://www.ravenbrook.com/project/p4dti/version/2.4/test/test_p4dti.py>.
#
# [GDR 2000-10-16] "Perforce Defect Tracking Integration Integrator's
# Guide"; Gareth Rees; Ravenbrook Limited; 2000-10-16;
# <http://www.ravenbrook.com/project/p4dti/version/2.4/manual/ig/>.