diff options
author | Todor Balabanov <todor.balabanov@gmail.com> | 2019-05-13 14:29:17 +0300 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-05-17 08:45:46 +0200 |
commit | 5ee453818c88f0a73ca2863a80c6b901feed1837 (patch) | |
tree | b95833b4759506c6dfa71164da37ec3e24c8cfd6 /nlpsolver/ThirdParty | |
parent | acd4625f2f1bf418452ffdafeac1b83fe1b2acde (diff) |
Some additional manual formatting.
Change-Id: Ie5590535d013aa2f747dd034fa2fcd2ae5c3956b
Reviewed-on: https://gerrit.libreoffice.org/72226
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'nlpsolver/ThirdParty')
13 files changed, 74 insertions, 55 deletions
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java index 0f1240df9a1b..b9784c8a2ab3 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java @@ -46,6 +46,7 @@ public class DEPSAgent implements ILibEngine { // Describes the problem to be solved private ProblemEncoder problemEncoder; + // Forms the goodness landscape private IGoodnessCompareEngine qualityComparator; @@ -57,8 +58,10 @@ public class DEPSAgent implements ILibEngine { // the own memory: store the point that generated in old learning cycle private BasicPoint pold_t; + // the own memory: store the point that generated in last learning cycle private BasicPoint pcurrent_t; + // the own memory: store the personal best point private SearchPoint pbest_t; @@ -109,11 +112,12 @@ public class DEPSAgent implements ILibEngine { } public void generatePoint() { -// generates a new point in the search space (S) based on -// its memory and the library + // 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 + + // evaluate into goodness information problemEncoder.evaluate(trailPoint); } 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 40e570a77559..645318341108 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java @@ -37,9 +37,14 @@ import net.adaptivebox.problem.ProblemEncoder; import net.adaptivebox.space.BasicPoint; public class DEGTBehavior extends AbsGTBehavior implements ILibEngine { - private static final 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 + //Number of differential vectors, normally be 1 or 2 + private static final int DVNum = 2; + + //scale constant: (0, 1.2], normally be 0.5 + public double FACTOR = 0.5; + + //crossover constant: [0, 1], normally be 0.1 or 0.9 + public double CR = 0.9; // the own memory: store the point that generated in last learning cycle private SearchPoint pbest_t; 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 afd18390e630..13c605b63780 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java @@ -64,20 +64,23 @@ import net.adaptivebox.space.DesignSpace; 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]) + // 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 + //inertia weight + public double weight = 0.4; + + //See ref[4], normally be 0.001~0.005 + public double CL = 0; // the own memory: store the point that generated in old learning cycle private BasicPoint pold_t; + // the own memory: store the point that generated in last learning cycle private BasicPoint pcurrent_t; + // the own memory: store the personal best point private SearchPoint pbest_t; @@ -100,7 +103,8 @@ public class PSGTBehavior extends AbsGTBehavior { 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 + + // limitation for delta_x deltaxbm = 0.5 * designSpace.getMagnitudeIn(b); if (deltaxb < -deltaxbm) { deltaxb = -deltaxbm; @@ -118,5 +122,4 @@ public class PSGTBehavior extends AbsGTBehavior { pold_t.importLocation(pcurrent_t); pcurrent_t.importLocation(trailPoint); } - } diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java index 526257544091..db37ddb39f5b 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalStruct.java @@ -42,13 +42,13 @@ public class EvalStruct { 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 + // 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 + // 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/goodness/ACRComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java index 22f4d4a32ba2..284549506ce1 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java @@ -51,8 +51,8 @@ public class ACRComparator implements IGoodnessCompareEngine, IUpdateCycleEngine public ACRComparator(Library lib, int T) { socialPool = lib; this.T = T; -// set the (epsilon_t|t=0) as the maximum CONS value among the SearchPoints in -// the library + + // set the (epsilon_t|t=0) as the maximum CONS value among the SearchPoints in the library epsilon_t = lib.getExtremalVcon(true); } @@ -74,8 +74,9 @@ public class ACRComparator implements IGoodnessCompareEngine, IUpdateCycleEngine } public void updateCycle(int t) { -// calculates the ratio + // calculates the ratio double rn = (double) socialPool.getVconThanNum(epsilon_t) / (double) socialPool.getPopSize(); + if (t > TthR * T && T != -1) { // Forcing sub-rule epsilon_t *= BETAF; } else { // Ratio-keeping sub-rules diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java index 74fd1b8481fe..8140650dd6e1 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/BCHComparator.java @@ -28,9 +28,7 @@ package net.adaptivebox.goodness; public class BCHComparator implements IGoodnessCompareEngine { - /* - * check the magnitude of two array, the frontal is more important - **/ + /* check the magnitude of two array, the frontal is more important */ private static int compareArray(double[] fit1, double[] fit2) { for (int i = 0; i < fit1.length; i++) { if (fit1[i] > fit2[i]) { diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java index 70e227b5f610..17a85993d56f 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/IGoodnessCompareEngine.java @@ -29,9 +29,13 @@ public abstract interface IGoodnessCompareEngine { int LESS_THAN = 0; /** - * check the magnitude of two IEncodeEngine LARGER_THAN: goodness1 is worse than - * goodness2 LESS_THAN: goodness1 is better than goodness2 EQUAL_TO : goodness1 - * is equal to goodness2 - **/ + * check the magnitude of two IEncodeEngine + * + * LARGER_THAN: goodness1 is worse than goodness2 + * + * LESS_THAN: goodness1 is better than goodness2 + * + * EQUAL_TO : goodness1 is equal to goodness2 + */ int compare(double[] goodness1, double[] goodness2); } diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java index 841e9102a1c0..247d4908c420 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java @@ -99,5 +99,4 @@ public class Library { } return num; } - } diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java index eb0441648781..df13efc74d0a 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java @@ -25,8 +25,7 @@ import net.adaptivebox.space.BasicPoint; public class SearchPoint extends BasicPoint implements IEncodeEngine { // store the encode information for goodness evaluation - // encodeInfo[0]: the sum of constraints (if it equals to 0, then be a feasible - // point) + // encodeInfo[0]: the sum of constraints (if it equals to 0, then be a feasible point) // encodeInfo[1]: the value of objective function private final double[] encodeInfo = new double[2]; private double objectiveValue; @@ -68,5 +67,4 @@ public class SearchPoint extends BasicPoint implements IEncodeEngine { public boolean isFeasible() { return encodeInfo[0] == 0; // no constraint violations } - -}
\ 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 c6a25e93c8f1..674d275420c3 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java @@ -85,11 +85,13 @@ public abstract class ProblemEncoder { // evaluate the point into encoded information public void evaluate(SearchPoint point) { -// copy to temp point + // copy to temp point System.arraycopy(point.getLocation(), 0, this.tempLocation, 0, tempLocation.length); -// mapping the temp point to original search space S + + // mapping the temp point to original search space S designSpace.getMappingPoint(tempLocation); -// calculate based on the temp point + + // calculate based on the temp point calcTargets(tempResponseSet, tempLocation); evalStruct.evaluate(point.getEncodeInfo(), tempResponseSet); point.setObjectiveValue(tempResponseSet[0]); diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java index 7785069e86bc..a09d0dcfd6b2 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java @@ -43,22 +43,24 @@ import net.adaptivebox.knowledge.SearchPoint; public class SCAgent { - // Describes the problem to be solved (encode the point into intermediate - // information) + // Describes the problem to be solved (encode the point into intermediate information) private ProblemEncoder problemEncoder; + // Forms the goodness landscape private IGoodnessCompareEngine specComparator; // the coefficients of SCAgent private static final int TaoB = 2; - // The early version set TaoW as the size of external library (NL), but 4 is - // often enough + + // The early version set TaoW as the size of external library (NL), but 4 is often enough private static final int TaoW = 4; // The referred external library private Library externalLib; + // store the point that generated in current learning cycle private SearchPoint trailPoint; + // the own memory: store the point that generated in last learning cycle private SearchPoint pcurrent_t; @@ -77,9 +79,10 @@ public class SCAgent { } public SearchPoint generatePoint() { -// generate a new point + // generate a new point generatePoint(trailPoint); -// evaluate the generated point + + // evaluate the generated point problemEncoder.evaluate(trailPoint); return trailPoint; } @@ -87,13 +90,14 @@ public class SCAgent { private void generatePoint(ILocationEngine tempPoint) { SearchPoint Xmodel, Xrefer, libBPoint; -// choose Selects a better point (libBPoint) from externalLib (L) based -// on tournament selection + // choose Selects a better point (libBPoint) from externalLib (L) based + // on tournament selection int xb = externalLib.tournamentSelection(specComparator, TaoB, true); libBPoint = externalLib.getSelectedPoint(xb); -// Compares pcurrent_t with libBPoint -// The better one becomes model point (Xmodel) -// The worse one becomes refer point (Xrefer) + + // Compares pcurrent_t with libBPoint + // The better one becomes model point (Xmodel) + // The worse one becomes refer point (Xrefer) if (specComparator.compare(pcurrent_t.getEncodeInfo(), libBPoint.getEncodeInfo()) == IGoodnessCompareEngine.LARGER_THAN) { Xmodel = libBPoint; @@ -102,19 +106,22 @@ public class SCAgent { Xmodel = pcurrent_t; Xrefer = libBPoint; } -// observational learning: generates a new point near the model point, which -// the variation range is decided by the difference of Xmodel and Xrefer + + // observational learning: generates a new point near the model point, which + // the variation range is decided by the difference of Xmodel and Xrefer inferPoint(tempPoint, Xmodel, Xrefer, problemEncoder.getDesignSpace()); } // 1. Update the current point into the external library // 2. Replace the current point by the generated point public void updateInfo() { -// Selects a bad point kw from TaoW points in Library + // Selects a bad point kw from TaoW points in Library int xw = externalLib.tournamentSelection(specComparator, TaoW, false); -// Replaces kw with pcurrent_t + + // Replaces kw with pcurrent_t externalLib.getSelectedPoint(xw).importPoint(pcurrent_t); -// Replaces pcurrent_t (x(t)) with trailPoint (x(t+1)) + + // Replaces pcurrent_t (x(t)) with trailPoint (x(t+1)) pcurrent_t.importPoint(trailPoint); } diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java index 9fbe937e1dff..f8f283bf1929 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignDim.java @@ -42,5 +42,4 @@ public class DesignDim { return paramBound.maxValue - Math.rint((paramBound.maxValue - value) / grain) * grain; } } - } diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java index 0c28e0006e1b..7d9307936033 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/DesignSpace.java @@ -70,5 +70,4 @@ public class DesignSpace { } } } - } |