[Libreoffice-commits] core.git: nlpsolver/src nlpsolver/ThirdParty

Todor Balabanov (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 2 06:41:49 UTC 2021


 nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java              |   33 +++-------
 nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java |    7 ++
 nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java  |    3 
 nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java  |    3 
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java                           |    5 +
 5 files changed, 24 insertions(+), 27 deletions(-)

New commits:
commit 559b342a62901754222723ee522f5ae80e4d40f5
Author:     Todor Balabanov <todor.balabanov at gmail.com>
AuthorDate: Tue Jul 27 20:13:32 2021 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Aug 2 08:41:14 2021 +0200

    The null pointer bug should be fixed now.
    
    Change-Id: I8278bfed8170907a958396839d0997fc127f4b2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119744
    Tested-by: Julien Nabet <serval2412 at yahoo.fr>
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
index 75e66ff251b6..ae718e63519b 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -72,31 +72,22 @@ public class DEPSAgent {
 
   private double switchP = 0.5;
 
-  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer, Library lib) {
-      setProblemEncoder(encoder);
-
+  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer) {
       this.switchP = switchP;
 
-      deGTBehavior.setLibrary(lib);
-      psGTBehavior.setLibrary(lib);
-      setGTBehavior(deGTBehavior);
-      setGTBehavior(psGTBehavior);
-      this.deGTBehavior = deGTBehavior;
-      this.psGTBehavior = psGTBehavior;
+      problemEncoder = encoder;
 
       qualityComparator = comparer;
-  }
 
-  public void setLibrary(Library lib) {
-    deGTBehavior.setLibrary(lib);
-    psGTBehavior.setLibrary(lib);
-  }
+      trailPoint = problemEncoder.getFreshSearchPoint();
+      pold_t = problemEncoder.getFreshSearchPoint();
+      pcurrent_t = problemEncoder.getFreshSearchPoint();
+
+      this.deGTBehavior = deGTBehavior;
+      this.deGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
 
-  public void setProblemEncoder(ProblemEncoder encoder) {
-    problemEncoder = encoder;
-    trailPoint = problemEncoder.getFreshSearchPoint();
-    pold_t = problemEncoder.getFreshSearchPoint();
-    pcurrent_t = problemEncoder.getFreshSearchPoint();
+      this.psGTBehavior = psGTBehavior;
+      this.psGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
   }
 
   public void setSpecComparator(IGoodnessCompareEngine comparer) {
@@ -105,6 +96,8 @@ public class DEPSAgent {
 
   public void setPbest(SearchPoint pbest) {
     pbest_t = pbest;
+    deGTBehavior.setPbest(pbest_t);
+    psGTBehavior.setPbest(pbest_t);
   }
 
   private AbsGTBehavior getGTBehavior() {
@@ -122,7 +115,7 @@ public class DEPSAgent {
   public void generatePoint() {
     // generates a new point in the search space (S) based on
     // its memory and the library
-    selectGTBehavior = this.getGTBehavior();
+    selectGTBehavior = getGTBehavior();
     selectGTBehavior.generateBehavior(trailPoint, problemEncoder);
 
     // evaluate into goodness information
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 b6aacd3ccc40..09110581659c 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
@@ -28,10 +28,17 @@ abstract public class AbsGTBehavior implements ILibEngine {
   // The referred social library
   protected Library socialLib;
 
+  // the own memory: store the personal best point
+  protected SearchPoint pbest_t;
+
   public void setLibrary(Library lib) {
     socialLib = lib;
   }
 
+  public void setPbest(SearchPoint pbest) {
+    pbest_t = pbest;
+  }
+
   abstract public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold);
 
   abstract public void generateBehavior(SearchPoint trailPoint, ProblemEncoder problemEncoder);
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 21bc2fb82de3..c9ca0ef82e59 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
@@ -48,9 +48,6 @@ public class DEGTBehavior extends AbsGTBehavior {
   //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;
-
   @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 eb35a1ad4e9a..68bf5a10edd9 100644
--- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java
+++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/PSGTBehavior.java
@@ -82,9 +82,6 @@ public class PSGTBehavior extends AbsGTBehavior {
   // 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;
-
   @Override
   public void setMemPoints(SearchPoint pbest, BasicPoint pcurrent, BasicPoint pold) {
     pcurrent_t = pcurrent;
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
index 20cf9286e91a..7a4c552d9e60 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -36,6 +36,7 @@ import net.adaptivebox.deps.behavior.PSGTBehavior;
 import net.adaptivebox.global.IUpdateCycleEngine;
 import net.adaptivebox.knowledge.Library;
 import net.adaptivebox.knowledge.SearchPoint;
+import net.adaptivebox.space.BasicPoint;
 
 import com.sun.star.comp.Calc.NLPSolver.dialogs.IEvolutionarySolverStatusDialog;
 import com.sun.star.lang.IllegalArgumentException;
@@ -131,14 +132,16 @@ public final class DEPSSolverImpl extends BaseEvolutionarySolver
             deGTBehavior.MIN_FACTOR = Math.min(m_minFactor.getValue(), m_maxFactor.getValue());
             deGTBehavior.MAX_FACTOR = Math.max(m_minFactor.getValue(), m_maxFactor.getValue());
             deGTBehavior.CR = m_CR.getValue();
+            deGTBehavior.setLibrary(m_library);
 
             PSGTBehavior psGTBehavior = new PSGTBehavior();
             psGTBehavior.c1 = m_c1.getValue();
             psGTBehavior.c2 = m_c2.getValue();
             psGTBehavior.CL = m_CL.getValue();
             psGTBehavior.weight = m_weight.getValue();
+            psGTBehavior.setLibrary(m_library);
 
-            agents[i] = new DEPSAgent(m_problemEncoder, deGTBehavior, psGTBehavior, m_agentSwitchRate.getValue(), m_specCompareEngine, m_library);
+            agents[i] = new DEPSAgent(m_problemEncoder, deGTBehavior, psGTBehavior, m_agentSwitchRate.getValue(), m_specCompareEngine);
             agents[i].setPbest(m_library.getSelectedPoint(i));
         }
 


More information about the Libreoffice-commits mailing list