diff options
Diffstat (limited to 'nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java')
-rw-r--r-- | nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java index 3de78939cb10..7785069e86bc 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java @@ -43,21 +43,23 @@ 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 + // Forms the goodness landscape private IGoodnessCompareEngine specComparator; - //the coefficients of SCAgent + // 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 + // The referred external library private Library externalLib; - //store the point that generated in current learning cycle + // store the point that generated in current learning cycle private SearchPoint trailPoint; - //the own memory: store the point that generated in last learning cycle + // the own memory: store the point that generated in last learning cycle private SearchPoint pcurrent_t; public void setExternalLib(Library lib) { @@ -75,9 +77,9 @@ 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; } @@ -85,49 +87,50 @@ 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) - if(specComparator.compare(pcurrent_t.getEncodeInfo(), libBPoint.getEncodeInfo())==IGoodnessCompareEngine.LARGER_THAN) { +// 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; Xrefer = pcurrent_t; } else { 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 + // 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---model point, 2---refer point - private boolean inferPoint(ILocationEngine newPoint, ILocationEngine point1,ILocationEngine point2, DesignSpace space){ - double[] newLoc = newPoint.getLocation(); - double[] real1 = point1.getLocation(); - double[] real2 = point2.getLocation(); + } - for (int i=0; i<newLoc.length; i++) { - newLoc[i] = real1[i]*2-real2[i]; - //boundary handling - newLoc[i] = space.boundAdjustAt(newLoc[i], i); - newLoc[i] = RandomGenerator.doubleRangeRandom(newLoc[i], real2[i]); - } - return true; - } + // 1---model point, 2---refer point + private boolean inferPoint(ILocationEngine newPoint, ILocationEngine point1, ILocationEngine point2, + DesignSpace space) { + double[] newLoc = newPoint.getLocation(); + double[] real1 = point1.getLocation(); + double[] real2 = point2.getLocation(); + + for (int i = 0; i < newLoc.length; i++) { + newLoc[i] = real1[i] * 2 - real2[i]; + // boundary handling + newLoc[i] = space.boundAdjustAt(newLoc[i], i); + newLoc[i] = RandomGenerator.doubleRangeRandom(newLoc[i], real2[i]); + } + return true; + } } - |