summaryrefslogtreecommitdiff
path: root/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-11-25 12:41:39 +0000
committerMichael Meeks <michael.meeks@suse.com>2011-11-28 11:06:59 +0000
commit17ff286751454dcd5aa86bef41a8e53cfb109c70 (patch)
tree615db0eda5afe21aa7c5b9db57416d34ed11c464 /nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode
parente46454b676bedc5585456cc37c63c9e4ff7deaad (diff)
Flatten un-maintained ex. Sun/Oracle nlpsolver extension into the repo
This should make it easier to hack, and also to separate out the tangled in third party EvolutionarySolver as/when we can.
Diffstat (limited to 'nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode')
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java70
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java60
-rwxr-xr-xnlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java24
3 files changed, 154 insertions, 0 deletions
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java
new file mode 100755
index 000000000000..82e4073ee4e8
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java
@@ -0,0 +1,70 @@
+/**
+ * Description: provide the information for evaluating of a response (target)
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 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.encode;
+
+import net.adaptivebox.global.*;
+
+public class EvalElement {
+
+ //The weight for each response (target)
+ public double weight = 1;
+ /**
+ * The expected range of the response value, forms the following objective:
+ *
+ * NO minValue maxValue : THE ELEMENT OF BasicBound
+ * 1 MINDOUBLE, MINDOUBLE: the minimize objective
+ * 2 MAXDOUBLE, MAXDOUBLE: the maximize objective
+ * 3 MINDOUBLE, v : the lessthan constraint (<v)
+ * 4 v , MAXDOUBLE: the largethan constraint (>v)
+ * 5 v1 , v2 : the region constraint, i.e. belongs to [v1, v2]
+ *
+ * OPTIM type: the No.1 and No.2
+ * CONS type: the last three
+ *
+ */
+ public BasicBound targetBound = new BasicBound();
+
+ public EvalElement() {};
+
+ public boolean isOptType() {
+ return ((targetBound.minValue==BasicBound.MINDOUBLE&&targetBound.maxValue==BasicBound.MINDOUBLE)||
+ (targetBound.minValue==BasicBound.MAXDOUBLE&&targetBound.maxValue==BasicBound.MAXDOUBLE));
+ }
+
+ public double evaluateCONS(double targetValue) {
+ if(targetValue<targetBound.minValue) {
+ return weight*(targetBound.minValue-targetValue);
+ }
+ if(targetValue>targetBound.maxValue) {
+ return weight*(targetValue-targetBound.maxValue);
+ }
+ return 0;
+ }
+
+ public double evaluateOPTIM(double targetValue) {
+ if(targetBound.maxValue==BasicBound.MINDOUBLE) { //min mode
+ return weight*targetValue;
+ } else { //max
+ return -weight*targetValue;
+ }
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java
new file mode 100755
index 000000000000..ad44df1dc2d2
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java
@@ -0,0 +1,60 @@
+/**
+ * Description: provide the information for evaluating a set of targets values
+ * into encoded information (For formation the goodness landscape by comparing)
+ *
+ * @ Author Create/Modi Note
+ * Xiaofeng Xie Mar 1, 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] Deb K. An efficient constraint handling method for genetic algorithms.
+ * Computer Methods in Applied Mechanics and Engineering, 2000, 186(2-4): 311-338
+ */
+
+package net.adaptivebox.encode;
+
+public class EvalStruct {
+ // The information for evaluating all the responses
+ public EvalElement[] evalElems = null;
+
+ public EvalStruct(int elemsNum) {
+ evalElems = new EvalElement[elemsNum];
+ }
+ public int getSize() {
+ return evalElems.length;
+ }
+
+ public void setElemAt(EvalElement dim, int index) {
+ evalElems[index] = dim;
+ }
+
+ //convert response values into encoded information double[2]
+ public void evaluate(double[] evalRes, double[] targetValues) {
+ evalRes[0] = evalRes[1] = 0;
+ for(int i=0; i<evalElems.length; i++) {
+ if (evalElems[i].isOptType()) {
+ //The objectives (OPTIM type)
+ //The multi-objective will be translated into single-objective
+ evalRes[1] += evalElems[i].evaluateOPTIM(targetValues[i]);
+ } else {
+ //The constraints (CONS type)
+ //If evalRes[0] equals to 0, then be a feasible point, i.e. satisfies
+ // all the constraints
+ evalRes[0] += evalElems[i].evaluateCONS(targetValues[i]);
+ }
+ }
+ }
+}
+
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java
new file mode 100755
index 000000000000..9ca77d32ca8f
--- /dev/null
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/IEncodeEngine.java
@@ -0,0 +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();
+}