模拟退火算法解决路径优化 源代码

模拟退火算法解决路径优化 源代码

ID:19781202

大小:33.50 KB

页数:16页

时间:2018-10-06

模拟退火算法解决路径优化 源代码_第1页
模拟退火算法解决路径优化 源代码_第2页
模拟退火算法解决路径优化 源代码_第3页
模拟退火算法解决路径优化 源代码_第4页
模拟退火算法解决路径优化 源代码_第5页
资源描述:

《模拟退火算法解决路径优化 源代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、模拟退火算法解决路径优化的源代码我有simulatedannealingwithmetropolies(MonteCarlo)做的一个项目的代码,你要看看么?voidanneal(intnparam,intnstep,intnstep_per_block,doublet0,constdouble*param_in,doublecost_in,double*params_out,double*cost_out){intnblock;intstep;intblock;intnactive;intrank;intn_accepted

2、=0;inti,j,n;doublecost_current,cost_trial;int*param_index;double*param_current;double*param_trial;double*Q;double*S;double*u;double*dp;double*A;FILE*fp_log_file;charfname[FILENAME_MAX];doubletemp=t0;doubletempmax=temp;doubleebar,evar,emin,eta,specific_heat;doubledel

3、ta;doublechi=0.8;//Annealingscheduledoublechi_s=3.0;//Vanderbilt/Louie'growthfactor'doublerm;doubleroot3=sqrt(3.0);doublep=0.02/sqrt(3.0);//maxsizeofannealingstepparam_current=newdouble[nparam];param_trial=newdouble[nparam];cost_current=cost_in;MPI_Comm_rank(MPI_COM

4、M_WORLD,&rank);sprintf(fname,"a_%4.4d.log",rank);fp_log_file=fopen(fname,"a");if(fp_log_file==(FILE*)NULL)errorMessage("fopen(log)failed");//Workoutthenumberofactiveparameters,andsetupthe//indextableoftheactiveparameters.//Notethatthecompletearrayofparameters(para

5、m_trial)must//beusedtoevaluatethecostfunction.nactive=0;for(n=0;n

6、ethestepdistributionmatrixQ_ijQ=newdouble[nactive*nactive];S=newdouble[nactive*nactive];u=newdouble[nactive];dp=newdouble[nactive];A=newdouble[nactive];double*Qtmp;Qtmp=newdouble[nactive*nactive];for(i=0;i

7、+j]=p*delta*param_current[param_index[j]];}}//carryoutannealingpointsnblock=nstep/nstep_per_block;rm=1.0/(double)nstep_per_block;for(block=0;block

8、diagonal.temp=chi*temp;for(i=0;i

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。