nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java 
             |   10 +++-------
 
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
 |    4 ----
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java             
              |    5 +++--
 3 files changed, 6 insertions(+), 13 deletions(-)

New commits:
commit 5c299f0112441ca095276376a9973cb4ff0fda02
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Aug 6 12:22:43 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Aug 6 15:22:37 2021 +0200

    cid#1489772 UR: Uninitialized read of field in constructor
    
    pass in SearchPoint to initialize pbest_t before it is then
    passed to setMemPoints
    
    setMemPoints sets the pbest_t variable of AbsGTBehavior so
    calling setPbest on AbsGTBehavior subclasses after calling
    that doesn't do anything so drop it, and then DEPSAgent.setPbest
    isn't needed anymore
    
    Change-Id: Id4fdc770cefc0f801218dc9bf51a6dc5b1e25d5a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120115
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
index ae718e63519b..3a08df39f5e7 100644
--- 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
+++ 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -72,7 +72,8 @@ public class DEPSAgent {
 
   private double switchP = 0.5;
 
-  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer) {
+  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior,
+                   double switchP, IGoodnessCompareEngine comparer, 
SearchPoint pbest) {
       this.switchP = switchP;
 
       problemEncoder = encoder;
@@ -82,6 +83,7 @@ public class DEPSAgent {
       trailPoint = problemEncoder.getFreshSearchPoint();
       pold_t = problemEncoder.getFreshSearchPoint();
       pcurrent_t = problemEncoder.getFreshSearchPoint();
+      pbest_t = pbest;
 
       this.deGTBehavior = deGTBehavior;
       this.deGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
@@ -94,12 +96,6 @@ public class DEPSAgent {
     qualityComparator = comparer;
   }
 
-  public void setPbest(SearchPoint pbest) {
-    pbest_t = pbest;
-    deGTBehavior.setPbest(pbest_t);
-    psGTBehavior.setPbest(pbest_t);
-  }
-
   private AbsGTBehavior getGTBehavior() {
     if (RandomGenerator.doubleZeroOneRandom() < switchP) {
       return deGTBehavior;
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 09110581659c..2701c9dee9f0 100644
--- 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
+++ 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/AbsGTBehavior.java
@@ -35,10 +35,6 @@ abstract public class AbsGTBehavior implements ILibEngine {
     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/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
index 7a4c552d9e60..2b6c1ce36c73 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -141,8 +141,9 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
             psGTBehavior.weight = m_weight.getValue();
             psGTBehavior.setLibrary(m_library);
 
-            agents[i] = new DEPSAgent(m_problemEncoder, deGTBehavior, 
psGTBehavior, m_agentSwitchRate.getValue(), m_specCompareEngine);
-            agents[i].setPbest(m_library.getSelectedPoint(i));
+            agents[i] = new DEPSAgent(m_problemEncoder, deGTBehavior, 
psGTBehavior,
+                                      m_agentSwitchRate.getValue(), 
m_specCompareEngine,
+                                      m_library.getSelectedPoint(i));
         }
 
         //Learn:

Reply via email to