您当前的位置: 首页 >  搜索

FPGA硅农

暂无认证

  • 0浏览

    0关注

    282博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

启发式算法(蒙特卡洛算法和差分进化算法)解决设计空间搜索问题

FPGA硅农 发布时间:2021-06-11 14:55:18 ,浏览量:0

要求解的问题

在这里插入图片描述

python代码
import numpy as np
import random

K=3
S=1
N=64
M=128
R=32
C=32
PE=220                      #DSP数量
B=50000                     #片上存储器容量

def objfunc(Tn,Tm,Tr,Tc):
    Tload=max(Tn*(S*Tr+K-S)*(S*Tc+K-S),Tn*Tm*K*K)
    Tstore=Tr*Tc*Tm
    Tcompute=Tr*Tc*K*K
    Tone_tile=Tload+Tcompute+(np.ceil(N/Tn)-1)*max(Tload,Tcompute)
    Ttotal=np.ceil(R/Tr)*np.ceil(C/Tc)*(Tstore+Tone_tile+(np.ceil(M/Tm)-1)*max(Tone_tile,Tstore))
    return Ttotal

def constrain(Tn,Tm,Tr,Tc):
    if Tn*Tm>PE or Tn*Tm*K*K+Tn*(S*Tr+K-S)*(S*Tc+K-S)+Tm*Tr*Tc>B:
        return False
    else:
        return True

def MonteCarlo(n):
    solution=[0,0,0,0]
    Tmin=9999999.0
    for i in range(n):
        Tn=np.random.randint(low=1,high=N+1)
        Tm=np.random.randint(low=1,high=M+1)
        Tr=np.random.randint(low=1,high=R+1)
        Tc=np.random.randint(low=1,high=C+1)
        #print(Tn,Tm,Tr,Tc)
        if constrain(Tn=Tn,Tm=Tm,Tr=Tr,Tc=Tc):         #满足约束
            temp=objfunc(Tn=Tn,Tm=Tm,Tr=Tr,Tc=Tc)
            if temp0 and Tm>0 and Tr>0 and Tc>0 and Tn            
关注
打赏
1658642721
查看更多评论
0.0400s