bump product version to 4.1.6.2
[LibreOffice.git] / nlpsolver / ThirdParty / EvolutionarySolver / src / net / adaptivebox / space / DesignDim.java
blobaa9988c1b3a9a60946e85f11ebbf7ac995bb2ee9
1 /**
2 * Description: provide the information for goodness evaluation of a target
4 * @ Author Create/Modi Note
5 * Xiaofeng Xie Mar 1, 2003
6 * Xiaofeng Xie May 3, 2004 Add grain value
7 * Xiaofeng Xie May 11, 2004 Add crowd distance
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * Please acknowledge the author(s) if you use this code in any way.
22 package net.adaptivebox.space;
23 import net.adaptivebox.global.*;
25 public class DesignDim {
26 // To discrete space with the given step. For example, for an integer variable,
27 // The grain value can be set as 1.
28 public double grain = 0;
29 public BasicBound paramBound = new BasicBound(); //the range of a parameter
32 public void importData(DesignDim ipr) {
33 this.grain = ipr.grain;
34 this.paramBound = ipr.paramBound;
37 public boolean isDiscrete() {
38 return grain!=0;
41 public double getGrainedValue(double value) {
42 if(grain==0) {
43 return value;
44 } else if(grain>0) {
45 return paramBound.minValue+Math.rint((value-paramBound.minValue)/grain)*grain;
46 } else {
47 return paramBound.maxValue-Math.rint((paramBound.maxValue-value)/grain)*grain;