예제 #1
0
 def __init__(self):
     environment_name = "MountainCar-v0"
     environment      = self.makeEnvironment(environment_name=environment_name)
     print(type(environment))
     self.model = Model( seed=42,
                         environment=environment,
                         environment_name=environment_name,
                         max_frames=300,
                         nr_of_workers=1,
                         pop_size=300,
                         hidden_shape=((6,),),
                         c1=1.0,
                         c2=1.0,
                         c3=0.4,
                         dt=3.0,
                         prob_add_link=0.1,
                         prob_add_node=0.03,
                         prob_mut_weights=0.8,
                         prob_mut_uniform=0.9,
                         prob_interspecies_mating=0.001,
                         elitism=0.2,
                         cppn_output_range=1.0,
                         cppn_weight_range=3.0,
                         function_set=[ '0.3989422804*np.exp(np.array(-0.5*({})).clip(min=-100,max=100))', #gaussian
                                        '1/(1+np.exp(np.array({}).clip(min=-100,max=100)))',            #sigmoid
                                        'np.sin({})',                     #sine
                                        'np.absolute({})'                      #absolute value
                                        ],
                         activation_function=(lambda x: x.clip(min=0))      #RELU
                         )
예제 #2
0
def update_post():
    '''This is the route to update the number shown on the view'''

    print('updating the model with the new number from a POST request')
    model = Model(request.form['number'])

    print('updating the view with the new model')
    return render_template('view.html', data=model)
예제 #3
0
def index():
    '''This is the default landing page'''

    print('instantiating a default model')
    model = Model()

    print('updating default view with default model')
    return render_template('view.html', data=model)
예제 #4
0
파일: test.py 프로젝트: jkopec/CSV-IO
 def setUp(self):
     self.model = Model()
예제 #5
0
파일: test.py 프로젝트: jkopec/CSV-IO
class Tests(unittest.TestCase):

    def setUp(self):
        self.model = Model()

    def test_load(self):
        try:
            self.model.loadCSV()
        except IOError as e:
            self.fail("Couldn't load CSV-file!\n%s" % e)

    def test_save(self):
        try:
            self.model.saveCSV("")
        except IOError as e:
            self.fail("Couldn't save CSV-file!\n%s" % e)

    def test_replaceText(self):
        try:
            self.model.saveCSV("some;text;")
            text = self.model.loadCSV()
            assert text == "some;text;\n", "Replacing old text with 'some;text;' in CSV file failed!"
        except IOError as e:
            self.fail("Couldn't load CSV-file!\n%s" % e)

    def test_addText(self):
        try:
            added_text = "some;text;"
            old_text = self.model.loadCSV()
            self.model.saveCSV(old_text+added_text)
            new_text = self.model.loadCSV()
            self.assertTrue(new_text == old_text+added_text+"\n", "Replacing old text with 'some;text;' in CSV file failed!")
        except IOError as e:
            self.fail("Couldn't load CSV-file!\n%s" % e)

    def test_linebreaks(self):
        try:
            asserted_text = "some;\ntext;"
            added_text = "some;\n\n\n\n\ntext;"
            old_text = self.model.loadCSV()
            self.model.saveCSV(old_text+added_text)
            new_text = self.model.loadCSV()
            self.assertFalse(new_text == old_text+added_text, "Blank lines shouldn't be saved!")
            self.assertTrue(new_text == old_text+asserted_text+"\n",   "Blank lines shouldn't be saved!")
        except IOError as e:
            self.fail("Couldn't load CSV-file!\n%s" % e)

    def tearDown(self):
        try:
            self.model.saveCSV("")
        except IOError as e:
            self.fail("Couldn't clean CSV-file!\n%s" % e)