Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''
Created on 16. apr. 2018
@author: mmpe
'''
import unittest
import numpy as np
from topfarm import TopFarm
class Test(unittest.TestCase):
def test_topfarm_with_dummy(self):
from cost_models.dummy import DummyCost, DummyCostPlotComp
eps = 1e-6
optimal = [(3, -3), (7, -7), (4, -3), (3, -7)]
initial = [[6, 0], [6, -8], [1, 1], [-1, -8]]
boundary = [(0, 0), (6, 0), (6, -10), (0, -10)]
plot = False
plot_comp = None
if plot:
plot_comp = DummyCostPlotComp(optimal)
tf = TopFarm(initial, DummyCost(optimal), 2, boundary=boundary, plot_comp=plot_comp)
tf.evaluate()
tf.optimize()
tb_pos = tf.get_turbine_positions()
self.assertGreater(sum((tb_pos[2] - tb_pos[0])**2), 2**2 - eps)
np.testing.assert_array_almost_equal(tb_pos[3], optimal[3], 3)
self.assertLess(tb_pos[1][0], 6 + eps)
if plot:
plot_comp.show()
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.test_topfarm']
unittest.main()