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@yahoo.fr>
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Todor Balabanov
2021-08-02 08:41:14 +02:00
committed by Noel Grandin
parent e98f04cedf
commit 559b342a62
5 changed files with 24 additions and 27 deletions
@@ -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();
public void setProblemEncoder(ProblemEncoder encoder) {
problemEncoder = encoder;
trailPoint = problemEncoder.getFreshSearchPoint();
pold_t = problemEncoder.getFreshSearchPoint();
pcurrent_t = problemEncoder.getFreshSearchPoint();
this.deGTBehavior = deGTBehavior;
this.deGTBehavior.setMemPoints(pbest_t, pcurrent_t, pold_t);
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
@@ -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);
@@ -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;
@@ -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;
@@ -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));
}