2 * Description: The description of particle swarm (PS) Generate-and-test Behavior.
5 NAME VALUE_type Range DefaultV Description
6 c1 real [0, 2] 1.494 PSAgent: learning factor for pbest
7 c2 real [0, 2] 1.494 PSAgent: learning factor for gbest
8 w real [0, 1] 0.729 PSAgent: inertia weight
9 CL real [0, 0.1] 0 PSAgent: chaos factor
10 //Other choices for c1, c2, w, and CL: (2, 2, 0.4, 0.001)
12 * Author Create/Modi Note
13 * Xiaofeng Xie May 11, 2004
14 * Xiaofeng Xie Jul 01, 2008
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * Please acknowledge the author(s) if you use this code in any way.
32 * [1] Kennedy J, Eberhart R C. Particle swarm optimization. IEEE Int. Conf. on
33 * Neural Networks, Perth, Australia, 1995: 1942-1948
34 * For original particle swarm idea
35 * [2] Shi Y H, Eberhart R C. A Modified Particle Swarm Optimizer. IEEE Inter. Conf.
36 * on Evolutionary Computation, Anchorage, Alaska, 1998: 69-73
37 * For the inertia weight: adjust the trade-off between exploitation & exploration
38 * [3] Clerc M, Kennedy J. The particle swarm - explosion, stability, and
39 * convergence in a multidimensional complex space. IEEE Trans. on Evolutionary
40 * Computation. 2002, 6 (1): 58-73
41 * Constriction factor: ensures the convergence
42 * [4] Xie X F, Zhang W J, Yang Z L. A dissipative particle swarm optimization.
43 * Congress on Evolutionary Computation, Hawaii, USA, 2002: 1456-1461
45 * [5] Xie X F, Zhang W J, Bi D C. Optimizing semiconductor devices by self-
46 * organizing particle swarm. Congress on Evolutionary Computation, Oregon, USA,
48 * Further experimental analysis on the convergence of PSO
49 * [6] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
50 * optimization. Genetic and Evolutionary Computation Conference (GECCO),
51 * Seattle, WA, USA, 2004: 238-250
52 * -> a generate-and-test behavior
56 package net
.adaptivebox
.deps
.behavior
;
58 import net
.adaptivebox
.global
.RandomGenerator
;
59 import net
.adaptivebox
.goodness
.IGoodnessCompareEngine
;
60 import net
.adaptivebox
.knowledge
.Library
;
61 import net
.adaptivebox
.knowledge
.SearchPoint
;
62 import net
.adaptivebox
.problem
.ProblemEncoder
;
63 import net
.adaptivebox
.space
.BasicPoint
;
64 import net
.adaptivebox
.space
.DesignSpace
;
66 public class PSGTBehavior
extends AbsGTBehavior
{
67 // Two normally choices for (c1, c2, weight), i.e., (2, 2, 0.4), or (1.494,
68 // 1.494, 0.729) The first is used in dissipative PSO (cf. [4]) as CL>0, and
69 // the second is achieved by using constriction factors (cf. [3])
74 public double weight
= 0.4;
76 //See ref[4], normally be 0.001~0.005
79 // the own memory: store the point that generated in old learning cycle
80 private BasicPoint pold_t
;
82 // the own memory: store the point that generated in last learning cycle
83 private BasicPoint pcurrent_t
;
86 public void setMemPoints(SearchPoint pbest
, BasicPoint pcurrent
, BasicPoint pold
) {
87 pcurrent_t
= pcurrent
;
93 public void generateBehavior(SearchPoint trailPoint
, ProblemEncoder problemEncoder
) {
94 DesignSpace designSpace
= problemEncoder
.getDesignSpace();
96 double[] pold_t_location
= pold_t
.getLocation();
97 double[] pbest_t_location
= pbest_t
.getLocation();
98 double[] pcurrent_t_location
= pcurrent_t
.getLocation();
99 double[] gbest_t_location
= socialLib
.getGbest().getLocation();
100 double[] trailPointLocation
= trailPoint
.getLocation();
102 int DIMENSION
= designSpace
.getDimension();
103 for (int b
= 0; b
< DIMENSION
; b
++) {
104 if (RandomGenerator
.doubleZeroOneRandom() < CL
) {
105 designSpace
.mutationAt(trailPointLocation
, b
);
109 double deltaxb
= weight
* (pcurrent_t_location
[b
] - pold_t_location
[b
])
110 + c1
* RandomGenerator
.doubleZeroOneRandom() * (pbest_t_location
[b
] - pcurrent_t_location
[b
])
111 + c2
* RandomGenerator
.doubleZeroOneRandom() * (gbest_t_location
[b
] - pcurrent_t_location
[b
]);
113 // limitation for delta_x
114 double deltaxbm
= 0.5 * designSpace
.getMagnitudeIn(b
);
116 if (deltaxb
< -deltaxbm
) {
118 } else if (deltaxb
> deltaxbm
) {
122 trailPointLocation
[b
] = pcurrent_t_location
[b
] + deltaxb
;
127 public void testBehavior(SearchPoint trailPoint
, IGoodnessCompareEngine qualityComparator
) {
128 Library
.replace(qualityComparator
, trailPoint
, pbest_t
);
129 pold_t
.importLocation(pcurrent_t
);
130 pcurrent_t
.importLocation(trailPoint
);