Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hydroPSO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Senoner Samuel
hydroPSO
Commits
a0b60f07
Commit
a0b60f07
authored
12 years ago
by
Mauricio Zambrano-Bigiarini
Browse files
Options
Downloads
Patches
Plain Diff
hydroPSO.R: small bug fixed in IPSO. updated vignette
parent
c4fc7d8c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/PSO_v2012.R
+9
-6
9 additions, 6 deletions
R/PSO_v2012.R
inst/vignette/hydroPSO_vignette.Rnw
+24
-21
24 additions, 21 deletions
inst/vignette/hydroPSO_vignette.Rnw
with
33 additions
and
27 deletions
R/PSO_v2012.R
+
9
−
6
View file @
a0b60f07
...
@@ -259,13 +259,16 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest,
...
@@ -259,13 +259,16 @@ compute.veloc <- function(x, v, w, c1, c2, CF, Pbest, part.index, gbest,
if
(
MinMax
==
"min"
)
{
if
(
MinMax
==
"min"
)
{
c2i
<-
c2
*
(
(
1
/
ngbest.fit
)
/
sum
(
1
/
ngbest.fit
)
)
c2i
<-
c2
*
(
(
1
/
ngbest.fit
)
/
sum
(
1
/
ngbest.fit
)
)
}
else
c2i
<-
c2
*
(
ngbest.fit
/
sum
(
ngbest.fit
)
)
}
else
c2i
<-
c2
*
(
ngbest.fit
/
sum
(
ngbest.fit
)
)
nan.index
<-
which
(
is.nan
(
c2i
))
if
(
length
(
nan.index
)
>
0
)
c2i
[
nan.index
]
<-
c2
# transforming 'x' into a matrix, with the same values in each row, in
# transforming 'x' into a matrix, with the same values in each row, in
# order to be able to substract 'x' from 'ngest'
# order to be able to substract 'x' from 'ngest'
X
<-
matrix
(
rep
(
x
,
nngbest
),
ncol
=
n
,
byrow
=
TRUE
)
X
<-
matrix
(
rep
(
x
,
nngbest
),
ncol
=
n
,
byrow
=
TRUE
)
# computing the velocity
# computing the velocity
vn
<-
CF
*
(
w
*
v
+
r1
*
c1
*
(
pbest
-
x
)
+
colSums
(
R2
*
c2i
*
(
ngbest
-
X
)
)
)
vn
<-
CF
*
(
w
*
v
+
r1
*
c1
*
(
pbest
-
x
)
+
colSums
(
R2
*
c2i
*
(
ngbest
-
X
)
)
)
}
else
if
(
method
==
"fips"
)
{
}
else
if
(
method
==
"fips"
)
{
...
@@ -1085,7 +1088,7 @@ ComputeSwarmRadiusAndDiameter <- function(x, gbest, Lmax) {
...
@@ -1085,7 +1088,7 @@ ComputeSwarmRadiusAndDiameter <- function(x, gbest, Lmax) {
radius
<-
numeric
(
npart
)
radius
<-
numeric
(
npart
)
gbest
<-
matrix
(
rep
(
gbest
,
npart
),
nrow
=
npart
,
byrow
=
TRUE
)
gbest
<-
matrix
(
rep
(
gbest
,
npart
),
nrow
=
npart
,
byrow
=
TRUE
)
radius
<-
sqrt
(
rowSums
(
(
x
-
gbest
)
^
2
)
)
radius
<-
sqrt
(
rowSums
(
(
x
-
gbest
)
^
2
,
na.rm
=
TRUE
)
)
#swarm.radius <- max(radius, na.rm=TRUE)
#swarm.radius <- max(radius, na.rm=TRUE)
swarm.radius
<-
median
(
radius
,
na.rm
=
TRUE
)
swarm.radius
<-
median
(
radius
,
na.rm
=
TRUE
)
...
@@ -1224,7 +1227,7 @@ RegroupingSwarm <- function(x,
...
@@ -1224,7 +1227,7 @@ RegroupingSwarm <- function(x,
# Relative change achieved in each dimension
# Relative change achieved in each dimension
#rel.change <- (RangeNew-RangeO)/RangeO
#rel.change <- (RangeNew-RangeO)/RangeO
#names(rel.change) <- param.IDs
#names(rel.change) <- param.IDs
out
<-
list
(
3
)
out
<-
list
(
3
)
out
[[
1
]]
<-
x
out
[[
1
]]
<-
x
out
[[
2
]]
<-
v
out
[[
2
]]
<-
v
...
@@ -1326,7 +1329,7 @@ hydromod.eval <- function(part, Particles, iter, npart, maxit,
...
@@ -1326,7 +1329,7 @@ hydromod.eval <- function(part, Particles, iter, npart, maxit,
# 14-Jun-2012 ; 15-Jun-2012 ; 03-Jul-2012 ; 06-Jul-2012 #
# 14-Jun-2012 ; 15-Jun-2012 ; 03-Jul-2012 ; 06-Jul-2012 #
# 11-Jul-2012 ; 17-Jul-2012 ; 18-Jul-2012 ; 13-Sep-2012 ; 14-Sep-2012 #
# 11-Jul-2012 ; 17-Jul-2012 ; 18-Jul-2012 ; 13-Sep-2012 ; 14-Sep-2012 #
# 17-Sep-2012 ; 23-Sep-2012 ; 15-Oct-2012 ; 25-Oct-2012 ; 28-Oct-2012 #
# 17-Sep-2012 ; 23-Sep-2012 ; 15-Oct-2012 ; 25-Oct-2012 ; 28-Oct-2012 #
# 08-Nov-2012 ; 26-Nov-2012
#
# 08-Nov-2012 ; 26-Nov-2012
; 27-Nov-2012
#
################################################################################
################################################################################
# 'lower' : minimum possible value for each parameter
# 'lower' : minimum possible value for each parameter
# 'upper' : maximum possible value for each parameter
# 'upper' : maximum possible value for each parameter
...
@@ -2576,7 +2579,7 @@ hydroPSO <- function(
...
@@ -2576,7 +2579,7 @@ hydroPSO <- function(
if
(
(
topology
==
"lbest"
)
&
(
iter
<=
iter.ini
)
)
{
if
(
(
topology
==
"lbest"
)
&
(
iter
<=
iter.ini
)
)
{
ltopology
<-
"gbest"
ltopology
<-
"gbest"
}
else
ltopology
<-
topology
}
else
ltopology
<-
topology
V
[
j
,]
<-
compute.veloc
(
V
[
j
,]
<-
compute.veloc
(
x
=
X
[
j
,
],
x
=
X
[
j
,
],
v
=
V
[
j
,
],
v
=
V
[
j
,
],
...
@@ -2597,7 +2600,7 @@ hydroPSO <- function(
...
@@ -2597,7 +2600,7 @@ hydroPSO <- function(
ngbest
=
X.best.part
[
ngbest.pos
,
],
# topology="ipso"
ngbest
=
X.best.part
[
ngbest.pos
,
],
# topology="ipso"
lpbest.fit
=
pbest.fit
[
X.neighbours
[
j
,
]]
# method="wfips"
lpbest.fit
=
pbest.fit
[
X.neighbours
[
j
,
]]
# method="wfips"
)
)
V
[
j
,]
<-
velocity.boundary.treatment
(
v
=
V
[
j
,],
vmax
=
Vmax
)
V
[
j
,]
<-
velocity.boundary.treatment
(
v
=
V
[
j
,],
vmax
=
Vmax
)
########################################################################
########################################################################
...
...
This diff is collapsed.
Click to expand it.
inst/vignette/hydroPSO_vignette.Rnw
+
24
−
21
View file @
a0b60f07
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment