From 90ace7be71d41257e29a28fa2e7c0adf8f84050d Mon Sep 17 00:00:00 2001 From: Todor Balabanov Date: Wed, 15 May 2019 19:54:21 +0300 Subject: Range for DE scaling factor was implemented. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5b8d3cd69a6138d7eebf37c299626019b32d639a Reviewed-on: https://gerrit.libreoffice.org/72373 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- .../src/net/adaptivebox/deps/behavior/DEGTBehavior.java | 7 +++++-- .../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(-) (limited to 'nlpsolver') 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 -- cgit