program rbf
Include 'link_fnl_shared.h'
use numerical_libraries
!use imsl
implicit none
!*************************************** 参数说明
integer NumSam, NumVar !NumSam采样点个数,NumVar变量个数
parameter(NumSam = 30, NumVar = 3) !!!!!需要修改
real Bound(NumVar,2) !max和min 用于正规化
real ParaIn(NumSam,NumVar), ParaOut(NumSam) !采样数据(输入和输出)
real ParaIn2(NumSam,NumVar), r(NumSam,NumSam), h(NumSam,NumSam), w(NumSam), c, temp
real p(NumSam), ParaNew(NumVar), rNew(NumSam), hNew(NumSam), pNew, ap(NumSam),f(NumSam)
integer i, j, k
open (1, file = 'dem01.txt', status = 'old') !采样数据 !!!!!需要修改文件名
i = 0
do while(.not.eof(1))
i = i + 1
read(1,*) ParaIn(i,1), ParaIn(i,2),ParaIn(i,3),f(i),ap(i),ParaOut(i)!!!!!需要修改
enddo
close(1)
!* 找max和min
do i = 1, NumVar
Bound(i,1) = ParaIn(1,i)
Bound(i,2) = ParaIn(1,i)
enddo
do i = 2, NumSam
do j = 1, NumVar
if (ParaIn(i,j) < Bound(j,1)) then
Bound(j,1) = ParaIn(i,j)
endif
if (ParaIn(i,j) > Bound(j,2)) then
Bound(j,2) = ParaIn(i,j)
endif
enddo
enddo
!** 中心化数据到[-1,+1]
do i = 1, NumSam
do j = 1, NumVar
ParaIn2(i,j) = (2*ParaIn(i,j)-Bound(j,1)-Bound(j,2)) / (Bound(j,2)-Bound(j,1))
enddo
enddo
!***
c = 0 !高斯径向基的系数c=正规化距离的平均值
do i = 1, NumSam
do j = 1, NumSam
temp = 0
do k = 1, NumVar
temp = temp + (ParaIn2(i,k) - ParaIn2(j,k))**2
enddo
r(i,j) = sqrt(temp)
c = c + r(i,j)
enddo
enddo
c = c / NumSam**2
do i = 1, NumSam
do j = 1, NumSam
h(i,j) = exp(-r(i,j)**2 / c**2)
enddo
enddo
call LSARG(NumSam, h, NumSam, ParaOut, 1, w) !得到系数w
!****代入原样本检验
do i = 1, NumSam
p(i) = 0
do j = 1, NumSam
p(i) = p(i) + h(i,j) * w(j)
enddo
write(*,*) ParaOut(i), p(i)
enddo
open(2, file = 'outdem003.txt', status = 'unknown')
do i = 1, NumVar
write(2, "(2f15.5)") Bound(i,1), Bound(i,2)
enddo
write(2, "(f15.5)") c
do i = 1, NumSam
write(2, "(30f15.5)") (ParaIn2(i,j), j = 1, NumVar) !NumVar<30
enddo
do i = 1, NumSam
write(2, "(f15.5)") w(i)
enddo
end program
1.2 KB, 下载次数: 7
Jackdaw 发表于 2018-4-20 10:43
和运行方式有关系吧
试试下面方法之一
fcode 发表于 2018-4-21 08:16
我没有修改任何代码,在我这里的屏幕输出为
119.8400 119.8400
112.8700 112.8700
fcode 发表于 2018-4-24 10:58
单步调试一下,看运行到哪一步了。
调试.png (15.71 KB, 下载次数: 508)
调试
结果.png (24.91 KB, 下载次数: 506)
结果
单步调试.png (130.56 KB, 下载次数: 517)
调试1
单步调试1.png (7.29 KB, 下载次数: 503)
调试2
最后调试结果.png (19.58 KB, 下载次数: 468)
最后结果
call LSARG (NumSam, h, NumSam, ParaOut, 1, w) !得到系数w
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |