; +
; NAME:
; RMD_PSO
;
; PURPOSE:
; Function that attempts to find the global minimum of a function
; using a particle swarm optimization (PSO) strategy.
;
; In this algorithm the individual agents (swarm members) "fly" through
; parameter space seeking the global function minimum. At each time
; step in the search every agent determines the value of the function
; at its location in parameter space and compares this value with its
; own previous best value as well as the overall best parameter found
; among all of the agents. The velocity of each agent is determined by
; an attraction between its current position, the best solution for that
; particular agent, and the best solution for all agents found.
; The velocity of each agent is updated at each time step according to
; the equation:
;
; v[t+dt] = b*v[t] + dv[t] where
; dv[t] = w1*r*(pbest[t] - p[t]) + w2*r*(gbest[t] - p[t])
;
; w1 and w2 are weights (also known as learning factors) with
; typical values ranging between 0 and 4, b is a velocity damping factor
; (also called an inertia weight), r is a uniform random deviate,
; p is the current parameter set, pbest is the best parameter set found
; for this particular agent, and gbest is the best parameter set found
; for all particular agents. The inertia weight decreases from 1 at each
; time step so that after k updates, the value is b^k. One points to
; understand about the learning factors: (1) w1 governs the "cognitive"
; aspect of the motion (that which depends on its own memory) and w2
; governs the social aspect of the motion (that which depends on the
; discovery of the entire swarm). Note that the scales of the parameters,
; as defined by PRANGE, is absorbed into the learning factors.
;
; The position in parameter space is updated according to the equation:
; p[t+dt] = p[t] + dt*v[t]
;
; Note that "elastic" boundary conditions are implemented so that if an
; agent exceeds the limits of the parameter range (PRANGE) then it will
; be "reflected" (or bounce) from the boundary.
;
; For additional details on this optimization technique please consult
; the following web site: http://www.swarmintelligence.org/
;
; RETURN_VALUE:
; Best parameters found in the minimization.
;
; CATEGORY:
; OPTIMIZATION, OBJECTS, SWARM INTELLIGENCE
;
; CALLING SEQUENCE:
; RESULT = RMD_PSO(PRANGE = prange,FUNCTION_NAME = function_name,....)
;
; PARAMETERS:
; NONE
;
; KEYWORDS:
; FTOL: Fractional tolerance defined as the average fitness
; divided by the best fitness. FTOL is the termination
; criteria for the quantity defined above (DEF: 0.1)
; PRANGE: Range of parameters (2 by N array where N is the number
; of parameters in the optimization).
; WEIGHTS: Learning factors. (w1 and w2 in equation above) (DEF: [1.,1.])
; FUNCTION_NAME: Name of the function to be used in the minimization
; FUNCTION_VALUE:Value of FUNCTION_NAME at the result found in the minimization.
; FUNCTARGS: Exogenous inputs required for function evaluation above
; and beyond the parameters in the optimization.
; NUM_PARTICLES: Number of particles in the swarm (DEF: 10)
; ITMAX: Maximum number of iterations to perform if FTOL termination
; criteria not met.
; VEL_FRACTION: The fraction of the parameter range by which the initial
; velocity is created. (DEF: 0.1)
; VEL_DECREMENT: The fractional amount by which the velocity will be decremented
; at each iteration. Also called velocity damping and inertia weight.
; This is the parameter designated b in the equation above. (DEF: 0.95)
; ITERPROC: Name (string) of the procedure to be called at
; each iteration step. An example of such a procedure is
; PSO_ITERPROC, shown below.
;
; The requirements on the intermediate reporting procedure are
; that it be written as a PROCEDURE and it must accept the
; following arguments: FUNC, P (the current best parameter set),
; ITER (the current iteration, and INTERRUPT (a byte variable equal 1B or 0B
; indicating if the algorithm should cease at the next update--note that
; interrupt must be a variable since it is expected to be passed by reference).
; Optional keywords are FUNCTARGS, ITERARGS, and OREF. OREF is provided
; so that you can extract information on the PSO object (its state)
; at the current iteration. This can be useful if you want to get
; all of the current members of the swarm and display them, for instance.
;
; ITERARGS: Structure containing exogenous information necessary
; to perform the intermediate reporting procedure
; ITERPROC.
; NCALLS: Number of function calls over the course of the
; optimization procedure.
; QUIET: If set, no intermediate output will be provided
; (i.e. ITERPROC will not be called). Default: 1B
;
; REQUIREMENTS:
; IDL 6.0 and higher
;
; REQUIRED PROGRAMS:
; NONE
;
; COMMON BLOCKS:
; NONE
;
; SIDE EFFECTS:
; NONE
;
; EXAMPLE:
; Example usage found at end of this source listing namded
; PSO_MIN_EXAMPLE. To run this code, compile this file and
; type PSO_MIN_EXAMPLE at the IDL prompt.
;
; IDL> PSO_MIN_EXAMPLE
;
; AUTHOR:
; Robert Dimeo
; NIST Center for Neutron Research
; National Institute of Standards and Technology
; 100 Bureau Drive-Stop 8562
; Gaithersburg, MD 20899
;
; DISCLAIMER
; This software is provided as is without any warranty whatsoever.
; Permission to use, copy, modify, and distribute modified or
; unmodified copies is granted, provided this disclaimer
; is included unchanged.
;
; ACKNOWLEDGMENT:
; This work is part of the DAVE development effort at the NCNR and
; was supported in part by the National Science Foundation
; under Agreement No. DMR-0086210.
;
; MODIFICATION HISTORY:
; Written by RMD (12/20/04)
; Updated header documentation, tightened up some
; of the code, and corrected a few errors in the implementation
; of the intermediate reporting (ITERPROC) -- RMD (12/22/04)
; Replaced the periodic boundary conditions with "elastic"
; boundaries -- RMD (12/22/04)
; Removed the velocity tolerance and redefined FTOL so that
; it is not problem nor scale-dependent -- RMD (12/22/04)
; Removed the scale dependence of the learning factors
; -- RMD (12/22/04)
;
; -
; *************************************************** ;
pro pso::cleanup
compile_opt idl2,hidden
ptr_free,self.v_ptr,self.p_ptr,self.pbest_ptr
ptr_free,self.gbest_ptr,self.prange_ptr,self.f_ptr
ptr_free,self.fbest_ptr,self.gfbest_ptr,self.iterargs_ptr
ptr_free,self.functargs_ptr,self.seed_ptr
end
; *************************************************** ;
pro pso_iterproc, func, $
p, $
iter, $
interrupt, $
functargs = functargs, $
oref = opso, $
_Extra = iterargs
compile_opt hidden,idl2
; Default intermediate reporting procedure
print,'Iteration: '+strtrim(string(iter),2)
print,' *********************** '
for i = 0,n_elements(p)-1 do begin
strout = 'p['+strtrim(string(i),2)+']='+strtrim(string(p[i]),2)
print,strout
endfor
print
end
; *************************************************** ;
function pso::evaluate_function
compile_opt idl2,hidden
p = *self.p_ptr
psize = size(p)
nparms = psize[1]
f = fltarr(self.num_particles)
for i = 0,self.num_particles-1 do $
f[i] = call_function(self.func,reform(p[*,i]),_Extra = *self.functargs_ptr)
*self.f_ptr = f
self.ncalls = self.ncal
pso.zip_PSO_melanoma diagnosis_zip
版权申诉
31 浏览量
2022-09-24
18:38:31
上传
评论
收藏 832KB ZIP 举报
weixin_42651887
- 粉丝: 81
- 资源: 1万+
最新资源
- 10Eclipse项目源码.jpg
- 大屏可视化数据课程项目
- Maven 快速入门指南:安装和配置方法详解
- STM32物信息通过MQTT协议上传云平台
- STM32物信息通过MQTT协议上传云平台
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6260.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6259.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6258.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6257.0)
- Screenshot_2024_0614_022736.png
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈