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@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 5825008..88aa56e 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 b811572..c961742 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 df7ff57..ada457f 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 3c75232..eb35a1a 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;