From 0063cf285696951e336b9cec1da8881997b286ce Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 18 Nov 2014 10:01:21 +0200 Subject: java: make fields final where possible found by PMD Change-Id: I87780366119c141cd2dafe6ca1bf2d9798b10aec --- .../adaptivebox/deps/behavior/DEGTBehavior.java | 2 +- .../src/net/adaptivebox/encode/EvalElement.java | 2 +- .../net/adaptivebox/goodness/ACRComparator.java | 16 +++++++-------- .../src/net/adaptivebox/knowledge/Library.java | 2 +- .../src/net/adaptivebox/knowledge/SearchPoint.java | 2 +- .../net/adaptivebox/problem/ProblemEncoder.java | 8 ++++---- .../src/net/adaptivebox/sco/SCAgent.java | 4 ++-- .../src/net/adaptivebox/space/BasicPoint.java | 2 +- .../Calc/NLPSolver/BaseEvolutionarySolver.java | 20 +++++++++--------- .../star/comp/Calc/NLPSolver/DEPSSolverImpl.java | 14 ++++++------- .../dialogs/EvolutionarySolverStatusUno.java | 24 +++++++++++----------- 11 files changed, 48 insertions(+), 48 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 c9879c099e61..c40f2c1ec258 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/deps/behavior/DEGTBehavior.java @@ -35,7 +35,7 @@ import net.adaptivebox.problem.*; import net.adaptivebox.space.*; public class DEGTBehavior extends AbsGTBehavior implements ILibEngine { - private int DVNum = 2; //Number of differential vectors, normally be 1 or 2 + private final int DVNum = 2; //Number of differential vectors, normally be 1 or 2 public double FACTOR = 0.5; //scale constant: (0, 1.2], normally be 0.5 public double CR = 0.9; //crossover constant: [0, 1], normally be 0.1 or 0.9 diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java index b61046d34d92..1ad1adefd08c 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/encode/EvalElement.java @@ -25,7 +25,7 @@ import net.adaptivebox.global.*; public class EvalElement { //The weight for each response (target) - private double weight = 1; + private final double weight = 1; /** * The expected range of the response value, forms the following objective: * diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java index ae8d4d130f8c..2d9f55fc2ac4 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/goodness/ACRComparator.java @@ -36,18 +36,18 @@ import net.adaptivebox.global.*; public class ACRComparator implements IGoodnessCompareEngine, IUpdateCycleEngine { - private Library socialPool; + private final Library socialPool; private double epsilon_t = 0; - private double RU = 0.75; - private double RL = 0.25; - private double BETAF = 0.618; - private double BETAL = 0.618; - private double BETAU = 1.382; + private final double RU = 0.75; + private final double RL = 0.25; + private final double BETAF = 0.618; + private final double BETAL = 0.618; + private final double BETAU = 1.382; - private double T = -1; + private final double T; - private double TthR = 0.5; + private final double TthR = 0.5; public ACRComparator(Library lib, int T) { socialPool = lib; diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java index 6b6574bcc081..d4c202c989fc 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/Library.java @@ -29,7 +29,7 @@ import net.adaptivebox.goodness.*; import net.adaptivebox.problem.*; public class Library { - private SearchPoint[] libPoints = new SearchPoint[0]; + private final SearchPoint[] libPoints; private int gIndex = -1; public Library(SearchPoint[] points){ diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java index ea37e1e5cd0b..dbd472f043e3 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/knowledge/SearchPoint.java @@ -27,7 +27,7 @@ public class SearchPoint extends BasicPoint implements IEncodeEngine { //store the encode information for goodness evaluation //encodeInfo[0]: the sum of constraints (if it equals to 0, then be a feasible point) //encodeInfo[1]: the value of objective function - private double[] encodeInfo = new double[2]; + private final double[] encodeInfo = new double[2]; private double objectiveValue; public SearchPoint(int dim) { diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java index 603648e8428d..bc32c1c8d78b 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/problem/ProblemEncoder.java @@ -33,14 +33,14 @@ import net.adaptivebox.knowledge.*; public abstract class ProblemEncoder { //Store the calculated results for the responses - private double[] tempResponseSet; //temp values - private double[] tempLocation; //temp values + private final double[] tempResponseSet; //temp values + private final double[] tempLocation; //temp values //the search space (S) - private DesignSpace designSpace = null; + private final DesignSpace designSpace; // For evaluate the response vector into encoded vector double[2] - private EvalStruct evalStruct = null; + private final EvalStruct evalStruct; protected ProblemEncoder(int paramNum, int targetNum) throws Exception { designSpace = new DesignSpace(paramNum); diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java index 2bebff6f7fda..b473ae0a3807 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/sco/SCAgent.java @@ -48,9 +48,9 @@ public class SCAgent { private IGoodnessCompareEngine specComparator; //the coefficients of SCAgent - private int TaoB = 2; + private final int TaoB = 2; //The early version set TaoW as the size of external library (NL), but 4 is often enough - private int TaoW = 4; + private final int TaoW = 4; //The referred external library private Library externalLib; diff --git a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java index 1cf1b8592a44..a590a69742f7 100644 --- a/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java +++ b/nlpsolver/ThirdParty/EvolutionarySolver/src/net/adaptivebox/space/BasicPoint.java @@ -22,7 +22,7 @@ package net.adaptivebox.space; public class BasicPoint implements Cloneable, ILocationEngine { //store the location information in the search space (S) - private double[] location; + private final double[] location; public BasicPoint(int dim) { location = new double[dim]; 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 9d779afe7225..2d93dca6e4bf 100644 --- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java +++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseEvolutionarySolver.java @@ -61,8 +61,8 @@ public abstract class BaseEvolutionarySolver extends BaseNLPSolver { } private class Variable { - private CellMap CellMap; - private int OriginalVariable; + private final CellMap CellMap; + private final int OriginalVariable; private double MinValue; private double MaxValue; private double Granularity; @@ -78,8 +78,8 @@ public abstract class BaseEvolutionarySolver extends BaseNLPSolver { private class CalcProblemEncoder extends ProblemEncoder { - private ArrayList m_variables; - private ArrayList m_constraints; + private final ArrayList m_variables; + private final ArrayList m_constraints; private CalcProblemEncoder(ArrayList variables, ArrayList constraints) throws Exception { @@ -152,19 +152,19 @@ public abstract class BaseEvolutionarySolver extends BaseNLPSolver { protected double m_toleratedMin; protected double m_toleratedMax; - private ArrayList m_variables = new ArrayList(); + private final ArrayList m_variables = new ArrayList(); //properties protected PropertyInfo m_swarmSize = new PropertyInfo("SwarmSize", 70, "Size of Swam"); protected PropertyInfo m_librarySize = new PropertyInfo("LibrarySize", 210, "Size of Library"); protected PropertyInfo m_learningCycles = new PropertyInfo("LearningCycles", 2000, "Learning Cycles"); - private PropertyInfo m_guessVariableRange = new PropertyInfo("GuessVariableRange", true, "Variable Bounds Guessing"); - private PropertyInfo m_variableRangeThreshold = new PropertyInfo("VariableRangeThreshold", 3.0, "Variable Bounds Threshold (when guessing)"); //to approximate the variable bounds - private PropertyInfo m_useACRComperator = new PropertyInfo("UseACRComparator", false, "Use ACR Comparator (instead of BCH)"); - private PropertyInfo m_useRandomStartingPoint = new PropertyInfo("UseRandomStartingPoint", false, "Use Random starting point"); + private final PropertyInfo m_guessVariableRange = new PropertyInfo("GuessVariableRange", true, "Variable Bounds Guessing"); + 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"); protected PropertyInfo m_required = new PropertyInfo("StagnationLimit", 70, "Stagnation Limit"); protected PropertyInfo m_tolerance = new PropertyInfo("Tolerance", 1e-6, "Stagnation Tolerance"); - private PropertyInfo m_enhancedSolverStatus = new PropertyInfo("EnhancedSolverStatus", true, "Show enhanced solver status"); + private final PropertyInfo m_enhancedSolverStatus = new PropertyInfo("EnhancedSolverStatus", true, "Show enhanced solver status"); protected IEvolutionarySolverStatusDialog m_solverStatusDialog; 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 f7fc741fc6bf..716a79b79438 100644 --- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java +++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/DEPSSolverImpl.java @@ -100,15 +100,15 @@ public final class DEPSSolverImpl extends BaseEvolutionarySolver return m_serviceNames; } - private PropertyInfo m_agentSwitchRate = new PropertyInfo("AgentSwitchRate", 0.5, "Agent Switch Rate (DE Probability)"); + private final PropertyInfo m_agentSwitchRate = new PropertyInfo("AgentSwitchRate", 0.5, "Agent Switch Rate (DE Probability)"); // --DE - private PropertyInfo m_factor = new PropertyInfo("DEFactor", 0.5, "DE: Scaling Factor (0-1.2)"); - private PropertyInfo m_CR = new PropertyInfo("DECR", 0.9, "DE: Crossover Probability (0-1)"); + private final PropertyInfo m_factor = new PropertyInfo("DEFactor", 0.5, "DE: Scaling Factor (0-1.2)"); + private final PropertyInfo m_CR = new PropertyInfo("DECR", 0.9, "DE: Crossover Probability (0-1)"); // --PS - private PropertyInfo m_c1 = new PropertyInfo("PSC1", 1.494, "PS: Cognitive Constant"); - private PropertyInfo m_c2 = new PropertyInfo("PSC2", 1.494, "PS: Social Constant"); - private PropertyInfo m_weight = new PropertyInfo("PSWeight", 0.729, "PS: Constriction Coefficient"); - private PropertyInfo m_CL = new PropertyInfo("PSCL", 0.0, "PS: Mutation Probability (0-0.005)"); + private final PropertyInfo m_c1 = new PropertyInfo("PSC1", 1.494, "PS: Cognitive Constant"); + private final PropertyInfo m_c2 = new PropertyInfo("PSC2", 1.494, "PS: Social Constant"); + private final PropertyInfo m_weight = new PropertyInfo("PSWeight", 0.729, "PS: Constriction Coefficient"); + private final PropertyInfo m_CL = new PropertyInfo("PSCL", 0.0, "PS: Mutation Probability (0-0.005)"); public void solve() { try { 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 cd3dc0c3c7cb..da8dbb22e997 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 @@ -45,18 +45,18 @@ public class EvolutionarySolverStatusUno extends BaseDialog XActionListener { private int userState; - private Label lblSolutionValue; - private Label lblIteration; - private ProgressBar pbIteration; - private Label lblIterationValue; - private Label lblStagnation; - private ProgressBar pbStagnation; - private Label lblStagnationValue; - private Label lblRuntimeValue; - private Button btnStop; - private Button btnOK; - private Button btnContinue; - private int defaultTextColor; + private final Label lblSolutionValue; + private final Label lblIteration; + private final ProgressBar pbIteration; + private final Label lblIterationValue; + private final Label lblStagnation; + private final ProgressBar pbStagnation; + private final Label lblStagnationValue; + private final Label lblRuntimeValue; + private final Button btnStop; + private final Button btnOK; + private final Button btnContinue; + private final int defaultTextColor; private int maxIterations; private int maxStagnation; -- cgit