Commit 0c750924 authored by Simon Eismann's avatar Simon Eismann

extended interface

parent aa9b22c3
......@@ -197,7 +197,7 @@ public class QPlace extends Place {
} else if (((QPlace) original).randServTimeGen[c].getClass()
.equals(Deterministic.class)) {
double value = ((QPlace) original).randServTimeGen[c]
.nextDouble(-1);
.nextDouble(-1, null, null);
this.randServTimeGen[c] = new Deterministic(value);
} else {
// TODO implement copy of other distributions
......@@ -495,7 +495,7 @@ public class QPlace extends Place {
private void calculateServiceTimeIfFutureListIsEmpty(int color) {
if (futureList.get(color).isEmpty()) {
int concurrency = queueTokenPop[color];
double serviceTime = randServTimeGen[color].nextDouble(concurrency);
double serviceTime = randServTimeGen[color].nextDouble(concurrency, this.colors, this.queueTokenPop);
if (serviceTime < 0) {
serviceTime = 0;
}
......
......@@ -89,7 +89,7 @@ public class PRIOQueue extends Queue {
int n = 0;
while (n < count && numBusyServers < numServers) {
// Schedule service completion event
double servTime = queueingPlace.randServTimeGen[color].nextDouble(-1);
double servTime = queueingPlace.randServTimeGen[color].nextDouble(-1, null, null);
if (servTime < 0)
servTime = 0;
Token tk = (tokensToBeAdded != null) ? tokensToBeAdded[n]
......@@ -134,7 +134,7 @@ public class PRIOQueue extends Queue {
if (!priorityQueue.isEmpty()) {
Token tk = priorityQueue.remove();
QPlace qPl = (QPlace) tk.place;
double servTime = qPl.randServTimeGen[tk.color].nextDouble(-1);
double servTime = qPl.randServTimeGen[tk.color].nextDouble(-1, null, null);
if (servTime < 0) {
servTime = 0;
executor.scheduleEvent(servTime, this, tk);
......
......@@ -257,7 +257,7 @@ public class PSQueue extends Queue {
((Exponential) expRandServTimeGen[0]).setState(totServRate);
randColorGen.setState2(pdf);
double servTime = expRandServTimeGen[0].nextDouble(-1);
double servTime = expRandServTimeGen[0].nextDouble(-1, null, null);
if (servTime < 0)
servTime = 0;
int color = randColorGen.nextInt();
......
......@@ -113,7 +113,7 @@ public class RANDOMQueue extends Queue {
int n = 0;
while (n < count && numBusyServers < numServers) {
// Schedule service completion event
double servTime = qPl.randServTimeGen[color].nextDouble(-1);
double servTime = qPl.randServTimeGen[color].nextDouble(-1, null, null);
if (servTime < 0)
servTime = 0;
Token tk = (tokensToBeAdded != null) ? tokensToBeAdded[n]
......@@ -147,7 +147,7 @@ public class RANDOMQueue extends Queue {
int index = randomGenerator.nextInt(waitingLine.size());
Token tk = (Token) waitingLine.remove(index);
QPlace qPl = (QPlace) tk.place;
double servTime = qPl.randServTimeGen[tk.color].nextDouble(-1);
double servTime = qPl.randServTimeGen[tk.color].nextDouble(-1, null, null);
if (servTime < 0)
servTime = 0;
executor.scheduleEvent(servTime, this, tk);
......
......@@ -192,7 +192,7 @@ public class ThreadSchedulingQueue extends Queue {
tokenData.alreadyScheduled = true;
tokenData.requiredProcessingTime = queingPlace.randServTimeGen[color]
.nextDouble(-1);
.nextDouble(-1, null, null);
if (tokenData.requiredProcessingTime < 0) {
tokenData.requiredProcessingTime = 0;
}
......
package de.tud.cs.simqpn.kernel.loading.distributions;
public interface AbstractDistribution {
public double nextDouble(int concurrency);
}
package de.tud.cs.simqpn.kernel.loading.distributions;
public interface AbstractDistribution {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers);
}
package de.tud.cs.simqpn.kernel.loading.distributions;
public class AbstractDistributionWrapper implements AbstractDistribution {
private cern.jet.random.AbstractDistribution innerDistribution;
public AbstractDistributionWrapper(cern.jet.random.AbstractDistribution innerDistribution) {
this.innerDistribution = innerDistribution;
}
@Override
public double nextDouble(int concurrency) {
return innerDistribution.nextDouble();
}
}
package de.tud.cs.simqpn.kernel.loading.distributions;
public class AbstractDistributionWrapper implements AbstractDistribution {
private cern.jet.random.AbstractDistribution innerDistribution;
public AbstractDistributionWrapper(cern.jet.random.AbstractDistribution innerDistribution) {
this.innerDistribution = innerDistribution;
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
return innerDistribution.nextDouble();
}
}
......@@ -59,7 +59,7 @@ public class Deterministic implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency) {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
return value;
}
......
......@@ -63,7 +63,7 @@ public class DeterministicConcurrency implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency) {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
if (concurrency < min)
return concurrencyLevels.get(min);
......
......@@ -48,7 +48,7 @@ public class MARS implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency) {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
return 0.0;
}
......
......@@ -58,7 +58,7 @@ public class Periodical implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency) {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
double result = data[currentPos];
currentPos = (currentPos + 1) % data.length;
return result;
......
......@@ -53,7 +53,7 @@ public class Replay implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency) {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
if (nextValue == replayValues.length)
throw new IllegalStateException("There are only " + replayValues.length
+ " values in the replayfile for the colorRef " + colorRefId
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment