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>
This commit is contained in:
committed by
Samuel Mehrbrodt
parent
acd4625f2f
commit
5ee453818c
+7
-3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
-3
@@ -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;
|
||||
|
||||
Vendored
+11
-8
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -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
|
||||
|
||||
+1
-3
@@ -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]) {
|
||||
|
||||
Vendored
+8
-4
@@ -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);
|
||||
}
|
||||
|
||||
-1
@@ -99,5 +99,4 @@ public class Library {
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-4
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -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]);
|
||||
|
||||
+23
-16
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -42,5 +42,4 @@ public class DesignDim {
|
||||
return paramBound.maxValue - Math.rint((paramBound.maxValue - value) / grain) * grain;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -70,5 +70,4 @@ public class DesignSpace {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user