# 这是一个示例 Python 脚本。
# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。
import pandas as pd
import csv
import numpy as np
import math
def fusion(a):# 对矩阵进行DS融合求解函数,输入多维矩阵返回一维
result = a[0]
deletetmp = []
for jishu in range(len(a)):# 对a的行数进行循环
m1 = np.array(result)
deletetmp.append(jishu)
if jishu >= len(a)-1:
return result
mtmp = a
mtmp = np.delete(mtmp, deletetmp, axis=0)# 删除mtmp矩阵中的第deletetmp行
m2 = mtmp[0]
k = 0
for i in range(a.shape[1]):
for j in range(a.shape[1]):
k = k + m1[i] * m2[j] # 计算冲突因子k
res = 0
for q in range(a.shape[1]):
res = res + m1[q] * m2[q]
k = k - res # 计算冲突因子k
list1 = []
for s in range(a.shape[1]):
A = m1[s] * m2[s] / (1 - k) # 利用DS规则进行证据合成
list1.append(A)
list2 = []
for t in range(a.shape[1]): # 归一化处理
P = list1[t] / np.sum(list1)
list2.append(P)
result = np.array(list2)
return result
###############下一时刻指标值预测
def zhibiaoyuce(a, b):
from sklearn.linear_model import LinearRegression
model = LinearRegression() #导入linear_model回归模型
a = np.array(a, dtype=float)
b = np.array(b, dtype=float)
model.fit(a, b) #模型训练
y_pred = model.predict(a)
return y_pred
###############动态劣化度求取
def dongtailiehuadu(xmin, xmax, xp):
if xp< float(xmin):
liehuadu = 0
if xp > float(xmax):
liehuadu = 1
if xp >= float(xmin) and xp <= float(xmax):
liehuadu = (xp-float(xmin))/(float(xmax)-float(xmin))
return liehuadu
###############云模型隶属度求取
def lishudu(gdx, k):
exk = [0,0.35,0.65,1]
enk = [0.117,0.117,0.1,0.117]
u = math.exp(-(gdx-exk[k-1])*(gdx-exk[k-1])/2/enk[k-1]/enk[k-1])
return u
###############将读取的矩阵拆分生成预测样本函数
def yangben(r):
r = r.T
a = []
b = []
for k in range(r.shape[0]):
for s in range(20):
a.append(r[k, 5 * s:(5 * s + 5)])
b.append(r[k, 5 * s + 6])
a = np.array(a)
b = np.array(b)
c = b.reshape(20*(k+1), 1)
tmp = np.concatenate((a, c), axis=1)
return tmp
###############求列最大值
def liemax(r):
max_val = r[0]
for val in r:
if val > max_val:
max_val = val
return max_val
###############求列最小值
def liemin(r):
min_val = r[0]
for val in r:
if val < min_val:
min_val = val
return min_val
filename = './rawData954683(final)-0618.csv'
with open(filename,"r") as csvfile:# 读取数据
csvreader = csv.reader(csvfile)
data = []
for row in csvreader:
data.append(row)
data = np.array(data)
R1 = data[1:200, 3:11] #发电机参数矩阵
R2 = data[1:200, 11:18] #齿轮箱参数矩阵
R3 = data[1:200, 18:22] #机舱参数矩阵
R4 = data[1:200, 22:24] #主轴承参数矩阵
R5 = data[1:200, 24:28] #变流部件参数矩阵
R6 = data[1:200, 28:31] #外界因素参数矩阵
###################R1mass矩阵生成#########################
R1xy = yangben(R1)
R1x = R1xy[:, 0:4]
R1y = R1xy[:, 5]
y = zhibiaoyuce(R1x, R1y)
y_pred = [y[19], y[39], y[59], y[79], y[99], y[119], y[139], y[159]] #得到了R1中下一时刻8各指标的预测值
gdxtmp = []
rows = 8
cols = 4
massr1 = [[0 for col in range(cols)] for row in range(rows)]
massr1 = np.zeros((rows, cols))
for i in range(len(y_pred)):
liemin1 = liemin(R1[:,i])
liemax1 = liemax(R1[:,i])
gdxtmp.append(dongtailiehuadu(liemin1, liemax1, y_pred[i])) #求得R1中8各指标的动态劣化度
for j in range(4):
massr1[i,j] = lishudu(gdxtmp[i], j)
###################R2mass矩阵生成#########################
R2xy = yangben(R2)
R2x = R2xy[:, 0:4]
R2y = R2xy[:, 5]
y = zhibiaoyuce(R2x, R2y)
y_pred2 = [y[19], y[39], y[59], y[79], y[99], y[119], y[139]] # 得到了R1中下一时刻8各指标的预测值
gdxtmp2 = []
rows = 7
cols = 4
massr2 = [[0 for col in range(cols)] for row in range(rows)]
massr2 = np.zeros((rows, cols))
for i in range(len(y_pred2)):
liemin1 = liemin(R2[:, i])
liemax1 = liemax(R2[:, i])
gdxtmp2.append(dongtailiehuadu(liemin1, liemax1, y_pred2[i])) # 求得R1中8各指标的动态劣化度
for j in range(4):
massr2[i, j] = lishudu(gdxtmp2[i], j)
###################R3mass矩阵生成#########################
R3xy = yangben(R3)
R3x = R3xy[:, 0:4]
R3y = R3xy[:, 5]
y = zhibiaoyuce(R3x, R3y)
y_pred3 = [y[19], y[39], y[59], y[79]] # 得到了R1中下一时刻8各指标的预测值
gdxtmp3 = []
rows = 4
cols = 4
massr3 = [[0 for col in range(cols)] for row in range(rows)]
massr3 = np.zeros((rows, cols))
for i in range(len(y_pred3)):
liemin1 = liemin(R3[:, i])
liemax1 = liemax(R3[:, i])
gdxtmp3.append(dongtailiehuadu(liemin1, liemax1, y_pred3[i])) # 求得R1中8各指标的动态劣化度
for j in range(4):
massr3[i, j] = lishudu(gdxtmp3[i], j)
###################R4mass矩阵生成#########################
R4xy = yangben(R4)
R4x = R4xy[:, 0:4]
R4y = R4xy[:, 5]
y = zhibiaoyuce(R4x, R4y)
y_pred4 = [y[19], y[39]] # 得到了R1中下一时刻8各指标的预测值
gdxtmp4 = []
rows = 2
cols = 4
massr4 = [[0 for col in range(cols)] for row in range(rows)]
massr4 = np.zeros((rows, cols))
for i in range(len(y_pred4)):
liemin1 = liemin(R4[:, i])
liemax1 = liemax(R4[:, i])
gdxtmp4.append(dongtailiehuadu(liemin1, liemax1, y_pred4[i])) # 求得R1中8各指标的动态劣化度
for j in range(4):
massr4[i, j] = lishudu(gdxtmp4[i], j)
###################R5mass矩阵生成#########################
R5xy = yangben(R5)
R5x = R5xy[:, 0:4]
R5y = R5xy[:, 5]
y = zhibiaoyuce(R5x, R5y)
y_pred5 = [y[19], y[39], y[59], y[79]] # 得到了R1中下一时刻8各指标的预测值
gdxtmp5 = []
rows = 4
cols = 4
massR5 = [[0 for col in range(cols)] for row in range(rows)]
massR5 = np.zeros((rows, cols))
for i in range(len(y_pred5)):
liemin1 = liemin(R5[:, i])
liemax1 = liemax(R5[:, i])
gdxtmp5.append(dongtailiehuadu(liemin1, liemax1, y_pred5[i])) # 求得R1中8各指标的动态劣化度
for j in range(4):
massR5[i, j] = lishudu(gdxtmp5[i], j)
###################R6mass矩阵生成#########################
R6xy = yangben(R6)
R6x = R6xy[:, 0:4]
R6y = R6xy[:, 5]
y = zhibiaoyuce(R6x, R6y)
y_pred6 = [y[19], y[39], y[59]] # 得到了R1中下一时刻8各指标的预测值
gdxtmp6 = []
rows = 3
cols = 4
massR6 = [[0 for col in range(cols)] for row in range(rows)]
massR6 = np.zeros((rows, cols))
for i in range(len(y_pred6)):
liemin1 = liemin(R6[:, i])
liemax1 = liemax(R6[:, i])
gdxtmp6.append(dongtailiehuadu(liemin1, liemax1, y_pred6[i])) # 求得R1中8各指标的动态劣化度
for j in range(4):
massR6[i, j] = lishudu(gdxtmp6[i], j)
################################################### 对矩阵进行DS融合求解函数,输入多维矩阵返回一维
Rdsm = []
massr = np.vstack((massr1, massr2, massr3, massr4, massR5, massR6))
Rdsm = fusion(massr)
asacz
- 粉丝: 0
- 资源: 2
最新资源
- Python毕业设计基于OpenCV的视频人脸识别系统源码+文档说明(高分项目)
- 好看的pc端代码生成工具(亲测好用)
- 2-文字pdf转图片pdf软件,单文件仅5M
- 视频编码中基于贝叶斯决策规则的快速CU划分算法提高H.266/VVC帧内编码效率
- Python毕业设计基于OpenCV的视频人脸识别系统源码+文档说明(高分毕设)
- 风力发电机控制系统仿真设计 风力发电系统动态模拟仿真 光伏发电系统 本设计主要依据风力发电机组的控制目标和控制策略,通过使用电力系统动态模拟仿真软件PSCAD EMTDC,建立变桨距风力发电机组控制系
- shiro项目示例!!!!
- Python编写录屏录音工具.py
- 视频编码技术中用于 VVC 压缩的低复杂度CTU分区与快速帧内模式决策方法
- 基于python的Django框架学生信息管理系统
- 西门子博途 SiVArc,标准程序功能块自动生成Wincc画面和变量 借助西门子SiVArc,可通过程序块和设定好的生成模板为多个HMI设备和PLC生成可视化,可使用生成规则指定哪些HMI对象针对哪个
- python爬虫豆瓣电影TOP250,以及数据化分析程序源代码+数据
- CNN-SVM卷积神经网络结合支持向量机多输入单输出回归预测(Matlab完整源码和数据)
- 基于微信小程序校园二手交易平台小程序源码+数据库(毕业设计项目)
- ABB选项功能开通方法以及授权文件,适用于ROBWARE 6万能密钥
- 2-批处理文本PDF转曲线轮廓PDF
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈