Beispiel #1
0
def Start(Gbl=None, PopClass=Population, ObsClass=None, Capabilities='PCGFN'):
    " Launch function "
    if Gbl == None: Gbl = Scenario()
    if ObsClass == None:
        Observer = EO.EvolifeObserver(Gbl)  # Observer contains statistics
    Pop = PopClass(Gbl, Observer)
    BatchMode = Gbl.Parameter('BatchMode')

    if BatchMode:  # Non-graphic mode (for large-scale experiments)
        EB.Start(Pop.one_year, Observer)
    else:
        EW.Start(Pop.one_year, Observer, Capabilities=Capabilities)
    if not BatchMode: print("Bye.......")
    sleep(2.1)
    return
Beispiel #2
0
def Start(Gbl=None,
          PopClass=Patriotic_Population,
          ObsClass=None,
          Capabilities='FGCNP'):
    " Launch function "
    if Gbl == None: Gbl = Scenario()
    if ObsClass == None:
        Observer = EO.EvolifeObserver(Gbl)  # Observer contains statistics
    Pop = PopClass(Gbl, Observer)
    BatchMode = Gbl.Parameter('BatchMode')

    if BatchMode:
        EB.Start(Pop.one_year, Observer)
    else:
        EW.Start(Pop.one_year, Observer, Capabilities=Capabilities)
    if not BatchMode: print("Bye.......")
    sleep(2.1)
    return
Beispiel #3
0
def Start(Gbl = None, PopClass = Population, ObsClass = None, Capabilities = 'FGCNP'):
    " Launch function "
    if Gbl == None: Gbl = Scenario()
    if ObsClass == None: Observer = EO.EvolifeObserver(Gbl)	# Observer contains statistics
    Pop = PopClass(Gbl, Observer)
    BatchMode = Gbl.Parameter('BatchMode')
    if BatchMode:
        EB.Start(Pop.one_year, Observer)
    else:
        Views = []
        if 'F' in Capabilities:	Views.append(('Field', 500, 350))	# start with 'Field' window on screen
        if 'T' in Capabilities:	Views.append(('Trajectories', 500, 350))	# 'Trajectories' on screen
        if 'N' in Capabilities:	Views.append(('Network', 500, 150))	# 'Network' on screen
        Observer.recordInfo('DefaultViews',	Views)	# Evolife should start with these window open
        EW.Start(Pop.one_year, Observer, Capabilities=Capabilities, Options=[('Background','green11')])
    if not BatchMode:	print("Bye.......")
    time.sleep(2.1)	
    return
                NewState = self.EvolveCell(C)
            self.VPosition += 1
            return True
        return False


if __name__ == "__main__":
    print(__doc__)

    #############################
    # Global objects			#
    #############################
    Scenario = CA_Scenario('_Params.evo')

    CAutomaton = Automaton(Scenario)  # logical settlement grid

    Observer = EO.Generic_Observer()  # Observer records display orders
    Observer.recordInfo('FieldWallpaper', 'white')
    margin = 4  # horizontal margins in the window
    zoom = 4
    Observer.recordInfo('DefaultViews',
                        [('Field', CAutomaton.Size * zoom + 2 * margin)])

    EW.Start(
        CAutomaton.OneStep, Observer, Capabilities='RP'
    )  # R means that only changed positions have to be displayed; P enables photos

    print("Bye.......")

__author__ = 'Dessalles'
Beispiel #5
0
        # calling local class
        return Individual(self.Scenario,
                          ID=self.free_ID(Prefix=''),
                          Newborn=Newborn)


class Population(EP.EvolifePopulation):
    " Calls local class when creating group "

    def createGroup(self, ID=0, Size=0):
        return Group(self.Scenario, ID=ID, Size=Size)  # local class


if __name__ == "__main__":
    Gbl = Scenario()
    Obs = EO.EvolifeObserver(Gbl)
    Pop = Population(Scenario=Gbl, Evolife_Obs=Obs)
    if Gbl['BatchMode'] == 0: print(__doc__)

    # launching windows
    # See Evolife_Window.py for details
    Capabilities = 'FGCP'  # F = 'Field'; G = 'Genomes'; C = 'Curves';
    Views = []
    if 'F' in Capabilities:
        Views.append(
            ('Field', 500, 350))  # start with 'Field' window on screen
    if 'T' in Capabilities:
        Views.append(('Trajectories', 500, 350))  # 'Trajectories' on screen
    Obs.recordInfo('DefaultViews',
                   Views)  # Evolife should start with these window open
    EW.Start(SimulationStep=Pop.one_year,
Beispiel #6
0
            # if Satisfactions:
            # self.Observer.curve(Name='Global Satisfaction', Value=sum([S for (C,S) in Satisfactions])/len(Satisfactions))

        if self.CallsSinceLastMove > 10 * self.popSize:
            return False  # situation is probably stable
        return True  # simulation goes on


if __name__ == "__main__":
    print(__doc__)

    #############################
    # Global objects            #
    #############################
    Gbl = Scenario()
    Observer = EO.Observer(Gbl)  # Observer contains statistics
    Land = Landscapes.Landscape(
        Gbl.Parameter('LandSize'))  # logical settlement grid
    Land.setAdmissible(Gbl.Colours)
    Pop = Population(Gbl, Observer)

    # Observer.recordInfo('Background', 'white')
    Observer.recordInfo('FieldWallpaper', 'white')

    # declaration of curves
    for Col in Gbl.Colours:
        Observer.curve(Name='%s Satisfaction' % str(Col),
                       Color=Col,
                       Legend='average satisfaction of %s individuals' %
                       str(Col))
    # Observer.curve(Name='Global Satisfaction', Color='black', Legend='average global satisfaction')
Beispiel #7
0
        # find last file
        CsvFiles = glob.glob('___Results/*.csv')
        if CsvFiles:
            CsvFiles.sort(key=lambda x: os.stat(x).st_mtime)
            Files = [CsvFiles[-1]]
    elif len(Args) > 3:
        print('''Usage:	%s <curve file name> [<constant config file name>]''' %
              os.path.basename(Args[0]))
    else:
        Files = glob.glob(Args[1])
        ConstantConfigFileName = Args[2] if (len(Args) == 3) else None
    for Argfile in Files:
        yield (Argfile, ConstantConfigFileName)


if __name__ == "__main__":
    for (Argfile, ConstantConfigFileName) in Parse(sys.argv):
        if Argfile:
            Observer = EO.Generic_Observer('')
            plot = Plot(Argfile, Observer, ConstantConfigFileName)
            print(plot.RelevantParam if plot.RelevantParam else plot.Cfg)
            Cap = 'CFP' if plot.FieldDisplay else 'CP'
            EW.Start(plot.one_plot,
                     plot.Obs,
                     Capabilities=Cap,
                     Options=[('Run', 'Yes'),
                              ('ExitOnEnd', 'No')])  # start Evolife display
            if plot.FieldDisplay: plot.save()

__author__ = 'Dessalles'
Beispiel #8
0
    if len(Land.ActiveCells) == 0: return False

    return True


if __name__ == "__main__":
    print(__doc__)

    #############################
    # Global objects			#
    #############################
    Gbl = EPar.Parameters(CfgFile='_Params.evo')
    Gbl.P = lambda x: Gbl.Parameter(x)  # to shorten writings

    Observer = EO.Experiment_Observer(Gbl)  # Observer contains statistics
    # Observer.recordInfo('Background', 'white')
    # Observer.recordInfo('FieldWallpaper', 'white')
    Observer.recordInfo('Background', 'white')
    PhysicalSize = Gbl.P('DotSize') * Gbl.P('LandSize')
    Observer.recordInfo('DefaultViews',
                        [('Field', PhysicalSize, PhysicalSize),
                         ('Trajectories', PhysicalSize, PhysicalSize)])
    Observer.record([(0, Gbl.P('LandSize'), 2, 0),
                     (Gbl.P('LandSize'), 0, 2, 0)])  # to resize
    Observer.record([(0, Gbl.P('LandSize'), 2, 0),
                     (Gbl.P('LandSize'), 0, 2, 0)],
                    Window='Trajectories')  # to resize

    Land = Landscape(Gbl.P('LandSize'), (Gbl.P('Da'), Gbl.P('Db')),
                     (Gbl.P('MaxA'), Gbl.P('MaxB')),
Beispiel #9
0
import sys
sys.path.append('')

import numpy as np
import time
import random
import math
import Evolife.QtGraphics.Evolife_Window as EW
import Evolife.Ecology.Observer as EO

######
# Actions :
#    0 : duck, 1 : do nothing 2 : jump

# constants
Obs = EO.Generic_Observer()
pop_size = 100
number_kept = 1
grid_length = 150
big_grid_length = 50
grid_width = 3
turns_predict = 2
n_inputs = grid_width * turns_predict + 1
n_outputs = 3
n_hidden = 10
first_pow = 0
number_grids = 1

gene_size = 3
dna_size = gene_size * (n_inputs + n_outputs) * n_hidden
mutation_rate = 0.005