[Libreoffice-commits] core.git: nlpsolver/ThirdParty
Todor Balabanov (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 8 01:50:30 UTC 2021
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java | 13 +---------
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java | 3 ++
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java | 3 +-
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java | 1
4 files changed, 8 insertions(+), 12 deletions(-)
New commits:
commit 822f128e734f37ee4de9bf5b62640cbec140701e
Author: Todor Balabanov <todor.balabanov at gmail.com>
AuthorDate: Wed Jul 7 16:01:19 2021 +0300
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Jul 8 03:49:56 2021 +0200
Polymorphism is a better approach when there are chains of inheritance.
Change-Id: I2580dafcf8792bf4b11db78988db8c2976e4545c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118569
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
index 58250089b02f..88aa56eff837 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -66,7 +66,7 @@ public class DEPSAgent implements ILibEngine {
// the own memory: store the personal best point
private SearchPoint pbest_t;
- // Generate-and-test Behaviors
+ // Generate-and-test behaviors.
private DEGTBehavior deGTBehavior;
private PSGTBehavior psGTBehavior;
public double switchP = 0.5;
@@ -100,16 +100,7 @@ public class DEPSAgent implements ILibEngine {
}
public void setGTBehavior(AbsGTBehavior gtBehavior) {
- if (gtBehavior instanceof DEGTBehavior) {
- deGTBehavior = ((DEGTBehavior) gtBehavior);
- deGTBehavior.setPbest(pbest_t);
- return;
- }
- if (gtBehavior instanceof PSGTBehavior) {
- psGTBehavior = ((PSGTBehavior) gtBehavior);
- psGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
- return;
- }
+ gtBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
}
public void generatePoint() {
diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
index b811572ada82..c96174227b93 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
@@ -21,6 +21,7 @@ import net.adaptivebox.goodness.IGoodnessCompareEngine;
import net.adaptivebox.knowledge.Library;
import net.adaptivebox.knowledge.SearchPoint;
import net.adaptivebox.problem.ProblemEncoder;
+import net.adaptivebox.space.BasicPoint;
abstract public class AbsGTBehavior {
// The referred social library
@@ -30,6 +31,8 @@ abstract public class AbsGTBehavior {
socialLib = lib;
}
+ abstract public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold);
+
abstract public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder);
abstract public void testBehavior(SearchPoint trailPoint, IGoodnessCompareEngine qualityComparator);
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 df7ff571065d..ada457f3233c 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
@@ -52,7 +52,8 @@ public class DEGTBehavior extends AbsGTBehavior implements ILibEngine {
// the own memory: store the point that generated in last learning cycle
private SearchPoint pbest_t;
- public void setPbest(SearchPoint pbest) {
+ @Override
+ public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold) {
pbest_t = pbest;
}
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 3c7523209138..eb35a1ad4e9a 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java
@@ -85,6 +85,7 @@ public class PSGTBehavior extends AbsGTBehavior {
// the own memory: store the personal best point
private SearchPoint pbest_t;
+ @Override
public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold) {
pcurrent_t = pcurrent;
pbest_t = pbest;
More information about the Libreoffice-commits
mailing list