core.git: nlpsolver/src

2024-04-29 Thread Todor Balabanov (via logerrit)
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java |   
 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 763149e2f48766427e0962058ad812b07caf1e07
Author: Todor Balabanov 
AuthorDate: Sun Apr 28 12:14:40 2024 +0300
Commit: Caolán McNamara 
CommitDate: Mon Apr 29 15:40:27 2024 +0200

Double values comparison changed to compare method.

Using the Double.compare() method is often preferred over the == comparison
operator for comparing double values due to several reasons:

Handling NaN (Not-a-Number) values: The Double.compare() method correctly
handles NaN values, while the == operator does not. If either of the 
operands
is NaN, the == operator will always return false, regardless of the other
operand. In contrast, Double.compare() will correctly evaluate NaN values
according to the IEEE 754 floating-point standard.

Handling positive and negative zero: The == operator treats positive zero 
and
negative zero as equal, whereas they are distinct values in IEEE 754
floating-point representation. Double.compare() correctly distinguishes
between positive and negative zero.

Robustness against rounding errors: Floating-point arithmetic can introduce
rounding errors, causing two double values that should be equal to differ
slightly. Directly comparing them with the == operator might yield 
unexpected
results due to these small differences. Double.compare() allows you to 
define
a tolerance level if necessary, providing more control over how equality is
determined.

Consistent behavior: The behavior of Double.compare() is consistent and
predictable across different platforms and JVM implementations, as it 
follows
the IEEE 754 standard. On the other hand, the behavior of the == operator
might vary depending on the platform and compiler optimizations.

Suitability for sorting: Double.compare() returns an integer value that can
be directly used for sorting double values in ascending or descending order.
This makes it convenient for sorting arrays or collections of double values.

Overall, while the == operator might work in some cases, using
Double.compare() provides more robust and predictable behavior, especially
when dealing with floating-point numbers in Java.

Change-Id: I5756936a0d2b4fe11b9113ddd33b6ae691f5103f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166796
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
index 0c402e87c12f..b3ec15a8ca92 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -211,7 +211,7 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 //0 is a bad starting point, so just pick some other.
 //That is certainly not optimal but the user should specify
 //bounds or at least a good starting point anyway.
-if (value == 0.0)
+if (Double.compare(value, 0.0D) == 0)
 value = 1000;
 
 double b1;
@@ -366,7 +366,7 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 
 switch (m_extConstraints[i].Operator.getValue()) {
 case SolverConstraintOperator.EQUAL_value:
-result = value == targetValue;
+result = Double.compare(value, targetValue) == 0;
 break;
 case SolverConstraintOperator.GREATER_EQUAL_value:
 result = value >= targetValue;
@@ -375,10 +375,10 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 result = value <= targetValue;
 break;
 case SolverConstraintOperator.INTEGER_value:
-result = Math.rint(value) == value;
+result = Double.compare(Math.rint(value), value) == 0;
 break;
 case SolverConstraintOperator.BINARY_value:
-result = (value == 0.0 || value == 1.0);
+result = (Double.compare(value, 0.0D) == 0 || 
Double.compare(value, 1.0D) == 0);
 break;
 }
 } else {


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

2021-08-06 Thread Caolán McNamara (via logerrit)
 
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 
AuthorDate: Fri Aug 6 12:22:43 2021 +0100
Commit: Caolán McNamara 
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 

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:


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

2021-08-02 Thread Todor Balabanov (via logerrit)
 
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 
AuthorDate: Tue Jul 27 20:13:32 2021 +0300
Commit: Noel Grandin 
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 
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

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
--- 

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

2021-07-18 Thread Noel Grandin (via logerrit)
 
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java 
|   33 ++
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java 
 |4 -
 2 files changed, 23 insertions(+), 14 deletions(-)

New commits:
commit 4b99e377473e74160627d3b257fec7b3bc8e7763
Author: Noel Grandin 
AuthorDate: Sun Jul 18 09:11:57 2021 +0200
Commit: Noel Grandin 
CommitDate: Sun Jul 18 10:35:16 2021 +0200

Revert "Some lower objects coupling."

This reverts commit 7b93bae224c7c2c49b105ef97304bb46f8b68da5.

Reason for revert: Does not compile

/home/tdf/lode/jenkins/workspace/lo_ubsan/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java:45:
 error: DEPSAgent is not abstract and does not override abstract method 
setLibrary(Library) in ILibEngine
public class DEPSAgent implements ILibEngine {
   ^
1 error

Change-Id: I72f2a22ab1f4119178f8002c21ba0845c4cd1bdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119040
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
index 7a6077a725c4..b3e5f310031f 100644
--- 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
+++ 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -38,6 +38,7 @@ import net.adaptivebox.deps.behavior.PSGTBehavior;
 import net.adaptivebox.global.RandomGenerator;
 import net.adaptivebox.goodness.IGoodnessCompareEngine;
 import net.adaptivebox.knowledge.ILibEngine;
+import net.adaptivebox.knowledge.Library;
 import net.adaptivebox.knowledge.SearchPoint;
 import net.adaptivebox.problem.ProblemEncoder;
 import net.adaptivebox.space.BasicPoint;
@@ -71,21 +72,31 @@ public class DEPSAgent implements ILibEngine {
 
   private double switchP = 0.5;
 
-  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer) {
-problemEncoder = encoder;
+  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer, 
Library lib) {
+  setProblemEncoder(encoder);
 
-trailPoint = problemEncoder.getFreshSearchPoint();
-pold_t = problemEncoder.getFreshSearchPoint();
-pcurrent_t = problemEncoder.getFreshSearchPoint();
+  this.switchP = switchP;
 
-this.switchP = switchP;
+  deGTBehavior.setLibrary(lib);
+  psGTBehavior.setLibrary(lib);
+  setGTBehavior(deGTBehavior);
+  setGTBehavior(psGTBehavior);
+  this.deGTBehavior = deGTBehavior;
+  this.psGTBehavior = psGTBehavior;
 
-setGTBehavior(deGTBehavior);
-setGTBehavior(psGTBehavior);
-this.deGTBehavior = deGTBehavior;
-this.psGTBehavior = psGTBehavior;
+  qualityComparator = comparer;
+  }
 
-qualityComparator = comparer;
+  public void setLibrary(Library lib) {
+deGTBehavior.setLibrary(lib);
+psGTBehavior.setLibrary(lib);
+  }
+
+  public void setProblemEncoder(ProblemEncoder encoder) {
+problemEncoder = encoder;
+trailPoint = problemEncoder.getFreshSearchPoint();
+pold_t = problemEncoder.getFreshSearchPoint();
+pcurrent_t = problemEncoder.getFreshSearchPoint();
   }
 
   public void setSpecComparator(IGoodnessCompareEngine comparer) {
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 edba08936d39..20cf9286e91a 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -131,16 +131,14 @@ 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);
+agents[i] = new DEPSAgent(m_problemEncoder, deGTBehavior, 
psGTBehavior, m_agentSwitchRate.getValue(), m_specCompareEngine, m_library);
 agents[i].setPbest(m_library.getSelectedPoint(i));
 }
 
___
Libreoffice-commits mailing list

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

2021-07-17 Thread Todor Balabanov (via logerrit)
 
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java 
|   33 +++---
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java 
 |4 -
 2 files changed, 14 insertions(+), 23 deletions(-)

New commits:
commit 7b93bae224c7c2c49b105ef97304bb46f8b68da5
Author: Todor Balabanov 
AuthorDate: Sat Jul 17 18:27:27 2021 +0300
Commit: Noel Grandin 
CommitDate: Sat Jul 17 22:22:17 2021 +0200

Some lower objects coupling.

Change-Id: I0a7c658d830f82d627d20b9ed7000f3c5b8f1f89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119105
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
index b3e5f310031f..7a6077a725c4 100644
--- 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
+++ 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -38,7 +38,6 @@ import net.adaptivebox.deps.behavior.PSGTBehavior;
 import net.adaptivebox.global.RandomGenerator;
 import net.adaptivebox.goodness.IGoodnessCompareEngine;
 import net.adaptivebox.knowledge.ILibEngine;
-import net.adaptivebox.knowledge.Library;
 import net.adaptivebox.knowledge.SearchPoint;
 import net.adaptivebox.problem.ProblemEncoder;
 import net.adaptivebox.space.BasicPoint;
@@ -72,31 +71,21 @@ public class DEPSAgent implements ILibEngine {
 
   private double switchP = 0.5;
 
-  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer, 
Library lib) {
-  setProblemEncoder(encoder);
-
-  this.switchP = switchP;
-
-  deGTBehavior.setLibrary(lib);
-  psGTBehavior.setLibrary(lib);
-  setGTBehavior(deGTBehavior);
-  setGTBehavior(psGTBehavior);
-  this.deGTBehavior = deGTBehavior;
-  this.psGTBehavior = psGTBehavior;
-
-  qualityComparator = comparer;
-  }
-
-  public void setLibrary(Library lib) {
-deGTBehavior.setLibrary(lib);
-psGTBehavior.setLibrary(lib);
-  }
-
-  public void setProblemEncoder(ProblemEncoder encoder) {
+  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer) {
 problemEncoder = encoder;
+
 trailPoint = problemEncoder.getFreshSearchPoint();
 pold_t = problemEncoder.getFreshSearchPoint();
 pcurrent_t = problemEncoder.getFreshSearchPoint();
+
+this.switchP = switchP;
+
+setGTBehavior(deGTBehavior);
+setGTBehavior(psGTBehavior);
+this.deGTBehavior = deGTBehavior;
+this.psGTBehavior = psGTBehavior;
+
+qualityComparator = comparer;
   }
 
   public void setSpecComparator(IGoodnessCompareEngine comparer) {
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..edba08936d39 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -131,14 +131,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));
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-07-13 Thread Todor Balabanov (via logerrit)
 
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java 
|   29 +-
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java 
 |   12 
 2 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit a71caa79c8eb09ff0374cdaf4b081ba42d1330a1
Author: Todor Balabanov 
AuthorDate: Mon Jul 12 19:13:32 2021 +0300
Commit: Noel Grandin 
CommitDate: Tue Jul 13 09:57:41 2021 +0200

Object initialization is done via a constructor with parameters.

Change-Id: I66e87f7c898efb1f2c6b1d31fbd5654244e3ea82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118785
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
index adc6a75bd4f4..b3e5f310031f 100644
--- 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
+++ 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/DEPSAgent.java
@@ -69,7 +69,23 @@ public class DEPSAgent implements ILibEngine {
   // Generate-and-test behaviors.
   private DEGTBehavior deGTBehavior;
   private PSGTBehavior psGTBehavior;
-  public double switchP = 0.5;
+
+  private double switchP = 0.5;
+
+  public DEPSAgent(ProblemEncoder encoder, DEGTBehavior deGTBehavior, 
PSGTBehavior psGTBehavior, double switchP, IGoodnessCompareEngine comparer, 
Library lib) {
+  setProblemEncoder(encoder);
+
+  this.switchP = switchP;
+
+  deGTBehavior.setLibrary(lib);
+  psGTBehavior.setLibrary(lib);
+  setGTBehavior(deGTBehavior);
+  setGTBehavior(psGTBehavior);
+  this.deGTBehavior = deGTBehavior;
+  this.psGTBehavior = psGTBehavior;
+
+  qualityComparator = comparer;
+  }
 
   public void setLibrary(Library lib) {
 deGTBehavior.setLibrary(lib);
@@ -101,17 +117,6 @@ public class DEPSAgent implements ILibEngine {
 
   public void setGTBehavior(AbsGTBehavior gtBehavior) {
 gtBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
-
-// see getGTBehavior and setLibrary for uses of
-// deGTBehavior and psGTBehavior
-if (gtBehavior instanceof DEGTBehavior) {
-  deGTBehavior = ((DEGTBehavior) gtBehavior);
-  return;
-}
-if (gtBehavior instanceof PSGTBehavior) {
-  psGTBehavior = ((PSGTBehavior) gtBehavior);
-  return;
-}
   }
 
   public void generatePoint() {
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 aff425ba4e20..20cf9286e91a 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -127,10 +127,6 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
 //Init:
 DEPSAgent[] agents = new DEPSAgent[m_swarmSize.getValue()];
 for (int i = 0; i < m_swarmSize.getValue(); i++) {
-agents[i] = new DEPSAgent();
-agents[i].setProblemEncoder(m_problemEncoder);
-agents[i].setPbest(m_library.getSelectedPoint(i));
-
 DEGTBehavior deGTBehavior = new DEGTBehavior();
 deGTBehavior.MIN_FACTOR = Math.min(m_minFactor.getValue(), 
m_maxFactor.getValue());
 deGTBehavior.MAX_FACTOR = Math.max(m_minFactor.getValue(), 
m_maxFactor.getValue());
@@ -142,12 +138,8 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
 psGTBehavior.CL = m_CL.getValue();
 psGTBehavior.weight = m_weight.getValue();
 
-agents[i].switchP = m_agentSwitchRate.getValue();
-agents[i].setGTBehavior(deGTBehavior);
-agents[i].setGTBehavior(psGTBehavior);
-
-agents[i].setSpecComparator(m_specCompareEngine);
-agents[i].setLibrary(m_library);
+agents[i] = new DEPSAgent(m_problemEncoder, deGTBehavior, 
psGTBehavior, m_agentSwitchRate.getValue(), m_specCompareEngine, m_library);
+agents[i].setPbest(m_library.getSelectedPoint(i));
 }
 
 //Learn:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-06-21 Thread Todor Balabanov (via logerrit)
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java |   
 5 +
 nlpsolver/src/locale/NLPSolverCommon_en_US.properties  |   
 1 +
 2 files changed, 6 insertions(+)

New commits:
commit 89459662bf2684a07596d4132c84e5da7e0af8d4
Author: Todor Balabanov 
AuthorDate: Sun Jun 20 13:49:57 2021 +0300
Commit: Noel Grandin 
CommitDate: Mon Jun 21 08:48:50 2021 +0200

Global optimization metaheuristics sometimes are sensitive to the quality 
of the random numbers.

Change-Id: Ibc1e95736c5f9355e67f2129a7804064e329da89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117510
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
index b33d77a438d9..0c402e87c12f 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -34,6 +34,7 @@ import com.sun.star.sheet.SolverConstraintOperator;
 import com.sun.star.uno.XComponentContext;
 import java.util.ArrayList;
 import net.adaptivebox.global.BasicBound;
+import net.adaptivebox.global.RandomGenerator;
 import net.adaptivebox.goodness.ACRComparator;
 import net.adaptivebox.goodness.BCHComparator;
 import net.adaptivebox.goodness.IGoodnessCompareEngine;
@@ -53,6 +54,7 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 registerProperty(m_useACRComperator);
 
 registerProperty(m_useRandomStartingPoint);
+registerProperty(m_useStrongerPRNG);
 
 registerProperty(m_required);
 registerProperty(m_tolerance);
@@ -168,6 +170,7 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 private final PropertyInfo m_variableRangeThreshold = new 
PropertyInfo("VariableRangeThreshold", 3.0, "Variable Bounds Threshold 
(when guessing)"); //to approximate the variable bounds
 private final PropertyInfo m_useACRComperator = new 
PropertyInfo("UseACRComparator", false, "Use ACR Comparator (instead 
of BCH)");
 private final PropertyInfo m_useRandomStartingPoint = new 
PropertyInfo("UseRandomStartingPoint", false, "Use Random starting 
point");
+private final PropertyInfo m_useStrongerPRNG = new 
PropertyInfo("UseStrongerPRNG", false, "Use a stronger random 
generator (slower)");
 protected PropertyInfo m_required = new 
PropertyInfo("StagnationLimit", 70, "Stagnation Limit");
 protected PropertyInfo m_tolerance = new 
PropertyInfo("Tolerance", 1e-6, "Stagnation Tolerance");
 private final PropertyInfo m_enhancedSolverStatus = new 
PropertyInfo("EnhancedSolverStatus", true, "Show enhanced solver 
status");
@@ -324,6 +327,8 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 
 m_envCompareEngine = new BCHComparator();
 m_specCompareEngine = m_useACRComperator.getValue() ? new 
ACRComparator(m_library, m_learningCycles.getValue()) : new BCHComparator();
+
+RandomGenerator.useStrongerGenerator( m_useStrongerPRNG.getValue() );
 }
 
 protected void applySolution() {
diff --git a/nlpsolver/src/locale/NLPSolverCommon_en_US.properties 
b/nlpsolver/src/locale/NLPSolverCommon_en_US.properties
index 84262674ddb9..5ab304d69ebb 100644
--- a/nlpsolver/src/locale/NLPSolverCommon_en_US.properties
+++ b/nlpsolver/src/locale/NLPSolverCommon_en_US.properties
@@ -9,6 +9,7 @@ NLPSolverCommon.Properties.GuessVariableRange=Variable Bounds 
Guessing
 NLPSolverCommon.Properties.VariableRangeThreshold=Variable Bounds Threshold 
(when guessing)
 NLPSolverCommon.Properties.UseACRComparator=Use ACR Comparator (instead of BCH)
 NLPSolverCommon.Properties.UseRandomStartingPoint=Use Random starting point
+NLPSolverCommon.Properties.UseStrongerPRNG=Use a stronger random generator 
(slower)
 NLPSolverCommon.Properties.StagnationLimit=Stagnation Limit
 NLPSolverCommon.Properties.Tolerance=Stagnation Tolerance
 NLPSolverCommon.Properties.EnhancedSolverStatus=Show enhanced solver status
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: nlpsolver/src reportbuilder/java wizards/com

2021-05-03 Thread Noel Grandin (via logerrit)
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java  |
1 +
 reportbuilder/java/org/libreoffice/report/pentaho/SOReportJobFactory.java |
2 +-
 wizards/com/sun/star/wizards/form/UIControlArranger.java  |
4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit ed33d1d4928dc9886eaace62d3c62ea4305efdac
Author: Noel Grandin 
AuthorDate: Mon May 3 09:59:08 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon May 3 12:33:33 2021 +0200

clean up some Java warnings

Change-Id: Id54e8fd6803c3a6c0d924338d1781679ed0b1bfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115025
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
index f1a7a4714f05..dc5663213458 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
@@ -49,6 +49,7 @@ public class PropertyInfo {
 return m_description;
 }
 
+@SuppressWarnings("unchecked")
 public void setValue(Object value) throws IllegalArgumentException {
 if (m_property.Type == Type.LONG) {
 if (!(value instanceof Integer))
diff --git 
a/reportbuilder/java/org/libreoffice/report/pentaho/SOReportJobFactory.java 
b/reportbuilder/java/org/libreoffice/report/pentaho/SOReportJobFactory.java
index 3c52473e3d3c..322c2ac1ccfa 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/SOReportJobFactory.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/SOReportJobFactory.java
@@ -205,7 +205,7 @@ public class SOReportJobFactory
 {
 if (exception instanceof ReportDataFactoryException == false)
 return;
-exception = ((ReportDataFactoryException)exception).getParent();
+exception = ((ReportDataFactoryException)exception).getCause();
 if (exception instanceof DataSourceException == false)
 return;
 exception = ((DataSourceException)exception).getCause();
diff --git a/wizards/com/sun/star/wizards/form/UIControlArranger.java 
b/wizards/com/sun/star/wizards/form/UIControlArranger.java
index b73796eca410..8f92e8ce66b5 100644
--- a/wizards/com/sun/star/wizards/form/UIControlArranger.java
+++ b/wizards/com/sun/star/wizards/form/UIControlArranger.java
@@ -47,7 +47,7 @@ public class UIControlArranger
 private final XRadioButton optAlignLeft;
 private final XRadioButton optAlignRight;
 private final XControl flnLabelPlacement;
-private final Map helpTexts = new HashMap(4);
+private final Map helpTexts = new HashMap(4);
 private final ArrangeButtonList[] m_aArrangeList = new 
ArrangeButtonList[2];
 private final Integer IControlStep;
 private static final int SOBASEIMAGEYPOSITION = 66;
@@ -109,7 +109,7 @@ public class UIControlArranger
 });
 
 
-DefaultListModel imageModel = new DefaultListModel();
+DefaultListModel imageModel = new DefaultListModel();
 imageModel.addElement(ARRANGELISTSIDE);
 imageModel.addElement(ARRANGELISTTOP);
 imageModel.addElement(ARRANGETABLE);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-09-25 Thread Noel Grandin (via logerrit)
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java |   
14 --
 1 file changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 92552cfdf5693b03312aa97c6e014d0c2b7c565b
Author: Noel Grandin 
AuthorDate: Fri Sep 25 12:00:32 2020 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 25 17:56:55 2020 +0200

value and targetValue cannot be null at this point

Change-Id: I175da8a170fcddca083ed47b41c7241433e54db0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103383
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
index f5b3f0018cef..b33d77a438d9 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -356,23 +356,21 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 boolean result = true;
 for (int i = 0; i < m_constraintCount && result; i++) {
 if (m_extConstraints[i].Left.getError() == 0) {
-Double value, targetValue;
-
-value = m_extConstraints[i].getLeftValue();
-targetValue = m_extConstraints[i].Data;
+double value = m_extConstraints[i].getLeftValue();
+double targetValue = m_extConstraints[i].Data;
 
 switch (m_extConstraints[i].Operator.getValue()) {
 case SolverConstraintOperator.EQUAL_value:
-result = (targetValue != null && 
value.equals(targetValue));
+result = value == targetValue;
 break;
 case SolverConstraintOperator.GREATER_EQUAL_value:
-result = (targetValue != null && value >= targetValue);
+result = value >= targetValue;
 break;
 case SolverConstraintOperator.LESS_EQUAL_value:
-result = (targetValue != null && value <= targetValue);
+result = value <= targetValue;
 break;
 case SolverConstraintOperator.INTEGER_value:
-result = (Math.rint(value) == value);
+result = Math.rint(value) == value;
 break;
 case SolverConstraintOperator.BINARY_value:
 result = (value == 0.0 || value == 1.0);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-28 Thread Julien Nabet (via logerrit)
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java |   
 4 
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java |   
 4 
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java  |   
 5 +
 3 files changed, 13 insertions(+)

New commits:
commit a7e92d71d72d69b887bf716f30af37105f206915
Author: Julien Nabet 
AuthorDate: Tue Jul 28 11:32:03 2020 +0200
Commit: Julien Nabet 
CommitDate: Tue Jul 28 12:52:20 2020 +0200

Related tdf#135211: return early if no data

With DEPS or SCO Evolutionary algorithms, it'll return
"No solution found."
Change-Id: I15e8e24eb519a20e3f3645b79e990949f648fbd2

Change-Id: I7321419ccc1cd00d75f03fa86d3c0cb4bf9ad473
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99584
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
index 7fb4eadd57ba..f5b3f0018cef 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -189,6 +189,10 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 protected void initializeSolve() {
 super.initializeSolve();
 
+if (m_variableCount == 0)
+{
+return;
+}
 if (m_enhancedSolverStatus.getValue())
 m_solverStatusDialog = new EvolutionarySolverStatusUno(m_xContext);
 else
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 f152cf92d481..aff425ba4e20 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -119,6 +119,10 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
 Logger.getLogger(DEPSSolverImpl.class.getName()).log(Level.SEVERE, 
null, ex);
 }
 initializeSolve();
+if (m_problemEncoder == null)
+{
+return;
+}
 
 //Init:
 DEPSAgent[] agents = new DEPSAgent[m_swarmSize.getValue()];
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java
index cefe51006751..c1798606d4e6 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/SCOSolverImpl.java
@@ -90,6 +90,11 @@ public final class SCOSolverImpl extends 
BaseEvolutionarySolver
 public void solve() {
 initializeSolve();
 
+if (m_problemEncoder == null)
+{
+return;
+}
+
 //Init:
 int swarmSize = m_swarmSize.getValue();
 SCAgent[] agents = new SCAgent[swarmSize];
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-28 Thread Julien Nabet (via logerrit)
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java |   
 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 292876695246dffbc6829cf1b588e4346b24441a
Author: Julien Nabet 
AuthorDate: Tue Jul 28 10:45:42 2020 +0200
Commit: Julien Nabet 
CommitDate: Tue Jul 28 11:34:53 2020 +0200

Typo: Swam->Swarm

Change-Id: I99dbe7fa6d49e0663c3551d2e3dabd3f42d8d3c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99578
Reviewed-by: Julien Nabet 
Tested-by: Julien Nabet 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
index c0b10c2f4951..7fb4eadd57ba 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -161,7 +161,7 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 private final ArrayList m_variables = new ArrayList();
 
 //properties
-protected PropertyInfo m_swarmSize = new 
PropertyInfo("SwarmSize", 70, "Size of Swam");
+protected PropertyInfo m_swarmSize = new 
PropertyInfo("SwarmSize", 70, "Size of Swarm");
 protected PropertyInfo m_librarySize = new 
PropertyInfo("LibrarySize", 210, "Size of Library");
 protected PropertyInfo m_learningCycles = new 
PropertyInfo("LearningCycles", 2000, "Learning Cycles");
 private final PropertyInfo m_guessVariableRange = new 
PropertyInfo("GuessVariableRange", true, "Variable Bounds Guessing");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2019-06-03 Thread Todor Balabanov (via logerrit)
 
nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
 |7 +--
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java 
 |9 ++---
 nlpsolver/src/locale/NLPSolverCommon_en_US.properties  
 |3 ++-
 3 files changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 90ace7be71d41257e29a28fa2e7c0adf8f84050d
Author: Todor Balabanov 
AuthorDate: Wed May 15 19:54:21 2019 +0300
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 3 15:53:30 2019 +0200

Range for DE scaling factor was implemented.

Change-Id: I5b8d3cd69a6138d7eebf37c299626019b32d639a
Reviewed-on: https://gerrit.libreoffice.org/72373
Reviewed-by: Tomaž Vajngerl 
Tested-by: Tomaž Vajngerl 

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 645318341108..0e68f856d912 100644
--- 
a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
+++ 
b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java
@@ -41,7 +41,10 @@ public class DEGTBehavior extends AbsGTBehavior implements 
ILibEngine {
   private static final int DVNum = 2;
 
   //scale constant: (0, 1.2], normally be 0.5
-  public double FACTOR = 0.5;
+  public double MIN_FACTOR = 0.5;
+
+  //scale constant: (0, 1.2], normally be 0.5
+  public double MAX_FACTOR = 0.5;
 
   //crossover constant: [0, 1], normally be 0.1 or 0.9
   public double CR = 0.9;
@@ -70,7 +73,7 @@ public class DEGTBehavior extends AbsGTBehavior implements 
ILibEngine {
   delta += (i % 2 == 0 ? +1D : -1D) * 
differenceVectors[i].getLocation()[index];
 }
 
-trialVector[index] = globalVector[index] + FACTOR * delta;
+trialVector[index] = globalVector[index] + 
RandomGenerator.doubleRangeRandom(MIN_FACTOR, MAX_FACTOR) * delta;
   }
 
   @Override
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 716a79b79438..2e5c38d0d179 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java
@@ -59,7 +59,8 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
 super(context, "DEPS Evolutionary Algorithm");
 
 registerProperty(m_agentSwitchRate);
-registerProperty(m_factor);
+registerProperty(m_minFactor);
+registerProperty(m_maxFactor);
 registerProperty(m_CR);
 registerProperty(m_c1);
 registerProperty(m_c2);
@@ -102,7 +103,8 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
 
 private final PropertyInfo m_agentSwitchRate = new 
PropertyInfo("AgentSwitchRate", 0.5, "Agent Switch Rate (DE 
Probability)");
 // --DE
-private final PropertyInfo m_factor = new 
PropertyInfo("DEFactor", 0.5, "DE: Scaling Factor (0-1.2)");
+private final PropertyInfo m_minFactor = new 
PropertyInfo("DEFactorMin", 0.5, "DE: Min Scaling Factor (0-1.2)");
+private final PropertyInfo m_maxFactor = new 
PropertyInfo("DEFactorMax", 0.5, "DE: Max Scaling Factor (0-1.2)");
 private final PropertyInfo m_CR = new PropertyInfo("DECR", 
0.9, "DE: Crossover Probability (0-1)");
 // --PS
 private final PropertyInfo m_c1 = new PropertyInfo("PSC1", 
1.494, "PS: Cognitive Constant");
@@ -126,7 +128,8 @@ public final class DEPSSolverImpl extends 
BaseEvolutionarySolver
 agents[i].setPbest(m_library.getSelectedPoint(i));
 
 DEGTBehavior deGTBehavior = new DEGTBehavior();
-deGTBehavior.FACTOR = m_factor.getValue();
+deGTBehavior.MIN_FACTOR = m_minFactor.getValue();
+deGTBehavior.MAX_FACTOR = m_maxFactor.getValue();
 deGTBehavior.CR = m_CR.getValue();
 
 PSGTBehavior psGTBehavior = new PSGTBehavior();
diff --git a/nlpsolver/src/locale/NLPSolverCommon_en_US.properties 
b/nlpsolver/src/locale/NLPSolverCommon_en_US.properties
index 3f8baf0d43d7..84262674ddb9 100644
--- a/nlpsolver/src/locale/NLPSolverCommon_en_US.properties
+++ b/nlpsolver/src/locale/NLPSolverCommon_en_US.properties
@@ -15,7 +15,8 @@ NLPSolverCommon.Properties.EnhancedSolverStatus=Show enhanced 
solver status
 
 #DEPS
 NLPSolverCommon.Properties.AgentSwitchRate=Agent Switch Rate (DE Probability)
-NLPSolverCommon.Properties.DEFactor=DE: Scaling Factor (0-1.2)
+NLPSolverCommon.Properties.DEFactorMin=DE: Min Scaling Factor (0-1.2)
+NLPSolverCommon.Properties.DEFactorMax=DE: Max Scaling Factor (0-1.2)
 NLPSolverCommon.Properties.DECR=DE: Crossover Probability (0-1)
 NLPSolverCommon.Properties.PSC1=PS: Cognitive Constant
 NLPSolverCommon.Properties.PSC2=PS: Social Constant
___

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

2018-06-25 Thread Julien Nabet
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java |   
 6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 02a66f29fec36aed5fb1e800a08c1390d3674b59
Author: Julien Nabet 
Date:   Sun Jun 24 21:35:06 2018 +0200

tdf#43388: add missing info for Evolutionary Algorithm Solver

Add SolverConstraintOperator.INTEGER_value case and in the same time
the also missing SolverConstraintOperator.BINARY_value case

Change-Id: I18b826e74a2381dedaea3090919118b8d5dad072
Reviewed-on: https://gerrit.libreoffice.org/56359
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
index 701e6ba63226..c0b10c2f4951 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java
@@ -105,6 +105,12 @@ public abstract class BaseEvolutionarySolver extends 
BaseNLPSolver {
 case SolverConstraintOperator.LESS_EQUAL_value:
 setDefaultYAt(i + 1, BasicBound.MINDOUBLE, 
constraint.Data);
 break;
+case SolverConstraintOperator.INTEGER_value:
+setDefaultYAt(i + 1, BasicBound.MINDOUBLE, 
BasicBound.MAXDOUBLE);
+break;
+case SolverConstraintOperator.BINARY_value:
+setDefaultYAt(i + 1, 0, 1);
+break;
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-12-12 Thread Laurent Balland-Poirier
 
nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
 |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0412d863d144344b4c6c04b22209c0c57f1d6fb8
Author: Laurent Balland-Poirier 
Date:   Wed Nov 30 21:50:06 2016 +0100

tdf#104268 NLPSolver: Improve display of solution

Format "%.2f" is not optimal for large or small values.
Format "%g" should be prefered.

Change-Id: I92899d80564b9000b1f3e049221c456f8e1176a9
Reviewed-on: https://gerrit.libreoffice.org/31445
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
index da8dbb2..e3695a0 100644
--- 
a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
+++ 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/dialogs/EvolutionarySolverStatusUno.java
@@ -177,7 +177,7 @@ public class EvolutionarySolverStatusUno extends BaseDialog
 }
 
 public void setBestSolution(double solution, boolean feasible) {
-lblSolutionValue.setLabel(String.format("%.2f", solution));
+lblSolutionValue.setLabel(String.format("%g", solution));
 if (feasible)
 lblSolutionValue.setTextColor(defaultTextColor);
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-10-21 Thread Stephan Bergmann
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 115fa590dc7d4f37714d514309643896a5041ab4
Author: Stephan Bergmann 
Date:   Wed Oct 21 10:56:24 2015 +0200

More plausible fix

...for 7c465e7f9e8b5c34a4926fb0de84de70aee8f37d "coverity#1326260 Explicit 
null
dereferenced"

Change-Id: I3b7fb8195c29b7e447fbe31f823cd00d7a820e95

diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
index 16bb7e8..e1386a6 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
@@ -246,8 +246,10 @@ public abstract class BaseNLPSolver extends WeakBase
 RowInfo currentRow = null;
 int lastSheet = -1, lastRow = -1;
 for (int i = 0; i < m_variableCount; i++) {
-if (lastSheet == m_variables[i].Sheet && lastRow == 
m_variables[i].Row &&
-currentRow != null && currentRow.EndCol == 
m_variables[i].Column - 1)
+boolean match = lastSheet == m_variables[i].Sheet &&
+lastRow == m_variables[i].Row;
+assert !match || currentRow != null;
+if (match && currentRow.EndCol == m_variables[i].Column - 1)
 currentRow.EndCol++;
 else {
 currentRow = new RowInfo(m_variables[i].Sheet, 
m_variables[i].Row);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-02-16 Thread LeMoyne Castle
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java |   19 
--
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java  |7 ++-
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java  |4 --
 3 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit c290998df667bd2a8a12379642f79d09eca471c3
Author: LeMoyne Castle lemoyne.cas...@gmail.com
Date:   Sun Feb 15 09:05:46 2015 -0700

tdf#87074 null-ref error from NLPSolver in Basic

Initialize java class member objects exposed as
XSolver properties: no default construction in java.
Fixes issue for both DEPS and SCO solvers.
Also removed info level console prints.

Change-Id: I6762c5cca978072ce20b1f69a6b523f53364107d
Reviewed-on: https://gerrit.libreoffice.org/14499
Reviewed-by: Noel Grandin noelgran...@gmail.com
Tested-by: Noel Grandin noelgran...@gmail.com

diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
index 30b8392..73da46b 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
@@ -78,9 +78,17 @@ public abstract class BaseNLPSolver extends WeakBase
 private com.sun.star.lang.Locale m_locale = new com.sun.star.lang.Locale();
 private final ResourceManager resourceManager;
 
+private CellAddress m_objective;
+protected CellAddress[] m_variables;
+protected SolverConstraint[] m_constraints;
+
 public BaseNLPSolver(XComponentContext xContext, String name) {
 m_xContext = xContext;
 m_name = name;
+// init members exposed as XSolver properties thru uno bridge
+m_objective = new CellAddress();
+m_variables = new CellAddress[0];
+m_constraints = new SolverConstraint[0];
 
 XMultiComponentFactory componentFactory = xContext.getServiceManager();
 try {
@@ -117,9 +125,6 @@ public abstract class BaseNLPSolver extends WeakBase
 private XSpreadsheetDocument m_document;
 private XModel m_xModel;
 protected XReschedule m_xReschedule;
-private CellAddress m_objective;
-protected CellAddress[] m_variables;
-protected SolverConstraint[] m_constraints;
 protected ExtSolverConstraint[] m_extConstraints;
 protected boolean m_maximize;
 
@@ -155,9 +160,6 @@ public abstract class BaseNLPSolver extends WeakBase
 }
 
 public CellAddress[] getVariables() {
-if (m_variables == null)
-return new CellAddress[0]; //Workaround for basic scripts; 
otherwise
-   //setting the Variables property fails.
 return m_variables;
 }
 
@@ -296,9 +298,6 @@ public abstract class BaseNLPSolver extends WeakBase
 }
 
 public SolverConstraint[] getConstraints() {
-if (m_constraints == null)
-return new SolverConstraint[0]; //Workaround for basic scripts; 
otherwise
-//setting the Constraints property 
fails.
 return m_constraints;
 }
 
@@ -463,7 +462,7 @@ public abstract class BaseNLPSolver extends WeakBase
 return m_propertyMap.containsKey(property);
 }
 
-// editor-fold defaultstate=collapsed desc=Helper functions
+// Helper functions
 private void lockDocument(boolean lock) {
 if (lock)
 m_xModel.lockControllers();
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
index 2371f0e..f1a7a47 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java
@@ -89,10 +89,11 @@ public class PropertyInfoPropType {
 
 public void localize(ResourceManager resourceManager) {
 try {
-m_description = resourceManager.getLocalizedString(Properties. + 
m_property.Name);
-   System.out.println(Localised description to  + m_description);
+m_description = resourceManager.getLocalizedString(Properties.
++ m_property.Name);
 } catch (com.sun.star.resource.MissingResourceException ex) {
-   System.out.println(No properties file !);
+System.out.println(Can't localize. Resource missing for property: 

++ m_property.Name);
 }
 }
 
diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java
index 02a3d3e..157f496 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java
@@ -23,8 +23,6 @@ public final class Registration {
 {
 XSingleComponentFactory xFactory = null;
 
-   System.out.println(Get 

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

2014-04-27 Thread Alex Gulyás
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit dfbaef22fcc66f86ecdfccb82037fbfd171c975d
Author: Alex Gulyás gulyas.a...@gmail.com
Date:   Sun Apr 27 18:06:15 2014 +0200

fdo#78004 fix string formatting

Added missing 's'

Change-Id: I7570d86d65ebcffc547b06ab9c19843de0b90436
Reviewed-on: https://gerrit.libreoffice.org/9181
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java 
b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
index 60bdcf9..8561763 100644
--- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
+++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java
@@ -553,7 +553,7 @@ public abstract class BaseNLPSolver extends WeakBase
 
 if (days  0)
 return String.format(%d %s, %d %s,
-  days, 
resourceManager.getLocalizedString(String.format(Time.Day%, days == 1 ?  : 
s), Days),
+  days, 
resourceManager.getLocalizedString(String.format(Time.Day%s, days == 1 ?  : 
s), Days),
   hours, 
resourceManager.getLocalizedString(String.format(Time.Hour%s, hours == 1 ?  
: s), Hours));
 
 if (hours  0)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits