Beispiel #1
0
    def PerformExperiment(cls, poolNumber=None):
        ''' Perform single experiment and save all possible results (album, gene pool of last population and summary with
        best and average fitnesses (other parameters are optional)

        :param poolNumber: int
            Set, if you want to start your experiment not from the random beginning, but from the saved progress.
        '''

        # Set up environment
        SetUpManager.SetUp()

        # Load population if experiment doesn't start from the random beginning.
        if poolNumber is not None:
            EvolutonaryAlgorithm.LoadPopulation("data/genePools/pool" +
                                                str(poolNumber) + ".txt")

        # Perform experiment
        EvolutonaryAlgorithm.Execute()

        # Create album
        album = AlbumWriter.AlbumFromAlgorithm(EvolutonaryAlgorithm)

        # Save results
        cls.SaveAlbum(album)
        cls.SaveGenePool()
        cls.AddSummaryToRegistry()

        # Increment counter (next experiment will have another number)
        cls.numberOfExperiment += 1
Beispiel #2
0
    def PerformExperiment(cls, poolNumber=None):

        # Set up environment
        SetUpManager.SetUp()

        # Load population if experiment doesn't start from the random beginning.
        if poolNumber is not None:
            EvolutonaryAlgorithm.LoadPopulation("data/genePools/pool" +
                                                str(poolNumber) + ".txt")

        # Perform experiment
        EvolutonaryAlgorithm.Execute()

        # Create album
        album = AlbumWriter.AlbumFromAlgorithm(EvolutonaryAlgorithm)

        # Save results
        cls.SaveAlbum(album)
        cls.SaveGenePool()
        cls.AddSummaryToRegistry()

        # Increment counter (next experiment will have another number)
        cls.numberOfExperiment += 1
import unittest
from addons.Tests.UnitTests.data_containers_test.a_tools.auxilary_classes import random_RecordOfCar, comparable_RecordOfCar
from Modules.Settings.set_up_manager import SetUpManager

SetUpManager.SetUpRadarRecord()

class TestSaveToFile(unittest.TestCase):

    def test_1(self):
        filename = "data/saved_roc.txt"
        file = open(filename, "w")
        file.close()

        roc1 = random_RecordOfCar()
        roc1.SaveToFile(filename)

        roc2 = comparable_RecordOfCar()
        file = open(filename, "r")
        lines = file.readlines()
        roc2.LoadFromLines(lines)

        self.assertEqual(roc1, roc2)

if __name__ == '__main__':
    unittest.main()
Beispiel #4
0
'''
TEST Displayer::PlayAlbum(self)
'''
from Modules.GUI.displayer import Displayer
from Modules.Simulation.map import Map
from Modules.General.general_tools import PathsManager
from Modules.Simulation.data_containers import Album
from Modules.Settings.set_up_manager import SetUpManager

import os

os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (100, 100)

SetUpManager.SetUp()

amap = Map()
amap.LoadFromFile(PathsManager.GetPath("map"))
adisplayer = Displayer
adisplayer.map = amap
album = Album()
album.LoadFromFile(PathsManager.GetPath("albums", "album1.txt"))
adisplayer.PlayAlbum(album)
Beispiel #5
0
'''
TEST CarTransformCalculator:NewTransform(cls, car, nextMove):
'''
from Modules.Settings.settings import *
import pygame as pg
from Modules.GUI.sprites import SBarrier, SCar
from Modules.Simulation.car_base import BaseCar
from Modules.Simulation.map import Map
# from test_helpers import test_Camera
from Modules.GUI.displayer import Camera
Vec = pg.math.Vector2
from Modules.General.general_tools import PathsManager
from Modules.General.general_types import Move
from Modules.Settings.set_up_manager import SetUpManager

SetUpManager.SetUpPathsManager()
SetUpManager.SetUpImagesManager()
SetUpManager.SetUpSRotatableRect()
SetUpManager.SetUpCarTransformCalculator()
SetUpManager.SetUpBarrier()
SetUpManager.SetUpMap()
SetUpManager.SetUpBaseCar()
SetUpManager.SetUpCamera()
'''
+) klasa Vector(Point) w point.py jako zwykly typedef
+) powinien miec value, ktore przyslania length
'''

#CAMERA
# cam = test_Camera(2300, 1400)
cam = Camera
Beispiel #6
0
'''
TEST - Barrier:CreateOriginalRect(self):
'''
import unittest
from Modules.Simulation.map import Barrier
from Modules.Simulation.geometry import Vector
from Modules.Settings.set_up_manager import SetUpManager

SetUpManager.SetUpPathsManager()
SetUpManager.SetUpImagesManager()
SetUpManager.SetUpBarrier()


class TestCreateOriginalRect(unittest.TestCase):
    def test_0(self):
        b1 = Barrier()
        b1.scale = Vector([2.1, 3.1])
        b1.CreateOriginalRect()
        self.assertEqual(b1.original_rect.bottomright, (67, 99))


if __name__ == '__main__':
    unittest.main()