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 <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
a35b49c585
commit
a71caa79c8
2 changed files with 19 additions and 22 deletions
|
@ -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() {
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue