diff options
author | Noel Grandin <noel@peralex.com> | 2014-08-07 11:37:32 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-08-07 11:38:47 +0200 |
commit | 414a6e4e0ce35ead40d2a0476f18fba1f746b7bf (patch) | |
tree | 9a12419eea56ea20fc720186815e645c20752bee /nlpsolver | |
parent | 5be4407d0716f78acdcdf24de135af91f17e51be (diff) |
convert EvolutionarySolver source to unix LF
so I dont keep getting problems when moving patches between Windows
and Linux
Change-Id: Ia2323ecb388bf5996279686e1bd2b1676c5ae213
Diffstat (limited to 'nlpsolver')
15 files changed, 964 insertions, 964 deletions
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java index 02043f5b89f2..3107fa8deff1 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java @@ -1,127 +1,127 @@ -package net.adaptivebox.deps;
-
-/**
- * Description: The description of agent with hybrid differential evolution and particle swarm.
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Jun 10, 2004
- * Xiaofeng Xie Jul 01, 2008
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- *
- * @version 1.0
- * @Since MAOS1.0
- *
- * @References:
- * [1] Zhang W J, Xie X F. DEPSO: hybrid particle swarm with differential
- * evolution operator. IEEE International Conference on Systems, Man & Cybernetics,
- * Washington D C, USA, 2003: 3816-3821
- * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
- * optimization. Genetic and Evolutionary Computation Conference (GECCO),
- * Seattle, WA, USA, 2004: 238-250
- * -> an agent perspective
- */
-
-import net.adaptivebox.deps.behavior.*;
-import net.adaptivebox.goodness.IGoodnessCompareEngine;
-import net.adaptivebox.knowledge.*;
-import net.adaptivebox.problem.*;
-import net.adaptivebox.space.*;
-
-public class DEPSAgent implements ILibEngine {
-
- //Describes the problem to be solved
- protected ProblemEncoder problemEncoder;
- //Forms the goodness landscape
- protected IGoodnessCompareEngine qualityComparator;
-
- //store the point that generated in current learning cycle
- protected SearchPoint trailPoint;
-
- //temp variable
- private AbsGTBehavior selectGTBehavior;
-
- //The referred library
- protected Library socialLib;
- //the own memory: store the point that generated in old learning cycle
- protected BasicPoint pold_t;
- //the own memory: store the point that generated in last learning cycle
- protected BasicPoint pcurrent_t;
- //the own memory: store the personal best point
- protected SearchPoint pbest_t;
-
- //Generate-and-test Behaviors
- protected DEGTBehavior deGTBehavior;
- protected PSGTBehavior psGTBehavior;
- public double switchP = 0.5;
-
- public void setLibrary(Library lib) {
- socialLib = lib;
- deGTBehavior.setLibrary(socialLib);
- psGTBehavior.setLibrary(socialLib);
- }
-
- public void setProblemEncoder(ProblemEncoder encoder) {
- problemEncoder = encoder;
- trailPoint = problemEncoder.getFreshSearchPoint();
- pold_t = problemEncoder.getFreshSearchPoint();
- pcurrent_t = problemEncoder.getFreshSearchPoint();
- }
-
- public void setSpecComparator(IGoodnessCompareEngine comparer) {
- qualityComparator = comparer;
- }
-
- public void setPbest(SearchPoint pbest) {
- pbest_t = pbest;
- }
-
- protected AbsGTBehavior getGTBehavior() {
- if (Math.random()<switchP) {
- return deGTBehavior;
- } else {
- return psGTBehavior;
- }
- }
-
- public void setGTBehavior(AbsGTBehavior gtBehavior) {
- if (gtBehavior instanceof DEGTBehavior) {
- deGTBehavior = ((DEGTBehavior)gtBehavior);
- deGTBehavior.setPbest(pbest_t);
- return;
- }
- if (gtBehavior instanceof PSGTBehavior) {
- psGTBehavior = ((PSGTBehavior)gtBehavior);
- psGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
- return;
- }
- }
-
- public void generatePoint() {
- // generates a new point in the search space (S) based on
- // its memory and the library
- selectGTBehavior = this.getGTBehavior();
- selectGTBehavior.generateBehavior(trailPoint, problemEncoder);
- //evaluate into goodness information
- problemEncoder.evaluate(trailPoint);
- }
-
- public void learn() {
- selectGTBehavior.testBehavior(trailPoint, qualityComparator);
- }
-
- public SearchPoint getMGState() {
- return trailPoint;
- }
-}
-
+package net.adaptivebox.deps; + +/** + * Description: The description of agent with hybrid differential evolution and particle swarm. + * + * @ Author Create/Modi Note + * Xiaofeng Xie Jun 10, 2004 + * Xiaofeng Xie Jul 01, 2008 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + * + * @version 1.0 + * @Since MAOS1.0 + * + * @References: + * [1] Zhang W J, Xie X F. DEPSO: hybrid particle swarm with differential + * evolution operator. IEEE International Conference on Systems, Man & Cybernetics, + * Washington D C, USA, 2003: 3816-3821 + * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical + * optimization. Genetic and Evolutionary Computation Conference (GECCO), + * Seattle, WA, USA, 2004: 238-250 + * -> an agent perspective + */ + +import net.adaptivebox.deps.behavior.*; +import net.adaptivebox.goodness.IGoodnessCompareEngine; +import net.adaptivebox.knowledge.*; +import net.adaptivebox.problem.*; +import net.adaptivebox.space.*; + +public class DEPSAgent implements ILibEngine { + + //Describes the problem to be solved + protected ProblemEncoder problemEncoder; + //Forms the goodness landscape + protected IGoodnessCompareEngine qualityComparator; + + //store the point that generated in current learning cycle + protected SearchPoint trailPoint; + + //temp variable + private AbsGTBehavior selectGTBehavior; + + //The referred library + protected Library socialLib; + //the own memory: store the point that generated in old learning cycle + protected BasicPoint pold_t; + //the own memory: store the point that generated in last learning cycle + protected BasicPoint pcurrent_t; + //the own memory: store the personal best point + protected SearchPoint pbest_t; + + //Generate-and-test Behaviors + protected DEGTBehavior deGTBehavior; + protected PSGTBehavior psGTBehavior; + public double switchP = 0.5; + + public void setLibrary(Library lib) { + socialLib = lib; + deGTBehavior.setLibrary(socialLib); + psGTBehavior.setLibrary(socialLib); + } + + public void setProblemEncoder(ProblemEncoder encoder) { + problemEncoder = encoder; + trailPoint = problemEncoder.getFreshSearchPoint(); + pold_t = problemEncoder.getFreshSearchPoint(); + pcurrent_t = problemEncoder.getFreshSearchPoint(); + } + + public void setSpecComparator(IGoodnessCompareEngine comparer) { + qualityComparator = comparer; + } + + public void setPbest(SearchPoint pbest) { + pbest_t = pbest; + } + + protected AbsGTBehavior getGTBehavior() { + if (Math.random()<switchP) { + return deGTBehavior; + } else { + return psGTBehavior; + } + } + + public void setGTBehavior(AbsGTBehavior gtBehavior) { + if (gtBehavior instanceof DEGTBehavior) { + deGTBehavior = ((DEGTBehavior)gtBehavior); + deGTBehavior.setPbest(pbest_t); + return; + } + if (gtBehavior instanceof PSGTBehavior) { + psGTBehavior = ((PSGTBehavior)gtBehavior); + psGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t); + return; + } + } + + public void generatePoint() { + // generates a new point in the search space (S) based on + // its memory and the library + selectGTBehavior = this.getGTBehavior(); + selectGTBehavior.generateBehavior(trailPoint, problemEncoder); + //evaluate into goodness information + problemEncoder.evaluate(trailPoint); + } + + public void learn() { + selectGTBehavior.testBehavior(trailPoint, qualityComparator); + } + + public SearchPoint getMGState() { + return trailPoint; + } +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java index 159ce7c73328..b4b9b4ca6a5e 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java @@ -1,36 +1,36 @@ -/**
- * Description: The description of generate-and-test behavior.
- *
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie May 17, 2004
- * Xiaofeng Xie Jul 01, 2008
- *
- * @version 1.0
- * @Since MAOS1.0
- *
- * @References:
- * [1] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
- * optimization. Genetic and Evolutionary Computation Conference (GECCO),
- * Seattle, WA, USA, 2004: 238-250
- * -> a generate-and-test behavior
- */
-package net.adaptivebox.deps.behavior;
-
-import net.adaptivebox.goodness.*;
-import net.adaptivebox.knowledge.*;
-import net.adaptivebox.problem.*;
-
-abstract public class AbsGTBehavior {
- //The referred social library
- protected Library socialLib;
-
- public void setLibrary(Library lib) {
- socialLib = lib;
- }
-
- abstract public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder);
-
- abstract public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator);
-}
-
+/** + * Description: The description of generate-and-test behavior. + * + * + * @ Author Create/Modi Note + * Xiaofeng Xie May 17, 2004 + * Xiaofeng Xie Jul 01, 2008 + * + * @version 1.0 + * @Since MAOS1.0 + * + * @References: + * [1] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical + * optimization. Genetic and Evolutionary Computation Conference (GECCO), + * Seattle, WA, USA, 2004: 238-250 + * -> a generate-and-test behavior + */ +package net.adaptivebox.deps.behavior; + +import net.adaptivebox.goodness.*; +import net.adaptivebox.knowledge.*; +import net.adaptivebox.problem.*; + +abstract public class AbsGTBehavior { + //The referred social library + protected Library socialLib; + + public void setLibrary(Library lib) { + socialLib = lib; + } + + abstract public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder); + + abstract public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator); +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java index 50666ff4f8f5..7867fdb49db2 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java @@ -1,81 +1,81 @@ -/**
- * Description: The description of differential evolution Generate-and-Test Behavior.
-
- #Supported parameters:
- NAME VALUE_type Range DefaultV Description
- FACTOR real (0, 1.2] 0.5 DEAgent: scale constant
- CR real [0, 1] 0.9 DEAgent: crossover constant
- //Other choices for FACTOR and CR: (0.5, 0.1)
-
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie May 11, 2004
- * Xiaofeng Xie Jul 01, 2008
- *
- * @version 1.0
- * @Since MAOS1.0
- *
- * @References:
- * [1] Storn R, Price K. Differential evolution - a simple and efficient
- * heuristic for global optimization over continuous spaces. Journal of
- * Global Optimization, 1997, 11: 341-359
- * @ The original differential evolution idea
- * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
- * optimization. Genetic and Evolutionary Computation Conference (GECCO),
- * Seattle, WA, USA, 2004: 238-250
- * -> a generate-and-test behavior
- */
-
-package net.adaptivebox.deps.behavior;
-
-import net.adaptivebox.goodness.*;
-import net.adaptivebox.global.*;
-import net.adaptivebox.knowledge.*;
-import net.adaptivebox.problem.*;
-import net.adaptivebox.space.*;
-
-public class DEGTBehavior extends AbsGTBehavior implements ILibEngine {
- public int DVNum = 2; //Number of differential vectors, normally be 1 or 2
- public double FACTOR = 0.5; //scale constant: (0, 1.2], normally be 0.5
- public double CR = 0.9; //crossover constant: [0, 1], normally be 0.1 or 0.9
-
- //the own memory: store the point that generated in last learning cycle
- protected SearchPoint pbest_t;
-
- public void setPbest(SearchPoint pbest) {
- pbest_t = pbest;
- }
-
- public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) {
- SearchPoint gbest_t = socialLib.getGbest();
-
- BasicPoint[] referPoints = getReferPoints();
- int DIMENSION = problemEncoder.getDesignSpace().getDimension();
- int rj = RandomGenerator.intRangeRandom(0, DIMENSION-1);
- for (int k=0; k<DIMENSION; k++) {
- if (Math.random()<CR || k == DIMENSION-1) {
- double Dabcd = 0;
- for(int i=0; i<referPoints.length; i++) {
- Dabcd += Math.pow(-1, i%2)*referPoints[i].getLocation()[rj];
- }
- trailPoint.getLocation()[rj] = gbest_t.getLocation()[rj]+FACTOR*Dabcd;
- } else {
- trailPoint.getLocation()[rj] = pbest_t.getLocation()[rj];
- }
- rj = (rj+1)%DIMENSION;
- }
- }
-
- public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) {
- Library.replace(qualityComparator, trailPoint, pbest_t);
- }
-
- protected SearchPoint[] getReferPoints() {
- SearchPoint[] referPoints = new SearchPoint[DVNum*2];
- for(int i=0; i<referPoints.length; i++) {
- referPoints[i] = socialLib.getSelectedPoint(RandomGenerator.intRangeRandom(0, socialLib.getPopSize()-1));
- }
- return referPoints;
- }
-}
-
+/** + * Description: The description of differential evolution Generate-and-Test Behavior. + + #Supported parameters: + NAME VALUE_type Range DefaultV Description + FACTOR real (0, 1.2] 0.5 DEAgent: scale constant + CR real [0, 1] 0.9 DEAgent: crossover constant + //Other choices for FACTOR and CR: (0.5, 0.1) + + * + * @ Author Create/Modi Note + * Xiaofeng Xie May 11, 2004 + * Xiaofeng Xie Jul 01, 2008 + * + * @version 1.0 + * @Since MAOS1.0 + * + * @References: + * [1] Storn R, Price K. Differential evolution - a simple and efficient + * heuristic for global optimization over continuous spaces. Journal of + * Global Optimization, 1997, 11: 341-359 + * @ The original differential evolution idea + * [2] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical + * optimization. Genetic and Evolutionary Computation Conference (GECCO), + * Seattle, WA, USA, 2004: 238-250 + * -> a generate-and-test behavior + */ + +package net.adaptivebox.deps.behavior; + +import net.adaptivebox.goodness.*; +import net.adaptivebox.global.*; +import net.adaptivebox.knowledge.*; +import net.adaptivebox.problem.*; +import net.adaptivebox.space.*; + +public class DEGTBehavior extends AbsGTBehavior implements ILibEngine { + public int DVNum = 2; //Number of differential vectors, normally be 1 or 2 + public double FACTOR = 0.5; //scale constant: (0, 1.2], normally be 0.5 + public double CR = 0.9; //crossover constant: [0, 1], normally be 0.1 or 0.9 + + //the own memory: store the point that generated in last learning cycle + protected SearchPoint pbest_t; + + public void setPbest(SearchPoint pbest) { + pbest_t = pbest; + } + + public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) { + SearchPoint gbest_t = socialLib.getGbest(); + + BasicPoint[] referPoints = getReferPoints(); + int DIMENSION = problemEncoder.getDesignSpace().getDimension(); + int rj = RandomGenerator.intRangeRandom(0, DIMENSION-1); + for (int k=0; k<DIMENSION; k++) { + if (Math.random()<CR || k == DIMENSION-1) { + double Dabcd = 0; + for(int i=0; i<referPoints.length; i++) { + Dabcd += Math.pow(-1, i%2)*referPoints[i].getLocation()[rj]; + } + trailPoint.getLocation()[rj] = gbest_t.getLocation()[rj]+FACTOR*Dabcd; + } else { + trailPoint.getLocation()[rj] = pbest_t.getLocation()[rj]; + } + rj = (rj+1)%DIMENSION; + } + } + + public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) { + Library.replace(qualityComparator, trailPoint, pbest_t); + } + + protected SearchPoint[] getReferPoints() { + SearchPoint[] referPoints = new SearchPoint[DVNum*2]; + for(int i=0; i<referPoints.length; i++) { + referPoints[i] = socialLib.getSelectedPoint(RandomGenerator.intRangeRandom(0, socialLib.getPopSize()-1)); + } + return referPoints; + } +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java index b4ae0017eb69..c1e8db0123ae 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java @@ -1,117 +1,117 @@ -/**
- * Description: The description of particle swarm (PS) Generate-and-test Behavior.
- *
- #Supported parameters:
- NAME VALUE_type Range DefaultV Description
- c1 real [0, 2] 1.494 PSAgent: learning factor for pbest
- c2 real [0, 2] 1.494 PSAgent: learning factor for gbest
- w real [0, 1] 0.729 PSAgent: inertia weight
- CL real [0, 0.1] 0 PSAgent: chaos factor
- //Other choices for c1, c2, w, and CL: (2, 2, 0.4, 0.001)
-
- * @ Author Create/Modi Note
- * Xiaofeng Xie May 11, 2004
- * Xiaofeng Xie Jul 01, 2008
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- *
- * @version 1.0
- * @Since MAOS1.0
- *
- * @References:
- * [1] Kennedy J, Eberhart R C. Particle swarm optimization. IEEE Int. Conf. on
- * Neural Networks, Perth, Australia, 1995: 1942-1948
- * @ For original particle swarm idea
- * [2] Shi Y H, Eberhart R C. A Modified Particle Swarm Optimizer. IEEE Inter. Conf.
- * on Evolutionary Computation, Anchorage, Alaska, 1998: 69-73
- * @ For the inertia weight: adjust the trade-off between exploitation & exploration
- * [3] Clerc M, Kennedy J. The particle swarm - explosion, stability, and
- * convergence in a multidimensional complex space. IEEE Trans. on Evolutionary
- * Computation. 2002, 6 (1): 58-73
- * @ Constriction factor: ensures the convergence
- * [4] Xie X F, Zhang W J, Yang Z L. A dissipative particle swarm optimization.
- * Congress on Evolutionary Computation, Hawaii, USA, 2002: 1456-1461
- * @ The CL parameter
- * [5] Xie X F, Zhang W J, Bi D C. Optimizing semiconductor devices by self-
- * organizing particle swarm. Congress on Evolutionary Computation, Oregon, USA,
- * 2004: 2017-2022
- * @ Further experimental analysis on the convergence of PSO
- * [6] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical
- * optimization. Genetic and Evolutionary Computation Conference (GECCO),
- * Seattle, WA, USA, 2004: 238-250
- * -> a generate-and-test behavior
- *
- */
-
-package net.adaptivebox.deps.behavior;
-
-import net.adaptivebox.goodness.*;
-import net.adaptivebox.knowledge.*;
-import net.adaptivebox.problem.*;
-import net.adaptivebox.space.*;
-
-public class PSGTBehavior extends AbsGTBehavior {
- // Two normally choices for (c1, c2, weight), i.e., (2, 2, 0.4), or (1.494, 1.494, 0.729)
- // The first is used in dissipative PSO (cf. [4]) as CL>0, and the second is achieved by using
- // constriction factors (cf. [3])
- public double c1=2;
- public double c2=2;
- public double weight = 0.4; //inertia weight
-
- public double CL=0; //See ref[4], normally be 0.001~0.005
-
- //the own memory: store the point that generated in old learning cycle
- protected BasicPoint pold_t;
- //the own memory: store the point that generated in last learning cycle
- protected BasicPoint pcurrent_t;
- //the own memory: store the personal best point
- protected SearchPoint pbest_t;
-
- public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold) {
- pcurrent_t = pcurrent;
- pbest_t = pbest;
- pold_t = pold;
- }
-
- public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) {
- SearchPoint gbest_t = socialLib.getGbest();
- DesignSpace designSpace = problemEncoder.getDesignSpace();
- int DIMENSION = designSpace.getDimension();
- double deltaxb, deltaxbm;
- for (int b=0;b<DIMENSION;b++) {
- if (Math.random()<CL) {
- designSpace.mutationAt(trailPoint.getLocation(), b);
- } else {
- deltaxb = weight*(pcurrent_t.getLocation()[b]-pold_t.getLocation()[b])
- + c1*Math.random()*(pbest_t.getLocation()[b]-pcurrent_t.getLocation()[b])
- + c2*Math.random()*(gbest_t.getLocation()[b]-pcurrent_t.getLocation()[b]);
- //limitation for delta_x
- deltaxbm = 0.5*designSpace.getMagnitudeIn(b);
- if(deltaxb<-deltaxbm) {
- deltaxb = -deltaxbm;
- } else if (deltaxb>deltaxbm) {
- deltaxb = deltaxbm;
- }
- trailPoint.getLocation()[b] = pcurrent_t.getLocation()[b]+deltaxb;
- }
- }
- }
-
- public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) {
- Library.replace(qualityComparator, trailPoint, pbest_t);
- pold_t.importLocation(pcurrent_t);
- pcurrent_t.importLocation(trailPoint);
- }
-
-}
-
+/** + * Description: The description of particle swarm (PS) Generate-and-test Behavior. + * + #Supported parameters: + NAME VALUE_type Range DefaultV Description + c1 real [0, 2] 1.494 PSAgent: learning factor for pbest + c2 real [0, 2] 1.494 PSAgent: learning factor for gbest + w real [0, 1] 0.729 PSAgent: inertia weight + CL real [0, 0.1] 0 PSAgent: chaos factor + //Other choices for c1, c2, w, and CL: (2, 2, 0.4, 0.001) + + * @ Author Create/Modi Note + * Xiaofeng Xie May 11, 2004 + * Xiaofeng Xie Jul 01, 2008 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + * + * @version 1.0 + * @Since MAOS1.0 + * + * @References: + * [1] Kennedy J, Eberhart R C. Particle swarm optimization. IEEE Int. Conf. on + * Neural Networks, Perth, Australia, 1995: 1942-1948 + * @ For original particle swarm idea + * [2] Shi Y H, Eberhart R C. A Modified Particle Swarm Optimizer. IEEE Inter. Conf. + * on Evolutionary Computation, Anchorage, Alaska, 1998: 69-73 + * @ For the inertia weight: adjust the trade-off between exploitation & exploration + * [3] Clerc M, Kennedy J. The particle swarm - explosion, stability, and + * convergence in a multidimensional complex space. IEEE Trans. on Evolutionary + * Computation. 2002, 6 (1): 58-73 + * @ Constriction factor: ensures the convergence + * [4] Xie X F, Zhang W J, Yang Z L. A dissipative particle swarm optimization. + * Congress on Evolutionary Computation, Hawaii, USA, 2002: 1456-1461 + * @ The CL parameter + * [5] Xie X F, Zhang W J, Bi D C. Optimizing semiconductor devices by self- + * organizing particle swarm. Congress on Evolutionary Computation, Oregon, USA, + * 2004: 2017-2022 + * @ Further experimental analysis on the convergence of PSO + * [6] X F Xie, W J Zhang. SWAF: swarm algorithm framework for numerical + * optimization. Genetic and Evolutionary Computation Conference (GECCO), + * Seattle, WA, USA, 2004: 238-250 + * -> a generate-and-test behavior + * + */ + +package net.adaptivebox.deps.behavior; + +import net.adaptivebox.goodness.*; +import net.adaptivebox.knowledge.*; +import net.adaptivebox.problem.*; +import net.adaptivebox.space.*; + +public class PSGTBehavior extends AbsGTBehavior { + // Two normally choices for (c1, c2, weight), i.e., (2, 2, 0.4), or (1.494, 1.494, 0.729) + // The first is used in dissipative PSO (cf. [4]) as CL>0, and the second is achieved by using + // constriction factors (cf. [3]) + public double c1=2; + public double c2=2; + public double weight = 0.4; //inertia weight + + public double CL=0; //See ref[4], normally be 0.001~0.005 + + //the own memory: store the point that generated in old learning cycle + protected BasicPoint pold_t; + //the own memory: store the point that generated in last learning cycle + protected BasicPoint pcurrent_t; + //the own memory: store the personal best point + protected SearchPoint pbest_t; + + public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold) { + pcurrent_t = pcurrent; + pbest_t = pbest; + pold_t = pold; + } + + public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder) { + SearchPoint gbest_t = socialLib.getGbest(); + DesignSpace designSpace = problemEncoder.getDesignSpace(); + int DIMENSION = designSpace.getDimension(); + double deltaxb, deltaxbm; + for (int b=0;b<DIMENSION;b++) { + if (Math.random()<CL) { + designSpace.mutationAt(trailPoint.getLocation(), b); + } else { + deltaxb = weight*(pcurrent_t.getLocation()[b]-pold_t.getLocation()[b]) + + c1*Math.random()*(pbest_t.getLocation()[b]-pcurrent_t.getLocation()[b]) + + c2*Math.random()*(gbest_t.getLocation()[b]-pcurrent_t.getLocation()[b]); + //limitation for delta_x + deltaxbm = 0.5*designSpace.getMagnitudeIn(b); + if(deltaxb<-deltaxbm) { + deltaxb = -deltaxbm; + } else if (deltaxb>deltaxbm) { + deltaxb = deltaxbm; + } + trailPoint.getLocation()[b] = pcurrent_t.getLocation()[b]+deltaxb; + } + } + } + + public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator) { + Library.replace(qualityComparator, trailPoint, pbest_t); + pold_t.importLocation(pcurrent_t); + pcurrent_t.importLocation(trailPoint); + } + +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java index 9ca77d32ca8f..637d9d016088 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java @@ -1,24 +1,24 @@ -/**
- * Description: provide the encoded information for objectives
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Feb 10, 2004
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- */
-
-package net.adaptivebox.encode;
-
-public interface IEncodeEngine{
- abstract public double[] getEncodeInfo();
-}
+/** + * Description: provide the encoded information for objectives + * + * @ Author Create/Modi Note + * Xiaofeng Xie Feb 10, 2004 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + */ + +package net.adaptivebox.encode; + +public interface IEncodeEngine{ + abstract public double[] getEncodeInfo(); +} diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java index 4071cf8c7540..98feb5639a53 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicArray.java @@ -1,31 +1,31 @@ -/**
- * Description: basic operations on Arrays
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Oct. 9, 2002
- *
- */
-
-package net.adaptivebox.global;
-
-public class BasicArray {
- public static double getMinValue(double[] v) {
- double mv = Double.MAX_VALUE;
- for (int i=0; i<v.length; i++) {
- if (v[i]<mv) {
- mv=v[i];
- }
- }
- return mv;
- }
- public static double getMaxValue(double[] v) {
- double mv = -Double.MAX_VALUE;
- for (int i=0; i<v.length; i++) {
- if (v[i]>mv) {
- mv=v[i];
- }
- }
- return mv;
- }
-
-}
\ No newline at end of file +/** + * Description: basic operations on Arrays + * + * @ Author Create/Modi Note + * Xiaofeng Xie Oct. 9, 2002 + * + */ + +package net.adaptivebox.global; + +public class BasicArray { + public static double getMinValue(double[] v) { + double mv = Double.MAX_VALUE; + for (int i=0; i<v.length; i++) { + if (v[i]<mv) { + mv=v[i]; + } + } + return mv; + } + public static double getMaxValue(double[] v) { + double mv = -Double.MAX_VALUE; + for (int i=0; i<v.length; i++) { + if (v[i]>mv) { + mv=v[i]; + } + } + return mv; + } + +} diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java index f6e063ff08a6..383e9c2ed202 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicBound.java @@ -1,93 +1,93 @@ -/**
- * Description: provide an bound, and the corresponding operations
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Oct. 9, 2002
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- */
-
-package net.adaptivebox.global;
-
-public class BasicBound {
- public static final double MINDOUBLE= -1e308;
- public static final double MAXDOUBLE= 1e308;
-
- public double minValue = MINDOUBLE;
- public double maxValue = MAXDOUBLE;
- public BasicBound() {
- }
-
- public BasicBound(double min, double max) {
- minValue = Math.min(min, max);
- maxValue = Math.max(min, max);
- }
-
- public double getLength() {
- return Math.abs(maxValue-minValue);
- }
-
- public boolean isSatisfyCondition(double child){
- if(child > maxValue || child < minValue) {
- return(false);
- }
- return(true);
- }
-
- public double boundAdjust(double value){
- if(value > maxValue) {
- value = maxValue;
- } else if (value < minValue) {
- value = minValue;
- }
- return value;
- }
-
- public double annulusAdjust (double value) {
- if(value > maxValue) {
- double extendsLen = (value-maxValue)%getLength();
- value = minValue+extendsLen;
- } else if (value < minValue) {
- double extendsLen = (minValue-value)%getLength();
- value = maxValue-extendsLen;
- }
- return value;
- }
-
- public static BasicBound getBound(double[] data) {
- BasicBound bound = new BasicBound();
- if(data!=null) {
- if(data.length>0) {
- bound.minValue = data[0];
- bound.maxValue = data[0];
- for(int i=1; i<data.length; i++) {
- bound.minValue = Math.min(bound.minValue, data[i]);
- bound.maxValue = Math.max(bound.maxValue, data[i]);
- }
-
- }
- }
- return bound;
- }
-
- public double randomAdjust (double value){
- if(value > maxValue || value < minValue) {
- value = getRandomValue();
- }
- return value;
- }
-
- public double getRandomValue(){
- return RandomGenerator.doubleRangeRandom(minValue, maxValue);
- }
-}
+/** + * Description: provide an bound, and the corresponding operations + * + * @ Author Create/Modi Note + * Xiaofeng Xie Oct. 9, 2002 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + */ + +package net.adaptivebox.global; + +public class BasicBound { + public static final double MINDOUBLE= -1e308; + public static final double MAXDOUBLE= 1e308; + + public double minValue = MINDOUBLE; + public double maxValue = MAXDOUBLE; + public BasicBound() { + } + + public BasicBound(double min, double max) { + minValue = Math.min(min, max); + maxValue = Math.max(min, max); + } + + public double getLength() { + return Math.abs(maxValue-minValue); + } + + public boolean isSatisfyCondition(double child){ + if(child > maxValue || child < minValue) { + return(false); + } + return(true); + } + + public double boundAdjust(double value){ + if(value > maxValue) { + value = maxValue; + } else if (value < minValue) { + value = minValue; + } + return value; + } + + public double annulusAdjust (double value) { + if(value > maxValue) { + double extendsLen = (value-maxValue)%getLength(); + value = minValue+extendsLen; + } else if (value < minValue) { + double extendsLen = (minValue-value)%getLength(); + value = maxValue-extendsLen; + } + return value; + } + + public static BasicBound getBound(double[] data) { + BasicBound bound = new BasicBound(); + if(data!=null) { + if(data.length>0) { + bound.minValue = data[0]; + bound.maxValue = data[0]; + for(int i=1; i<data.length; i++) { + bound.minValue = Math.min(bound.minValue, data[i]); + bound.maxValue = Math.max(bound.maxValue, data[i]); + } + + } + } + return bound; + } + + public double randomAdjust (double value){ + if(value > maxValue || value < minValue) { + value = getRandomValue(); + } + return value; + } + + public double getRandomValue(){ + return RandomGenerator.doubleRangeRandom(minValue, maxValue); + } +} diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java index 435577e46da5..8c21d8de3f1f 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/BasicTag.java @@ -1,40 +1,40 @@ -/**
- * Description: defines some static constant values.
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Sep 22, 2000 xiaofengxie@tsinghua.org.cn
- *
- * @version 1.0
- * @Since MAOS1.0
- */
-
-package net.adaptivebox.global;
-
-
-public class BasicTag {
- public static final String COMMAND_TAG = "%";
- public static final String TAB_TAG = "\t";
- public static final String LEFT_SMALL_BRACKET_TAG = "(";
- public static final String RIGHT_SMALL_BRACKET_TAG = ")";
- public static final String LEFT_LARGE_BRACKET_TAG = "{";
- public static final String RIGHT_LARGE_BRACKET_TAG = "}";
- public static final String LEFT_BRACKET_TAG = "[";
- public static final String RIGHT_BRACKET_TAG = "]";
- public static final String EQUAL_TAG = "=";
- public static final String SPACE_TAG = " ";
- public static final String SEMICOLON_TAG = ";";
- public static final String COLON_TAG = ":";
- public static final String COMMA_TAG = ",";
- public static final String DOT_TAG = ".";
- public static final String NULL_SEPARATE_TAG = " \t";
- public static final String SEPARATE_TAG = "|";
- public static final String UNDERLINE_TAG = "_";
- public static final String INC_TAG = "+";
- public static final String DEC_TAG = "-";
- public static final String ZERO_TAG = "0";
- public static final String EXP_TAG = "E";
- public static final String S_EXP_TAG = "e";
- public static final String FILE_SEP_TAG = System.getProperty("file.separator");
- public static final String RETURN_TAG = System.getProperty("line.separator");
-}
-
+/** + * Description: defines some static constant values. + * + * @ Author Create/Modi Note + * Xiaofeng Xie Sep 22, 2000 xiaofengxie@tsinghua.org.cn + * + * @version 1.0 + * @Since MAOS1.0 + */ + +package net.adaptivebox.global; + + +public class BasicTag { + public static final String COMMAND_TAG = "%"; + public static final String TAB_TAG = "\t"; + public static final String LEFT_SMALL_BRACKET_TAG = "("; + public static final String RIGHT_SMALL_BRACKET_TAG = ")"; + public static final String LEFT_LARGE_BRACKET_TAG = "{"; + public static final String RIGHT_LARGE_BRACKET_TAG = "}"; + public static final String LEFT_BRACKET_TAG = "["; + public static final String RIGHT_BRACKET_TAG = "]"; + public static final String EQUAL_TAG = "="; + public static final String SPACE_TAG = " "; + public static final String SEMICOLON_TAG = ";"; + public static final String COLON_TAG = ":"; + public static final String COMMA_TAG = ","; + public static final String DOT_TAG = "."; + public static final String NULL_SEPARATE_TAG = " \t"; + public static final String SEPARATE_TAG = "|"; + public static final String UNDERLINE_TAG = "_"; + public static final String INC_TAG = "+"; + public static final String DEC_TAG = "-"; + public static final String ZERO_TAG = "0"; + public static final String EXP_TAG = "E"; + public static final String S_EXP_TAG = "e"; + public static final String FILE_SEP_TAG = System.getProperty("file.separator"); + public static final String RETURN_TAG = System.getProperty("line.separator"); +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java index 1cd783f54404..7bfe6df9511e 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/CompareValue.java @@ -1,20 +1,20 @@ -/**
- * Description: Global value for comparison.
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Jun 15, 2002
- * Xiaofeng Xie Feb 18, 2004
- *
- * @version 1.0
- * @Since MAOS1.0
- */
-
-
-package net.adaptivebox.global;
-
-public class CompareValue {
- public static final int LARGER_THAN = 2;
- public static final int EQUAL_TO = 1;
- public static final int LESS_THAN = 0;
- public static final int INVALID = -1;
-}
+/** + * Description: Global value for comparison. + * + * @ Author Create/Modi Note + * Xiaofeng Xie Jun 15, 2002 + * Xiaofeng Xie Feb 18, 2004 + * + * @version 1.0 + * @Since MAOS1.0 + */ + + +package net.adaptivebox.global; + +public class CompareValue { + public static final int LARGER_THAN = 2; + public static final int EQUAL_TO = 1; + public static final int LESS_THAN = 0; + public static final int INVALID = -1; +} diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java index 3f11dc59f98d..1721b240217c 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/GlobalCompare.java @@ -1,44 +1,44 @@ -/**
- * Description: Global package for comparison.
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Jun 15, 2002 xiaofengxie@tsinghua.org.cn
- *
- *
- * @version 1.0
- * @Since MAOS1.0
- */
-
-
-package net.adaptivebox.global;
-
-public class GlobalCompare {
-
-/* compare the data1 and data2, if data1=data2, return 0
- * if data1 < data2, return LESS_THAN, else if data1 > data2, LARGER_THAN
- **/
- static public int compare(double data1, double data2) {
- if (data1 < data2)
- return CompareValue.LESS_THAN;
- else if (data1 > data2)
- return CompareValue.LARGER_THAN;
- else
- return CompareValue.EQUAL_TO;
- }
-
-/* check the magnitude of two array, the frontial is more important
- **/
- public static int compareArray(double[] fit1, double[] fit2) {
- if (fit1.length!=fit2.length) {
- return CompareValue.INVALID; //error
- }
- for (int i=0; i<fit1.length; i++) {
- if (fit1[i]>fit2[i]) {
- return CompareValue.LARGER_THAN; //Large than
- } else if (fit1[i]<fit2[i]){
- return CompareValue.LESS_THAN; //Less than
- }
- }
- return CompareValue.EQUAL_TO; //same
- }
-}
+/** + * Description: Global package for comparison. + * + * @ Author Create/Modi Note + * Xiaofeng Xie Jun 15, 2002 xiaofengxie@tsinghua.org.cn + * + * + * @version 1.0 + * @Since MAOS1.0 + */ + + +package net.adaptivebox.global; + +public class GlobalCompare { + +/* compare the data1 and data2, if data1=data2, return 0 + * if data1 < data2, return LESS_THAN, else if data1 > data2, LARGER_THAN + **/ + static public int compare(double data1, double data2) { + if (data1 < data2) + return CompareValue.LESS_THAN; + else if (data1 > data2) + return CompareValue.LARGER_THAN; + else + return CompareValue.EQUAL_TO; + } + +/* check the magnitude of two array, the frontial is more important + **/ + public static int compareArray(double[] fit1, double[] fit2) { + if (fit1.length!=fit2.length) { + return CompareValue.INVALID; //error + } + for (int i=0; i<fit1.length; i++) { + if (fit1[i]>fit2[i]) { + return CompareValue.LARGER_THAN; //Large than + } else if (fit1[i]<fit2[i]){ + return CompareValue.LESS_THAN; //Less than + } + } + return CompareValue.EQUAL_TO; //same + } +} diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java index 18e9832e31bc..5dd4b7ef8719 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/global/IUpdateCycleEngine.java @@ -1,24 +1,24 @@ -/**
- * Description: provide the inteface for updating according to the cycle number
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Feb 18, 2004
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- */
-
-package net.adaptivebox.global;
-
-public interface IUpdateCycleEngine {
- public void updateCycle(int t);
+/** + * Description: provide the inteface for updating according to the cycle number + * + * @ Author Create/Modi Note + * Xiaofeng Xie Feb 18, 2004 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + */ + +package net.adaptivebox.global; + +public interface IUpdateCycleEngine { + public void updateCycle(int t); }
\ No newline at end of file diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java index a5deb6315954..2e91e65cde51 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java @@ -1,123 +1,123 @@ -/**
- * Description: Encodes the specified problem into encoded information for
- * forming the goodness landscape.
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie May 31, 2000
- * Xiaofeng Xie Sep. 19, 2002
- * Xiaofeng Xie Mar. 01, 2003
- * Xiaofeng Xie May 11, 2004
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- *
- * @version 1.0
- * @Since MAOS1.0
- */
-
-package net.adaptivebox.problem;
-
-import net.adaptivebox.global.*;
-import net.adaptivebox.space.*;
-import net.adaptivebox.encode.*;
-import net.adaptivebox.knowledge.*;
-
-public abstract class ProblemEncoder {
- //Store the calculated results for the responses
- double[] tempResponseSet; //temp values
- double[] tempLocation; //temp values
-
- //the search space (S)
- protected DesignSpace designSpace = null;
-
- // For evaluate the response vector into encoded vector double[2]
- protected EvalStruct evalStruct = null;
-
- protected ProblemEncoder(int paramNum, int targetNum) throws Exception {
- designSpace = new DesignSpace(paramNum);
- evalStruct = new EvalStruct(targetNum);
- tempLocation = new double[paramNum];
- tempResponseSet = new double[targetNum];
- }
-
- public DesignSpace getDesignSpace() {
- return designSpace;
- }
-
- public EvalStruct getEvalStruct() {
- return evalStruct;
- }
-
- //set the default information for each dimension of search space (S)
- protected void setDefaultXAt(int i, double min, double max, double grain) {
- DesignDim dd = new DesignDim();
- dd.grain = grain;
- dd.paramBound = new BasicBound(min, max);
- designSpace.setElemAt(dd, i);
- }
-
- protected void setDefaultXAt(int i, double min, double max) {
- DesignDim dd = new DesignDim();
- dd.paramBound = new BasicBound(min, max);
- designSpace.setElemAt(dd, i);
- }
-
- //set the default information for evaluation each response
- protected void setDefaultYAt(int i, double min, double max) {
- EvalElement ee = new EvalElement();
- ee.targetBound = new BasicBound(min, max);
- evalStruct.setElemAt(ee, i);
- }
-
- protected void setDefaultYAt(int i, double min, double max, double weight) {
- EvalElement ee = new EvalElement();
- ee.targetBound = new BasicBound(min, max);
- ee.weight = weight;
- evalStruct.setElemAt(ee, i);
- }
-
- //get a fresh point
- public SearchPoint getFreshSearchPoint() {
- return new SearchPoint(designSpace.getDimension());
- }
-
- //get an encoded point
- public SearchPoint getEncodedSearchPoint() {
- SearchPoint point = getFreshSearchPoint();
- designSpace.initializeGene(point.getLocation());
- evaluate(point);
- return point;
- }
-
- //evaluate the point into encoded information
- public void evaluate(SearchPoint point) {
- //copy to temp point
- System.arraycopy(point.getLocation(), 0, this.tempLocation, 0, tempLocation.length);
- //mapping the temp point to original search space S
- designSpace.getMappingPoint(tempLocation);
- //calculate based on the temp point
- calcTargets(tempResponseSet, tempLocation);
- evalStruct.evaluate(point.getEncodeInfo(), tempResponseSet);
- point.setObjectiveValue(tempResponseSet[0]);
- }
-
- //calcuate each response, must be implemented
- abstract protected double calcTargetAt(int index, double[] VX);
-
- // calculate all the responses VY[] based on given point VX[]
- private void calcTargets(double[] VY, double[] VX) {
- for(int i=0; i<VY.length; i++) {
- VY[i] = calcTargetAt(i, VX);
- }
- }
-}
-
+/** + * Description: Encodes the specified problem into encoded information for + * forming the goodness landscape. + * + * @ Author Create/Modi Note + * Xiaofeng Xie May 31, 2000 + * Xiaofeng Xie Sep. 19, 2002 + * Xiaofeng Xie Mar. 01, 2003 + * Xiaofeng Xie May 11, 2004 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + * + * @version 1.0 + * @Since MAOS1.0 + */ + +package net.adaptivebox.problem; + +import net.adaptivebox.global.*; +import net.adaptivebox.space.*; +import net.adaptivebox.encode.*; +import net.adaptivebox.knowledge.*; + +public abstract class ProblemEncoder { + //Store the calculated results for the responses + double[] tempResponseSet; //temp values + double[] tempLocation; //temp values + + //the search space (S) + protected DesignSpace designSpace = null; + + // For evaluate the response vector into encoded vector double[2] + protected EvalStruct evalStruct = null; + + protected ProblemEncoder(int paramNum, int targetNum) throws Exception { + designSpace = new DesignSpace(paramNum); + evalStruct = new EvalStruct(targetNum); + tempLocation = new double[paramNum]; + tempResponseSet = new double[targetNum]; + } + + public DesignSpace getDesignSpace() { + return designSpace; + } + + public EvalStruct getEvalStruct() { + return evalStruct; + } + + //set the default information for each dimension of search space (S) + protected void setDefaultXAt(int i, double min, double max, double grain) { + DesignDim dd = new DesignDim(); + dd.grain = grain; + dd.paramBound = new BasicBound(min, max); + designSpace.setElemAt(dd, i); + } + + protected void setDefaultXAt(int i, double min, double max) { + DesignDim dd = new DesignDim(); + dd.paramBound = new BasicBound(min, max); + designSpace.setElemAt(dd, i); + } + + //set the default information for evaluation each response + protected void setDefaultYAt(int i, double min, double max) { + EvalElement ee = new EvalElement(); + ee.targetBound = new BasicBound(min, max); + evalStruct.setElemAt(ee, i); + } + + protected void setDefaultYAt(int i, double min, double max, double weight) { + EvalElement ee = new EvalElement(); + ee.targetBound = new BasicBound(min, max); + ee.weight = weight; + evalStruct.setElemAt(ee, i); + } + + //get a fresh point + public SearchPoint getFreshSearchPoint() { + return new SearchPoint(designSpace.getDimension()); + } + + //get an encoded point + public SearchPoint getEncodedSearchPoint() { + SearchPoint point = getFreshSearchPoint(); + designSpace.initializeGene(point.getLocation()); + evaluate(point); + return point; + } + + //evaluate the point into encoded information + public void evaluate(SearchPoint point) { + //copy to temp point + System.arraycopy(point.getLocation(), 0, this.tempLocation, 0, tempLocation.length); + //mapping the temp point to original search space S + designSpace.getMappingPoint(tempLocation); + //calculate based on the temp point + calcTargets(tempResponseSet, tempLocation); + evalStruct.evaluate(point.getEncodeInfo(), tempResponseSet); + point.setObjectiveValue(tempResponseSet[0]); + } + + //calcuate each response, must be implemented + abstract protected double calcTargetAt(int index, double[] VX); + + // calculate all the responses VY[] based on given point VX[] + private void calcTargets(double[] VY, double[] VX) { + for(int i=0; i<VY.length; i++) { + VY[i] = calcTargetAt(i, VX); + } + } +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java index c06db87d83b7..03b621ec05d7 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/UnconstrainedProblemEncoder.java @@ -1,39 +1,39 @@ -/**
- * Description: For unconstrained function
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Dec 28, 2001
- * Xiaofeng Xie Mar 02, 2003
- * Xiaofeng Xie May 11, 2004
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- *
- * @version 1.0
- * @Since MAOS1.0
- */
-
-package net.adaptivebox.problem;
-
-import net.adaptivebox.global.*;
-
-public abstract class UnconstrainedProblemEncoder extends ProblemEncoder {
- protected UnconstrainedProblemEncoder(int NX) throws Exception {
- super(NX, 1);
- setDefaultYAt(0, BasicBound.MINDOUBLE, BasicBound.MINDOUBLE);
- }
-
- protected double calcTargetAt(int index, double[] VX) {
- return calcTarget(VX);
- }
- abstract public double calcTarget(double[] VX);
-}
+/** + * Description: For unconstrained function + * + * @ Author Create/Modi Note + * Xiaofeng Xie Dec 28, 2001 + * Xiaofeng Xie Mar 02, 2003 + * Xiaofeng Xie May 11, 2004 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + * + * @version 1.0 + * @Since MAOS1.0 + */ + +package net.adaptivebox.problem; + +import net.adaptivebox.global.*; + +public abstract class UnconstrainedProblemEncoder extends ProblemEncoder { + protected UnconstrainedProblemEncoder(int NX) throws Exception { + super(NX, 1); + setDefaultYAt(0, BasicBound.MINDOUBLE, BasicBound.MINDOUBLE); + } + + protected double calcTargetAt(int index, double[] VX) { + return calcTarget(VX); + } + abstract public double calcTarget(double[] VX); +} diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java index 6a493f37ae74..48f4df46042a 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java @@ -1,141 +1,141 @@ -/**
- * Description: provide the information for the search space (S)
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie Mar 2, 2003
- * Xiaofeng Xie May 11, 2004
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- *
- * @References:
- * [1] Zhang W J, Xie X F, Bi D C. Handling boundary constraints for numerical
- * optimization by particle swarm flying in periodic search space. Congress
- * on Evolutionary Computation, Oregon, USA, 2004
- * @ especially for particle swarm agent
- */
-
-package net.adaptivebox.space;
-import net.adaptivebox.global.*;
-
-public class DesignSpace {
- //The information of all the dimension
- private DesignDim[] dimProps;
-
- public DesignSpace(int dim) {
- dimProps = new DesignDim[dim];
- }
-
- public DesignDim getDimAt(int index) {
- return dimProps[index];
- }
-
- public void setElemAt(DesignDim elem, int index) {
- dimProps[index] = elem;
- }
-
- public int getDimension() {
- if (dimProps==null) {
- return -1;
- }
- return dimProps.length;
- }
-
- public double boundAdjustAt(double val, int dim){
- return dimProps[dim].paramBound.boundAdjust(val);
- }
-
- public void annulusAdjust (double[] location){
- for (int i=0; i<getDimension(); i++) {
- location[i] = dimProps[i].paramBound.annulusAdjust(location[i]);
- }
- }
-
- public void randomAdjust (double[] location){
- for (int i=0; i<getDimension(); i++) {
- location[i] = dimProps[i].paramBound.randomAdjust(location[i]);
- }
- }
-
- public boolean satisfyCondition(double[] location){
- for (int i=0; i<getDimension(); i++) {
- if (!dimProps[i].paramBound.isSatisfyCondition(location[i])) {
- return false;
- }
- }
- /*If the limits are not violated, return TRUE*/
- return(true);
- }
-
- public void mutationAt(double[] location, int i){
- location[i] = dimProps[i].paramBound.getRandomValue();
- }
-
- public double mutationUniformAtPointAsCenter (double pointX, int i){
- double length = this.getMagnitudeIn(i)/2;
- pointX += RandomGenerator.doubleRangeRandom(-1*length, length);
-
- return pointX;
- }
-
- public double getUpValueAt(int dimensionIndex) {
- return dimProps[dimensionIndex].paramBound.maxValue;
- }
-
- public double getLowValueAt(int dimensionIndex) {
- return dimProps[dimensionIndex].paramBound.minValue;
- }
-
- public double getMagnitudeIn(int dimensionIndex) {
- return dimProps[dimensionIndex].paramBound.getLength();
- }
-
-
- public boolean initilizeGeneAtPointAsCenter(double[] tempX){
- if (tempX.length!=this.getDimension()) {
- return false;
- }
- for(int i=0;i<tempX.length;i++) {
- double length = this.getMagnitudeIn(i)/2;
- tempX[i]+=RandomGenerator.doubleRangeRandom(-1*length, length);
- }
- return true;
- }
-
- public void initializeGene(double[] tempX){
- for(int i=0;i<tempX.length;i++) tempX[i] = dimProps[i].paramBound.getRandomValue(); //Global.RandomGenerator.doubleRangeRandom(9.8, 10);
- }
-
- public double[] getFreshGene() {
- double[] tempX = new double[this.getDimension()];
- initializeGene(tempX);
- return tempX;
- }
- public void getMappingPoint(double[] point) {
- for(int i=0; i<getDimension(); i++) {
- point[i] = dimProps[i].paramBound.annulusAdjust(point[i]);
- if(dimProps[i].isDiscrete()) {
- point[i] = dimProps[i].getGrainedValue(point[i]);
- }
- }
- }
-
- public double[] getRealLoc(double[] imageLoc) {
- double[] realLoc = new double[imageLoc.length];
- for (int i=0; i<imageLoc.length; i++) {
- realLoc[i] = imageLoc[i];
- }
- annulusAdjust(realLoc);
- return realLoc;
- }
-}
-
+/** + * Description: provide the information for the search space (S) + * + * @ Author Create/Modi Note + * Xiaofeng Xie Mar 2, 2003 + * Xiaofeng Xie May 11, 2004 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + * + * @References: + * [1] Zhang W J, Xie X F, Bi D C. Handling boundary constraints for numerical + * optimization by particle swarm flying in periodic search space. Congress + * on Evolutionary Computation, Oregon, USA, 2004 + * @ especially for particle swarm agent + */ + +package net.adaptivebox.space; +import net.adaptivebox.global.*; + +public class DesignSpace { + //The information of all the dimension + private DesignDim[] dimProps; + + public DesignSpace(int dim) { + dimProps = new DesignDim[dim]; + } + + public DesignDim getDimAt(int index) { + return dimProps[index]; + } + + public void setElemAt(DesignDim elem, int index) { + dimProps[index] = elem; + } + + public int getDimension() { + if (dimProps==null) { + return -1; + } + return dimProps.length; + } + + public double boundAdjustAt(double val, int dim){ + return dimProps[dim].paramBound.boundAdjust(val); + } + + public void annulusAdjust (double[] location){ + for (int i=0; i<getDimension(); i++) { + location[i] = dimProps[i].paramBound.annulusAdjust(location[i]); + } + } + + public void randomAdjust (double[] location){ + for (int i=0; i<getDimension(); i++) { + location[i] = dimProps[i].paramBound.randomAdjust(location[i]); + } + } + + public boolean satisfyCondition(double[] location){ + for (int i=0; i<getDimension(); i++) { + if (!dimProps[i].paramBound.isSatisfyCondition(location[i])) { + return false; + } + } + /*If the limits are not violated, return TRUE*/ + return(true); + } + + public void mutationAt(double[] location, int i){ + location[i] = dimProps[i].paramBound.getRandomValue(); + } + + public double mutationUniformAtPointAsCenter (double pointX, int i){ + double length = this.getMagnitudeIn(i)/2; + pointX += RandomGenerator.doubleRangeRandom(-1*length, length); + + return pointX; + } + + public double getUpValueAt(int dimensionIndex) { + return dimProps[dimensionIndex].paramBound.maxValue; + } + + public double getLowValueAt(int dimensionIndex) { + return dimProps[dimensionIndex].paramBound.minValue; + } + + public double getMagnitudeIn(int dimensionIndex) { + return dimProps[dimensionIndex].paramBound.getLength(); + } + + + public boolean initilizeGeneAtPointAsCenter(double[] tempX){ + if (tempX.length!=this.getDimension()) { + return false; + } + for(int i=0;i<tempX.length;i++) { + double length = this.getMagnitudeIn(i)/2; + tempX[i]+=RandomGenerator.doubleRangeRandom(-1*length, length); + } + return true; + } + + public void initializeGene(double[] tempX){ + for(int i=0;i<tempX.length;i++) tempX[i] = dimProps[i].paramBound.getRandomValue(); //Global.RandomGenerator.doubleRangeRandom(9.8, 10); + } + + public double[] getFreshGene() { + double[] tempX = new double[this.getDimension()]; + initializeGene(tempX); + return tempX; + } + public void getMappingPoint(double[] point) { + for(int i=0; i<getDimension(); i++) { + point[i] = dimProps[i].paramBound.annulusAdjust(point[i]); + if(dimProps[i].isDiscrete()) { + point[i] = dimProps[i].getGrainedValue(point[i]); + } + } + } + + public double[] getRealLoc(double[] imageLoc) { + double[] realLoc = new double[imageLoc.length]; + for (int i=0; i<imageLoc.length; i++) { + realLoc[i] = imageLoc[i]; + } + annulusAdjust(realLoc); + return realLoc; + } +} + diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java index fa5375b7608d..33737339a383 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/ILocationEngine.java @@ -1,25 +1,25 @@ -/**
- * Description: provide the information for location
- *
- * @ Author Create/Modi Note
- * Xiaofeng Xie May 3, 2003
- * Xiaofeng Xie May 11, 2004
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Please acknowledge the author(s) if you use this code in any way.
- */
-
-package net.adaptivebox.space;
-
-public interface ILocationEngine{
- abstract public double[] getLocation();
-}
+/** + * Description: provide the information for location + * + * @ Author Create/Modi Note + * Xiaofeng Xie May 3, 2003 + * Xiaofeng Xie May 11, 2004 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Please acknowledge the author(s) if you use this code in any way. + */ + +package net.adaptivebox.space; + +public interface ILocationEngine{ + abstract public double[] getLocation(); +} |