コード例 #1
0
    def OptimAlgo(self):
        wind_tbl = pd.merge(self.data['wind'],
                            self.wind_dir,
                            how='left',
                            on='wind_dir').set_index(self.data['wind'].index)
        cannon = np.array(self.data['balloon'].iloc[0, :])
        cannon_0 = np.append(cannon, 0)
        enemy = np.array(self.data['cannon'].iloc[0, :])

        direc_init = (enemy - cannon) / la.norm(enemy - cannon)
        print('cannon, enemy:', cannon, enemy)
        sb.optim(100, 45, direc_init, cannon, enemy, wind_tbl)
コード例 #2
0
ファイル: app2.py プロジェクト: Jong-Min-Moon/balloon
    def GridSearch(self):
        self.OptimOutput.setPlainText('각도 계산 중...')
        wind_tbl = pd.merge(self.data['wind'],
                            self.wind_dir,
                            how='left',
                            on='wind_dir').set_index(self.data['wind'].index)
        cannon = np.array(self.data['cannon'].iloc[0, :])
        cannon_0 = np.append(cannon, 0)
        enemy = np.array(self.data['enemy'].iloc[0, :])
        print('cannon, enemy:', cannon, enemy)
        ran = 5000
        under = la.norm(enemy - cannon)
        print('밑변:', under)
        if ran <= under:
            QMessageBox.about(
                self, "오류",
                "포와 적의 거리가 너무 멀어서({}) 현재 사거리로는 목표지점에 착탄 불가합니다.".format(under))
        else:
            theta_init = np.arccos(under / ran)
            print('theta_init:', theta_init)
            direc_init = (enemy - cannon) / la.norm(enemy - cannon)
            print('direc_init:', direc_init)

            theta_grid = np.linspace(0.01, np.pi / 2 - 0.01, 300)
            scores = np.array([
                sb.optim(100, atheta, direc_init, cannon_0, enemy, wind_tbl,
                         ran) for atheta in theta_grid
            ])
            theta_best = theta_grid[scores.argmin()]
            opt_eval = (sb.shoot_for_optim(
                100, cannon_0,
                sb.ang2coord(cannon[:1], theta_best, direc_init, 5000),
                wind_tbl, 5000))
            self.OptimOutput.setPlainText(
                '\n 최적화 해의 값을 가지고 100발 쐈을 때의 탄착군 중심: {}'.format(opt_eval))
            self.ax.plot(theta_grid, scores)
            self.canvas.draw()
コード例 #3
0
 def f(x):
     return sb.optim(100, x[0], np.array([x[1], x[2]]), cannon,
                     enemy, wind_tbl)
コード例 #4
0
ファイル: app2.py プロジェクト: Jong-Min-Moon/balloon
 def f(x):
     return (sb.optim(100, x[0], np.array([x[1], x[2]]), cannon_0,
                      enemy, wind_tbl, ran))