1 Star 12 Fork 8

NackBT/BP神经网络整定PID算法

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.cpp 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
NackBT 提交于 2020-11-08 12:04 . 核心执行文件
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include "BPNN_PID.h"
#define Sample 40
using namespace std;
int main() {
double Target = 15,Current = 0;
double TestData[4][Sample] = {0};
BPNN_PID bpnnPid;
bpnnPid.TargetV = Target;
string Uof = "OutputU.txt";
string Kpof= "OutputKp.txt";
string Kiof= "OutputKi.txt";
string Kdof= "OutputKd.txt";
ofstream OutputU(Uof);
ofstream OutputKp(Kpof);
ofstream OutputKi(Kiof);
ofstream OutputKd(Kdof);
for (int i = 0; i < Sample; ++i)
{
bpnnPid.CurrentV = Current;
bpnnPid.GetU_Ctrl();
Current =Current + bpnnPid.U_Ctrl;
TestData[0][i] = Current;
TestData[1][i] = bpnnPid.bpnnWeight.w1;
TestData[2][i] = bpnnPid.bpnnWeight.w2;
TestData[3][i] = bpnnPid.bpnnWeight.w3;
}
if(OutputU.is_open() && OutputKp.is_open() && OutputKd.is_open() && OutputKi.is_open())
{
for (short i = 0 ; i < Sample ; i++)
{
OutputU << TestData[0][i] << endl;
OutputKp << TestData[1][i] << endl;
OutputKi << TestData[2][i] << endl;
OutputKd << TestData[3][i] << endl;
}
}
else
{
cout << "Error" << endl;
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/NackBT/BPNN_PID.git
git@gitee.com:NackBT/BPNN_PID.git
NackBT
BPNN_PID
BP神经网络整定PID算法
master

搜索帮助