CPD Results
The following document contains the results of PMD's CPD 7.17.0.
Duplications
| File | Line |
|---|---|
| nl/tudelft/simulation/jstats/distributions/empirical/DistributionFrequencies.java | 37 |
| nl/tudelft/simulation/jstats/distributions/empirical/DistributionFrequencies.java | 117 |
public static DiscreteEmpiricalDistribution createDiscreteDistribution(final Number[] values, final long[] frequencies)
{
Throw.whenNull(values, "values array cannot be null");
Throw.whenNull(frequencies, "frequencies array cannot be null");
Throw.when(values.length == 0, IllegalArgumentException.class, "values array cannot be empty");
Throw.when(frequencies.length == 0, IllegalArgumentException.class, "frequencies array cannot be empty");
Throw.when(frequencies.length != values.length, IllegalArgumentException.class,
"values array and frequencies array should have the same length");
double sum = 0.0;
for (int i = 0; i < frequencies.length; i++)
{
Throw.when(frequencies[i] <= 0, IllegalArgumentException.class, "frequency cannot be zero or negative");
sum += 1.0 * frequencies[i];
}
double[] cumulativeProbabilities;
double partialSum = 0;
cumulativeProbabilities = new double[frequencies.length];
for (int i = 0; i < frequencies.length; i++)
{
partialSum += 1.0 * frequencies[i];
cumulativeProbabilities[i] = partialSum / sum;
}
cumulativeProbabilities[cumulativeProbabilities.length - 1] = 1.0;
return new DiscreteEmpiricalDistribution(values.clone(), cumulativeProbabilities);
}
/**
* Create a discrete empirical distribution from two arrays, one with frequencies or weights, and one with corresponding
* values.
* @param values double[] the values
* @param frequencies the frequencies for the corresponding values
* @return the cumulative distribution object belonging to the given arrays
* @throws NullPointerException when values array is null or frequencies array is null, or when one of the values is null
* @throws IllegalArgumentException when frequencies array or values array are empty, or have unequal length, or when
* frequencies are zero or negative, or when values are not in ascending order
*/
public static DiscreteEmpiricalDistribution createDiscreteDistribution(final double[] values, final long[] frequencies) | |
| File | Line |
|---|---|
| nl/tudelft/simulation/jstats/ode/integrators/RungeKuttaCashCarp.java | 45 |
| nl/tudelft/simulation/jstats/ode/integrators/RungeKuttaFehlberg.java | 45 |
public RungeKuttaCashCarp(final double stepSize, final DifferentialEquationInterface equation)
{
super(stepSize, equation);
}
@Override
public double[] next(final double x, final double[] y)
{
double[][] k = new double[nk][];
for (int i = 0; i < nk; i++)
{
double[] ysum = y.clone();
for (int j = 0; j < i; j++)
{
if (b[i][j] != 0.0)
{
ysum = add(ysum, multiply(b[i][j], k[j]));
}
}
k[i] = multiply(this.stepSize, this.equation.dy(x + a[i] * this.stepSize, ysum));
}
double[] sum = y.clone();
super.error = new double[y.length];
for (int i = 0; i < nk; i++)
{
sum = add(sum, this.multiply(c[i], k[i])); | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/experiment/Experiment.java | 431 |
| nl/tudelft/simulation/dsol/experiment/Replication.java | 92 |
}
@Override
public String getId()
{
return getRunControl().getId();
}
@Override
public void setDescription(final String description)
{
getRunControl().setDescription(description);
}
@Override
public String getDescription()
{
return getRunControl().getDescription();
}
@Override
public T getStartTime()
{
return getRunControl().getStartTime();
}
@Override
public T getEndTime()
{
return getRunControl().getEndTime();
}
@Override
public T getWarmupTime()
{
return getRunControl().getWarmupTime();
}
@Override
public <M extends DsolModel<T, ? extends SimulatorInterface<T>>> Predicate<? super M> getStoppingCondition()
{
return getRunControl().getStoppingCondition();
}
@Override
public <M extends DsolModel<T, ? extends SimulatorInterface<T>>> void setStoppingCondition(
final Predicate<? super M> stoppingCondition)
{
getRunControl().setStoppingCondition(stoppingCondition);
} | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/statistics/SimCounter.java | 57 |
| nl/tudelft/simulation/dsol/statistics/SimTally.java | 55 |
public SimCounter(final String key, final String description, final DsolModel<T, ? extends SimulatorInterface<T>> model)
{
super(description);
Throw.whenNull(model, "model cannot be null");
Throw.whenNull(key, "key cannot be null");
Throw.when(key.length() == 0, IllegalArgumentException.class, "key cannot be empty");
this.key = key;
model.getOutputStatistics().add(this);
this.simulator = model.getSimulator();
try
{
// only if we are before the warmup time, subscribe to the warmul event
if (this.simulator.getSimulatorTime().compareTo(this.simulator.getReplication().getWarmupTime()) < 0)
{
this.simulator.addListener(this, Replication.WARMUP_EVENT, ReferenceType.STRONG);
}
ContextInterface context =
ContextUtil.lookupOrCreateSubContext(this.simulator.getReplication().getContext(), "statistics");
context.bindObject(key);
}
catch (NamingException exception)
{
CategoryLogger.always().warn(exception, "<init>");
}
}
/**
* constructs a new SimCounter.
* @param key unique key for identifying the statistic
* @param description the description
* @param model the model
* @param target the target on which to count
* @param eventType the EventType for which counting takes place
*/
public SimCounter(final String key, final String description, final DsolModel<T, ? extends SimulatorInterface<T>> model, | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/simulators/DevDessAnimator.java | 83 |
| nl/tudelft/simulation/dsol/simulators/DevDessSimulator.java | 73 |
synchronized (super.semaphore)
{
checkStoppingCondition();
int cmp = this.eventList.first().getAbsoluteExecutionTime().compareTo(this.runUntilTime);
if ((cmp == 0 && !this.runUntilIncluding) || cmp > 0)
{
this.simulatorTime = SimTime.copy(this.runUntilTime);
this.runState = RunState.STOPPING;
break;
}
SimEventInterface<T> event = this.eventList.removeFirst();
if (event.getAbsoluteExecutionTime().compareTo(super.simulatorTime) != 0)
{
super.fireUnverifiedTimedEvent(SimulatorInterface.TIME_CHANGED_EVENT, null,
event.getAbsoluteExecutionTime());
}
this.simulatorTime = event.getAbsoluteExecutionTime();
try
{
event.execute();
if (this.eventList.isEmpty())
{
this.simulatorTime = SimTime.copy(this.runUntilTime);
this.runState = RunState.STOPPING;
break;
}
}
catch (Exception exception)
{
handleSimulationException(exception);
}
} | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/eventlists/EventListPriorityQueue.java | 43 |
| nl/tudelft/simulation/dsol/eventlists/RedBlackTree.java | 58 |
}
@Override
public void add(final SimEventInterface<T> event)
{
this.eventList.add(event);
}
@Override
public boolean contains(final SimEventInterface<T> event)
{
return this.eventList.contains(event);
}
@Override
public void clear()
{
this.eventList.clear();
}
@Override
public boolean isEmpty()
{
return this.eventList.isEmpty();
}
@Override
public Iterator<SimEventInterface<T>> iterator()
{
return this.eventList.iterator();
}
@Override
public boolean remove(final SimEventInterface<T> event)
{
return this.eventList.remove(event);
}
@Override
public int size()
{
return this.eventList.size();
}
} | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/statistics/SimCounter.java | 57 |
| nl/tudelft/simulation/dsol/statistics/SimPersistent.java | 57 |
| nl/tudelft/simulation/dsol/statistics/SimTally.java | 55 |
public SimCounter(final String key, final String description, final DsolModel<T, ? extends SimulatorInterface<T>> model)
{
super(description);
Throw.whenNull(model, "model cannot be null");
Throw.whenNull(key, "key cannot be null");
Throw.when(key.length() == 0, IllegalArgumentException.class, "key cannot be empty");
this.key = key;
model.getOutputStatistics().add(this);
this.simulator = model.getSimulator();
try
{
// only if we are before the warmup time, subscribe to the warmul event
if (this.simulator.getSimulatorTime().compareTo(this.simulator.getReplication().getWarmupTime()) < 0)
{
this.simulator.addListener(this, Replication.WARMUP_EVENT, ReferenceType.STRONG); | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/simulators/DevDessAnimator.java | 86 |
| nl/tudelft/simulation/dsol/simulators/DevsAnimator.java | 68 |
int cmp = this.eventList.first().getAbsoluteExecutionTime().compareTo(this.runUntilTime);
if ((cmp == 0 && !this.runUntilIncluding) || cmp > 0)
{
this.simulatorTime = SimTime.copy(this.runUntilTime);
this.runState = RunState.STOPPING;
break;
}
SimEventInterface<T> event = this.eventList.removeFirst();
if (event.getAbsoluteExecutionTime().compareTo(super.simulatorTime) != 0)
{
super.fireUnverifiedTimedEvent(SimulatorInterface.TIME_CHANGED_EVENT, null,
event.getAbsoluteExecutionTime());
}
this.simulatorTime = event.getAbsoluteExecutionTime();
try
{
event.execute(); | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/simulators/DevDessSimulator.java | 76 |
| nl/tudelft/simulation/dsol/simulators/DevsAnimator.java | 68 |
int cmp = this.eventList.first().getAbsoluteExecutionTime().compareTo(this.runUntilTime);
if ((cmp == 0 && !this.runUntilIncluding) || cmp > 0)
{
this.simulatorTime = SimTime.copy(this.runUntilTime);
this.runState = RunState.STOPPING;
break;
}
SimEventInterface<T> event = this.eventList.removeFirst();
if (event.getAbsoluteExecutionTime().compareTo(super.simulatorTime) != 0)
{
super.fireUnverifiedTimedEvent(SimulatorInterface.TIME_CHANGED_EVENT, null,
event.getAbsoluteExecutionTime());
}
this.simulatorTime = event.getAbsoluteExecutionTime();
try
{
event.execute(); | |
| File | Line |
|---|---|
| nl/tudelft/simulation/jstats/ode/integrators/RungeKutta3.java | 23 |
| nl/tudelft/simulation/jstats/ode/integrators/RungeKutta4.java | 23 |
public RungeKutta3(final double stepSize, final DifferentialEquationInterface equation)
{
super(stepSize, equation);
}
@Override
public double[] next(final double x, final double[] y)
{
double[] k1 = this.equation.dy(x, y);
double[] k2 = this.equation.dy(x + 0.5 * this.stepSize, add(y, multiply(0.5 * this.stepSize, k1)));
double[] k3 = this.equation.dy(x + 0.5 * this.stepSize, add(y, multiply(0.5 * this.stepSize, k2)));
double[] sum = add(k1, multiply(4.0, k2), k3); | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/simulators/DevDessAnimator.java | 38 |
| nl/tudelft/simulation/dsol/simulators/DevsAnimator.java | 35 |
@Override
public long getAnimationDelay()
{
return this.animationDelay;
}
@Override
public void setAnimationDelay(final long animationDelay)
{
this.animationDelay = animationDelay;
this.fireEvent(ANIMATION_DELAY_CHANGED_EVENT, animationDelay);
}
@Override
public void updateAnimation()
{
this.fireTimedEvent(AnimatorInterface.UPDATE_ANIMATION_EVENT, null, this.simulatorTime);
}
@Override
public void run()
{
AnimationThread animationThread = new AnimationThread(this);
animationThread.start();
// set the run flag semaphore to signal to startImpl() that the run method has started
this.runflag = true;
while (!isStoppingOrStopped() && !this.eventList.isEmpty()
&& this.simulatorTime.compareTo(this.replication.getEndTime()) <= 0)
{ | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/model/inputparameters/InputParameterDoubleScalar.java | 73 |
| nl/tudelft/simulation/dsol/model/inputparameters/InputParameterFloatScalar.java | 71 |
public InputParameterDoubleScalar(final String key, final String shortName, final String description, final T defaultValue,
final T minimumValue, final T maximumValue, final boolean minIncluded, final boolean maxIncluded,
final String format, final double displayPriority) throws InputParameterException
{
this(key, shortName, description, defaultValue, minimumValue.si, maximumValue.si, minIncluded, maxIncluded, format,
displayPriority);
Throw.whenNull(format, "format cannot be null");
Throw.whenNull(defaultValue, "defaultValue cannot be null");
Throw.whenNull(minimumValue, "minimumValue cannot be null");
Throw.whenNull(maximumValue, "maximumValue cannot be null");
}
/**
* Construct a new InputParameterDoubleScalar.
* @param key unique (within the parent's input parameter map) name of the new InputParameterDoubleUnit
* @param shortName concise description of the input parameter
* @param description double description of the input parameter (may use HTML markup)
* @param defaultValue the default value of this input parameter
* @param minimumValueSI the lowest value allowed as input (in SI units)
* @param maximumValueSI the highest value allowed as input (in SI units)
* @param minIncluded is the minimum value included or excluded in the allowed interval?
* @param maxIncluded is the maximum value included or excluded in the allowed interval?
* @param format the format to use in displaying the double
* @param displayPriority sorting order when properties are displayed to the user
* @throws NullPointerException when key, shortName, defaultValue, description, format, or defaultValue is null
* @throws IllegalArgumentException when displayPriority is NaN
* @throws InputParameterException when unit for the default value cannot be found in the unit definition
*/
@SuppressWarnings("checkstyle:parameternumber")
public InputParameterDoubleScalar(final String key, final String shortName, final String description, final T defaultValue, | |
| File | Line |
|---|---|
| nl/tudelft/simulation/dsol/model/inputparameters/InputParameterDoubleScalar.java | 110 |
| nl/tudelft/simulation/dsol/model/inputparameters/InputParameterFloatScalar.java | 108 |
-Double.MAX_VALUE, Double.MAX_VALUE, false, false, format, 1.0));
add(new InputParameterUnit<U>("unit", "unit", "unit for the value", defaultValue.getDisplayUnit(), 2.0));
this.minimumValueSI = minimumValueSI;
this.maximumValueSI = maximumValueSI;
this.minIncluded = minIncluded;
this.maxIncluded = maxIncluded;
}
/**
* @return the unit sub-parameter
* @throws RuntimeException when parameter map has been corrupted and no unit parameter can be found
*/
@SuppressWarnings("unchecked")
public InputParameterUnit<U> getUnitParameter()
{
try
{
return (InputParameterUnit<U>) get("unit");
}
catch (InputParameterException exception)
{
throw new RuntimeException(
"Parameter map has been corrupted and no unit parameter can be found for field " + getShortName(),
exception);
}
}
/**
* @return the double sub-parameter
* @throws RuntimeException when parameter map has been corrupted and no value parameter can be found
*/
public InputParameterDouble getDoubleParameter() | |
