Skip to content
Snippets Groups Projects
Commit 510d131e authored by Mauricio Zambrano-Bigiarini's avatar Mauricio Zambrano-Bigiarini
Browse files

hydroPSO.Rd: added regrouping examples

parent ca415b7f
No related branches found
No related tags found
No related merge requests found
...@@ -426,7 +426,7 @@ Note for \code{\link[stats]{optim}} users: \cr ...@@ -426,7 +426,7 @@ Note for \code{\link[stats]{optim}} users: \cr
# Number of dimensions of the optimisation problem (for all the examples) # Number of dimensions of the optimisation problem (for all the examples)
nparam <- 3 nparam <- 3
# Boundaries of the search space # Boundaries of the search space (Rastrigin function)
lower <- rep(-5.12, nparam) lower <- rep(-5.12, nparam)
upper <- rep(5.12, nparam) upper <- rep(5.12, nparam)
...@@ -463,10 +463,10 @@ plot_results(MinMax="min", do.png=TRUE) ...@@ -463,10 +463,10 @@ plot_results(MinMax="min", do.png=TRUE)
set.seed(100) set.seed(100)
# Defining the swarm size ('npart'), the relative tolerance ('reltol'), # Defining the swarm size ('npart'), the relative tolerance ('reltol'),
# the absolute tolerance ('abstol') and the frequency of report messages printed # the frequency of report messages printed to the screen ('REPORT'), and no
# to the screen ('REPORT') # output files ('write2disk')
hydroPSO( fn="rastrigrin", lower=rep(-5.12, nparam), upper=rep(5.12, nparam), hydroPSO( fn=rastrigrin, lower=lower, upper=upper,
control=list(npart=15, reltol=1e-15, abstol=1e-14, REPORT=10) ) control=list(npart=15, reltol=1e-15, REPORT=10, write2disk=FALSE) )
################################ ################################
...@@ -478,13 +478,37 @@ hydroPSO( fn="rastrigrin", lower=rep(-5.12, nparam), upper=rep(5.12, nparam), ...@@ -478,13 +478,37 @@ hydroPSO( fn="rastrigrin", lower=rep(-5.12, nparam), upper=rep(5.12, nparam),
set.seed(100) set.seed(100)
# Same as Example 2, but setting the topology to global gest ('topology="gbest"') # Same as Example 2, but setting the topology to global gest ('topology="gbest"')
hydroPSO( fn="rastrigrin", lower=rep(-5.12, nparam), upper=rep(5.12, nparam), hydroPSO( fn=rastrigrin, lower=lower, upper=upper,
control=list(npart=15, reltol=1e-15, abstol=1e-14, REPORT=10, control=list(npart=15, reltol=1e-15, REPORT=10, write2disk=FALSE,
topology="gbest") ) topology="gbest") )
################################
# Example 4. Regrouping #
################################
# Setting the seed (for reproducible results)
set.seed(100)
# Same as Example 3 ('topology="gbest"') but using regrouping
hydroPSO( fn=rastrigrin, lower=lower, upper=upper,
control=list(npart=15, reltol=1e-15, REPORT=10, write2disk=FALSE,
topology="gbest",
use.RG=TRUE, RG.thr=1e-4, RG.r=3, RG.miniter=50) )
# Setting the seed (for reproducible results)
set.seed(100)
# Same as Example 2 ('topology="random"') but using regrouping
hydroPSO( fn=rastrigrin, lower=lower, upper=upper,
control=list(npart=15, reltol=1e-15, REPORT=10, write2disk=FALSE,
use.RG=TRUE, RG.thr=1e-4, RG.r=3, RG.miniter=50) )
################################ ################################
# Example 4. Asynchronus update# # Example 5. Asynchronus update#
################################ ################################
# Setting the seed (for reproducible results) # Setting the seed (for reproducible results)
...@@ -492,7 +516,7 @@ set.seed(100) ...@@ -492,7 +516,7 @@ set.seed(100)
# Same as Example 3, but using asynchronus update of previus and local best # Same as Example 3, but using asynchronus update of previus and local best
# ('best.update="async"') # ('best.update="async"')
hydroPSO( fn="rastrigrin", lower=rep(-5.12, nparam), upper=rep(5.12, nparam), hydroPSO( fn=rastrigrin, lower=lower, upper=upper,
control=list(npart=15, reltol=1e-15, abstol=1e-14, REPORT=10, control=list(npart=15, reltol=1e-15, abstol=1e-14, REPORT=10,
topology="gbest", best.update="async") ) topology="gbest", best.update="async") )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment