Exemple #1
0
    def test_five_alpha_points(self):
        filename = os.path.join(self.csv_dir, 'test_five_alpha_points.csv')

        known_points_bottom = np.genfromtxt(filename,
                                            delimiter=',',
                                            usecols=(1))
        known_points_right = np.genfromtxt(filename,
                                           delimiter=',',
                                           usecols=(0))

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [
            6.632653061224477, 3.36734693877551
        ]
        adjusted_points.dist_range = 0.5

        right_points = adjusted_points._structured_training_points(
            compute_distance=True, source='right')
        right_plot = adjusted_points._right_plot()
        right_transparency = adjusted_points.right_alphas

        bottom_points = adjusted_points._structured_training_points(
            compute_distance=True, source='bottom')
        bottom_plot = adjusted_points._bottom_plot()
        bottom_transparency = adjusted_points.bottom_alphas

        assert_almost_equal(known_points_right, right_transparency, decimal=5)
        assert_almost_equal(known_points_bottom,
                            bottom_transparency,
                            decimal=5)
Exemple #2
0
    def test_in_between_training_points_bottom(self):

        known_points = np.array(
            [[-5.00000000e+00, 6.66666667e+00, 6.57596372e-02, 1.23408742e+02],
             [-5.00000000e+00, 8.33333333e+00, 4.53514739e-02, 9.11175424e+01],
             [-3.33333333e+00, 6.66666667e+00, 6.57596372e-02, 3.74658926e+01],
             [-3.33333333e+00, 8.33333333e+00, 4.53514739e-02, 1.99973985e+01],
             [-1.66666667e+00, 6.66666667e+00, 6.57596372e-02, 1.45787586e+01],
             [-1.66666667e+00, 8.33333333e+00, 4.53514739e-02, 9.54066442e+00],
             [0.00000000e+00, 6.66666667e+00, 6.57596372e-02, 2.00465571e+01],
             [0.00000000e+00, 8.33333333e+00, 4.53514739e-02, 2.50465571e+01],
             [1.66666667e+00, 6.66666667e+00, 6.57596372e-02, 1.78448388e+01],
             [1.66666667e+00, 8.33333333e+00, 4.53514739e-02, 3.04906272e+01],
             [3.33333333e+00, 6.66666667e+00, 6.57596372e-02, 2.11532161e+01],
             [3.33333333e+00, 8.33333333e+00, 4.53514739e-02, 3.90524872e+01],
             [5.00000000e+00, 6.66666667e+00, 6.57596372e-02, 4.18276351e+01],
             [5.00000000e+00, 8.33333333e+00, 4.53514739e-02, 6.25880832e+01],
             [6.66666667e+00, 6.66666667e+00, 6.57596372e-02, 4.95460339e+01],
             [6.66666667e+00, 8.33333333e+00, 4.53514739e-02, 7.07753532e+01],
             [8.33333333e+00, 6.66666667e+00, 6.57596372e-02, 3.01575160e+01],
             [8.33333333e+00, 8.33333333e+00, 4.53514739e-02, 4.94634008e+01],
             [1.00000000e+01, 6.66666667e+00, 6.57596372e-02, 1.53659121e+01],
             [1.00000000e+01, 8.33333333e+00, 4.53514739e-02, 3.03560567e+01]])

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [-5, 7.653061224489797]
        new_points = adjusted_points._structured_training_points(
            compute_distance=True, source='bottom')

        assert_almost_equal(known_points, new_points, decimal=5)
Exemple #3
0
    def test_in_between_training_points_right(self):

        known_points = np.array(
            [[0.00000000e+00, 0.00000000e+00, 5.44217687e-02, 5.56021126e+01],
             [0.00000000e+00, 1.66666667e+00, 5.44217687e-02, 3.83798904e+01],
             [0.00000000e+00, 3.33333333e+00, 5.44217687e-02, 2.67132238e+01],
             [0.00000000e+00, 5.00000000e+00, 5.44217687e-02, 2.06021126e+01],
             [0.00000000e+00, 6.66666667e+00, 5.44217687e-02, 2.00465571e+01],
             [0.00000000e+00, 8.33333333e+00, 5.44217687e-02, 2.50465571e+01],
             [0.00000000e+00, 1.00000000e+01, 5.44217687e-02, 3.56021126e+01],
             [0.00000000e+00, 1.16666667e+01, 5.44217687e-02, 5.17132237e+01],
             [0.00000000e+00, 1.33333333e+01, 5.44217687e-02, 7.33798904e+01],
             [0.00000000e+00, 1.50000000e+01, 5.44217687e-02, 1.00602113e+02],
             [1.66666667e+00, 0.00000000e+00, 5.66893424e-02, 2.28172406e+01],
             [1.66666667e+00, 1.66666667e+00, 5.66893424e-02, 1.32408069e+01],
             [1.66666667e+00, 3.33333333e+00, 5.66893424e-02, 9.21992860e+00],
             [1.66666667e+00, 5.00000000e+00, 5.66893424e-02, 1.07546059e+01],
             [1.66666667e+00, 6.66666667e+00, 5.66893424e-02, 1.78448388e+01],
             [1.66666667e+00, 8.33333333e+00, 5.66893424e-02, 3.04906272e+01],
             [1.66666667e+00, 1.00000000e+01, 5.66893424e-02, 4.86919712e+01],
             [1.66666667e+00, 1.16666667e+01, 5.66893424e-02, 7.24488707e+01],
             [1.66666667e+00, 1.33333333e+01, 5.66893424e-02, 1.01761326e+02],
             [1.66666667e+00, 1.50000000e+01, 5.66893424e-02, 1.36629336e+02]])

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [0.8163265306122387, 0.0]
        new_points = adjusted_points._structured_training_points(
            compute_distance=True, source='right')

        assert_almost_equal(known_points, new_points, decimal=5)
Exemple #4
0
    def test_aligned_training_points(self):

        known_points_right = np.array([[10., 0., 0., 10.96088904],
                                       [10., 1.66666667, 0., 3.72881146],
                                       [10., 3.33333333, 0., 2.05228945],
                                       [10., 5., 0., 5.93132298],
                                       [10., 6.66666667, 0., 15.36591208],
                                       [10., 8.33333333, 0., 30.35605673],
                                       [10., 10., 0., 50.90175693],
                                       [10., 11.66666667, 0., 77.00301269],
                                       [10., 13.33333333, 0., 108.65982401],
                                       [10., 15., 0., 145.87219088]])

        known_points_bottom = np.array([[-5., 15., 0., 17.50829952],
                                        [-3.33333333, 15., 0., 5.67897804],
                                        [-1.66666667, 15., 0., 44.94384339],
                                        [0., 15., 0., 100.60211264],
                                        [1.66666667, 15., 0., 136.62933643],
                                        [3.33333333, 15., 0., 166.20512723],
                                        [5., 15., 0., 201.18543108],
                                        [6.66666667, 15., 0., 211.24818608],
                                        [8.33333333, 15., 0., 182.2424958],
                                        [10., 15., 0., 145.87219088]])

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [10, 15]
        right_points = adjusted_points._structured_training_points(
            compute_distance=True, source='right')
        bottom_points = adjusted_points._structured_training_points(
            compute_distance=True, source='bottom')

        # Make sure that arrays equal each other to the 8th decimal place
        assert_almost_equal(known_points_right, right_points, decimal=8)
        assert_almost_equal(known_points_bottom, bottom_points, decimal=8)
Exemple #5
0
    def test_single_line_of_alpha_points(self):

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [
            6.632653061224477, 3.36734693877551
        ]

        right_points = adjusted_points._structured_training_points(
            compute_distance=True, source='right')
        right_plot = adjusted_points._right_plot()

        bottom_points = adjusted_points._structured_training_points(
            compute_distance=True, source='bottom')
        bottom_plot = adjusted_points._bottom_plot()

        self.assertTrue(len(adjusted_points.right_alphas) == 10)
        self.assertTrue(len(adjusted_points.bottom_alphas) == 10)
    def test_alpha_transparency(self):

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [
            0.04203304, 2.043553874897959, 0.02435233
        ]
        adjusted_points.dist_range = 0.75

        known_points_right = np.array([
            0.86567989, 0.78348589, 0.639777, 0.62940986, 0.62587447,
            0.56152752, 0.50987878, 0.49376071, 0.48388914, 0.46630121,
            0.4640111, 0.45980945, 0.41160175, 0.39350227, 0.39026132,
            0.38265725, 0.38192591, 0.36878805, 0.34231505, 0.32336551,
            0.30383287, 0.29137243, 0.28730608, 0.2857517, 0.26159429,
            0.26053377, 0.22521007, 0.18561353, 0.17247835, 0.13633153,
            0.10337783, 0.10021358, 0.08660427, 0.08069668, 0.06691626,
            0.05474111, 0.04688808, 0.04670316, 0.01284643, 0.00901992,
            0.00842553, 0.00386693
        ])

        known_points_bottom = np.array([
            7.65526230e-01, 7.38928632e-01, 7.26005432e-01, 7.15400571e-01,
            6.49085815e-01, 6.40394477e-01, 6.28033520e-01, 6.13040213e-01,
            5.83063203e-01, 4.39487058e-01, 3.68150531e-01, 3.43219760e-01,
            3.23457593e-01, 2.99935268e-01, 2.52810393e-01, 2.44806774e-01,
            2.43471983e-01, 2.36658494e-01, 2.33785648e-01, 2.22517218e-01,
            2.08587699e-01, 1.99369532e-01, 1.95640614e-01, 1.80272528e-01,
            1.74355451e-01, 1.52993016e-01, 1.28729050e-01, 1.28385003e-01,
            1.28254220e-01, 1.05787985e-01, 1.01550282e-01, 8.44650788e-02,
            6.39578812e-02, 3.34477398e-02, 1.97405267e-02, 6.40957590e-04
        ])

        right_points = adjusted_points._unstructured_training_points(
            compute_distance=True, source='right')
        right_plot = adjusted_points._right_plot()
        right_transparency = adjusted_points.right_alphas

        bottom_points = adjusted_points._unstructured_training_points(
            compute_distance=True, source='bottom')
        bottom_plot = adjusted_points._bottom_plot()
        bottom_transparency = adjusted_points.bottom_alphas

        assert_rel_error(self, right_transparency, known_points_right, 1.1e-02)
        assert_rel_error(self, bottom_transparency, known_points_bottom,
                         1.6e-02)
Exemple #7
0
    def test_in_between_training_points_bottom(self):

        filename = os.path.join(self.csv_dir, 'unstructured_test_points_bottom.csv')

        known_points = np.genfromtxt(
            filename, delimiter=',', skip_header=1)
        known_points = np.delete(known_points, 2, 1)
        known_points = known_points[known_points[:,0].argsort()[::-1]]

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [0.04203304, 2.043553874897959, 0.02435233]
        adjusted_points.dist_range = 0.75

        new_points = adjusted_points._unstructured_training_points(compute_distance=True, source='bottom')
        new_points = np.delete(new_points, 2, 1)
        new_points = new_points[new_points[:,0].argsort()[::-1]]

        assert_almost_equal(known_points, new_points, decimal=4)
Exemple #8
0
    def test_in_between_training_points_right(self):

        filename = os.path.join(self.csv_dir, 'unstructured_test_points_right.csv')

        known_points = np.genfromtxt(
            filename, delimiter=',', skip_header=1)
        known_points = np.delete(known_points, 2, 1)
        known_points = known_points[known_points[:,1].argsort()[::-1]]

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [1.619333019591837, 0.01423411, 0.02435233]
        adjusted_points.dist_range = 0.75

        new_points = adjusted_points._unstructured_training_points(compute_distance=True, source='right')
        new_points = np.delete(new_points, 2, 1)
        new_points = new_points[new_points[:,1].argsort()[::-1]]

        assert_almost_equal(known_points, new_points, decimal=4)
Exemple #9
0
    def test_flip_inputs_aligned_points(self):

        known_points_right = np.array(
            [[6.66666667e+00, 0.00000000e+00, 2.26757370e-03, 2.01843121e+01],
             [6.66666667e+00, 1.66666667e+00, 2.26757370e-03, 1.91914092e+01],
             [6.66666667e+00, 3.33333333e+00, 2.26757370e-03, 2.37540619e+01],
             [6.66666667e+00, 5.00000000e+00, 2.26757370e-03, 3.38722701e+01],
             [6.66666667e+00, 6.66666667e+00, 2.26757370e-03, 4.95460339e+01],
             [6.66666667e+00, 8.33333333e+00, 2.26757370e-03, 7.07753532e+01],
             [6.66666667e+00, 1.00000000e+01, 2.26757370e-03, 9.75602281e+01],
             [6.66666667e+00, 1.16666667e+01, 2.26757370e-03, 1.29900659e+02],
             [6.66666667e+00, 1.33333333e+01, 2.26757370e-03, 1.67796645e+02],
             [6.66666667e+00, 1.50000000e+01, 2.26757370e-03, 2.11248186e+02]])

        known_points_bottom = np.array(
            [[-5.00000000e+00, 3.33333333e+00, 2.26757370e-03, 2.04657808e+02],
             [-3.33333333e+00, 3.33333333e+00, 2.26757370e-03, 8.90695473e+01],
             [-1.66666667e+00, 3.33333333e+00, 2.26757370e-03, 4.13216135e+01],
             [0.00000000e+00, 3.33333333e+00, 2.26757370e-03, 2.67132238e+01],
             [1.66666667e+00, 3.33333333e+00, 2.26757370e-03, 9.21992860e+00],
             [3.33333333e+00, 3.33333333e+00, 2.26757370e-03, 2.02134053e+00],
             [5.00000000e+00, 3.33333333e+00, 2.26757370e-03, 1.69734056e+01],
             [6.66666667e+00, 3.33333333e+00, 2.26757370e-03, 2.37540619e+01],
             [8.33333333e+00, 3.33333333e+00, 2.26757370e-03, 8.21241294e+00],
             [1.00000000e+01, 3.33333333e+00, 2.26757370e-03, 2.05228945e+00]])

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [
            6.632653061224477, 3.36734693877551
        ]
        right_points = adjusted_points._structured_training_points(
            compute_distance=True, source='right')
        bottom_points = adjusted_points._structured_training_points(
            compute_distance=True, source='bottom')

        assert_almost_equal(known_points_right, right_points, decimal=5)
        assert_almost_equal(known_points_bottom, bottom_points, decimal=5)
Exemple #10
0
    def test_updated_scatter_distance(self):

        filename = os.path.join(self.csv_dir, 'updated_scatter_distance.csv')

        known_points_bottom = np.genfromtxt(filename,
                                            delimiter=',',
                                            usecols=(5, 6, 7, 8))
        known_points_right = np.genfromtxt(filename,
                                           delimiter=',',
                                           usecols=(0, 1, 2, 3))

        adjusted_points = MetaModelVisualization(self.mm)
        adjusted_points.input_point_list = [
            6.632653061224477, 3.36734693877551
        ]
        adjusted_points.dist_range = 0.5

        right_points = adjusted_points._structured_training_points(
            compute_distance=True, source='right')
        bottom_points = adjusted_points._structured_training_points(
            compute_distance=True, source='bottom')

        assert_almost_equal(known_points_right, right_points, decimal=5)
        assert_almost_equal(known_points_bottom, bottom_points, decimal=5)