2 * Description: provide the information for the search space (S)
4 * Author Create/Modi Note
5 * Xiaofeng Xie Mar 2, 2003
6 * Xiaofeng Xie May 11, 2004
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * Please acknowledge the author(s) if you use this code in any way.
21 * [1] Zhang W J, Xie X F, Bi D C. Handling boundary constraints for numerical
22 * optimization by particle swarm flying in periodic search space. Congress
23 * on Evolutionary Computation, Oregon, USA, 2004
24 * especially for particle swarm agent
27 package net
.adaptivebox
.space
;
29 public class DesignSpace
{
30 // The information of all the dimension
31 private DesignDim
[] dimProps
;
33 public DesignSpace(int dim
) {
34 dimProps
= new DesignDim
[dim
];
37 public void setElemAt(DesignDim elem
, int index
) {
38 dimProps
[index
] = elem
;
41 public int getDimension() {
42 if (dimProps
== null) {
45 return dimProps
.length
;
48 public double boundAdjustAt(double val
, int dim
) {
49 return dimProps
[dim
].paramBound
.boundAdjust(val
);
52 public void mutationAt(double[] location
, int i
) {
53 location
[i
] = dimProps
[i
].paramBound
.getRandomValue();
56 public double getMagnitudeIn(int dimensionIndex
) {
57 return dimProps
[dimensionIndex
].paramBound
.getLength();
60 public void initializeGene(double[] tempX
) {
61 for (int i
= 0; i
< tempX
.length
; i
++)
62 tempX
[i
] = dimProps
[i
].paramBound
.getRandomValue(); // Global.RandomGenerator.doubleRangeRandom(9.8, 10);
65 public void getMappingPoint(double[] point
) {
66 for (int i
= 0; i
< getDimension(); i
++) {
67 point
[i
] = dimProps
[i
].paramBound
.annulusAdjust(point
[i
]);
68 if (dimProps
[i
].isDiscrete()) {
69 point
[i
] = dimProps
[i
].getGrainedValue(point
[i
]);