Skip to content

Commit c5fa29e

Browse files
authored
Simplify Particle Swarm Options Constructor. (#43)
* simplify constructor of pso. * bump version
1 parent 3dfe0b3 commit c5fa29e

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Manopt"
22
uuid = "0fc0a36d-df90-57f3-8f93-d78a9fc72bb5"
33
authors = ["Ronny Bergmann <manopt@ronnybergmann.net>"]
4-
version = "0.2.11"
4+
version = "0.2.12"
55

66
[deps]
77
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"

src/plans/particle_swarm_plan.jl

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ mutable struct ParticleSwarmOptions{
4949
retraction_method::TRetraction
5050
inverse_retraction_method::TInvRetraction
5151
vector_transport_method::TVTM
52-
function ParticleSwarmOptions{P}(
52+
function ParticleSwarmOptions(
5353
x0::AbstractVector,
5454
velocity::AbstractVector,
55-
inertia::TParams=0.65,
56-
social_weight::TParams=1.4,
57-
cognitive_weight::TParams=1.4,
55+
inertia=0.65,
56+
social_weight=1.4,
57+
cognitive_weight=1.4,
5858
stopping_criterion::StoppingCriterion=StopWhenAny(
5959
StopAfterIteration(500), StopWhenChangeLess(10.0^(-4))
6060
),
6161
retraction_method::AbstractRetractionMethod=ExponentialRetraction(),
6262
inverse_retraction_method::AbstractInverseRetractionMethod=LogarithmicInverseRetraction(),
6363
vector_transport_method::AbstractVectorTransportMethod=ParallelTransport(),
64-
) where {P,TParams}
64+
)
6565
o = new{
6666
typeof(x0),
67-
P,
67+
eltype(x0),
6868
typeof(velocity),
69-
TParams,
69+
typeof(inertia + social_weight + cognitive_weight),
7070
typeof(stopping_criterion),
7171
typeof(retraction_method),
7272
typeof(inverse_retraction_method),
@@ -85,28 +85,3 @@ mutable struct ParticleSwarmOptions{
8585
return o
8686
end
8787
end
88-
function ParticleSwarmOptions(
89-
x0::AbstractVector{P},
90-
velocity::AbstractVector,
91-
inertia::Real=0.65,
92-
social_weight::Real=1.4,
93-
cognitive_weight::Real=1.4,
94-
stopping_criterion::StoppingCriterion=StopWhenAny(
95-
StopAfterIteration(500), StopWhenChangeLess(10.0^(-4))
96-
),
97-
retraction_method::AbstractRetractionMethod=ExponentialRetraction(),
98-
inverse_retraction_method::AbstractInverseRetractionMethod=LogarithmicInverseRetraction(),
99-
vector_transport_method::AbstractVectorTransportMethod=ParallelTransport(),
100-
) where {P,T}
101-
return ParticleSwarmOptions{P}(
102-
x0,
103-
velocity,
104-
inertia,
105-
social_weight,
106-
cognitive_weight,
107-
stopping_criterion,
108-
retraction_method,
109-
inverse_retraction_method,
110-
vector_transport_method,
111-
)
112-
end

0 commit comments

Comments
 (0)