Commit 24f0d9c3 authored by Simon Eismann's avatar Simon Eismann

reworked interface

parent 667fdc05
......@@ -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, null, null);
.nextDouble(null, -1);
this.randServTimeGen[c] = new Deterministic(value);
} else {
// TODO implement copy of other distributions
......@@ -494,8 +494,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, this.colors, this.queueTokenPop);
double serviceTime = randServTimeGen[color].nextDouble(this, color);
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, null, null);
double servTime = queueingPlace.randServTimeGen[color].nextDouble(null, -1);
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, null, null);
double servTime = qPl.randServTimeGen[tk.color].nextDouble(null, -1);
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, null, null);
double servTime = expRandServTimeGen[0].nextDouble(null, -1);
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, null, null);
double servTime = qPl.randServTimeGen[color].nextDouble(null, -1);
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, null, null);
double servTime = qPl.randServTimeGen[tk.color].nextDouble(null, -1);
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, null, null);
.nextDouble(null, -1);
if (tokenData.requiredProcessingTime < 0) {
tokenData.requiredProcessingTime = 0;
}
......
package de.tud.cs.simqpn.kernel.loading.distributions;
import de.tud.cs.simqpn.kernel.entities.QPlace;
public interface AbstractDistribution {
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers);
public double nextDouble(QPlace qplace, int color);
}
package de.tud.cs.simqpn.kernel.loading.distributions;
import de.tud.cs.simqpn.kernel.entities.QPlace;
public class AbstractDistributionWrapper implements AbstractDistribution {
private cern.jet.random.AbstractDistribution innerDistribution;
......@@ -9,7 +11,7 @@ public class AbstractDistributionWrapper implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
public double nextDouble(QPlace qplace, int color) {
return innerDistribution.nextDouble();
}
......
......@@ -40,6 +40,8 @@
*/
package de.tud.cs.simqpn.kernel.loading.distributions;
import de.tud.cs.simqpn.kernel.entities.QPlace;
/**
* A deterministic distribution that always returns the double passed to the
* constructor.
......@@ -59,7 +61,7 @@ public class Deterministic implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
public double nextDouble(QPlace qplace, int color) {
return value;
}
......
......@@ -43,6 +43,8 @@ package de.tud.cs.simqpn.kernel.loading.distributions;
import java.util.Map;
import java.util.Map.Entry;
import de.tud.cs.simqpn.kernel.entities.QPlace;
public class DeterministicConcurrency implements AbstractDistribution {
private Map<Integer, Double> concurrencyLevels;
......@@ -63,7 +65,8 @@ public class DeterministicConcurrency implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
public double nextDouble(QPlace qplace, int color) {
int concurrency = qplace.getQueueTokenPop()[color];
if (concurrency < min)
return concurrencyLevels.get(min);
......
......@@ -43,6 +43,7 @@ package de.tud.cs.simqpn.kernel.loading.distributions;
import cern.jet.random.Exponential;
import de.tud.cs.simqpn.kernel.RandomNumberGenerator;
import de.tud.cs.simqpn.kernel.SimQPNException;
import de.tud.cs.simqpn.kernel.entities.QPlace;
public class MARS implements AbstractDistribution {
......@@ -62,12 +63,12 @@ public class MARS implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
public double nextDouble(QPlace qplace, int color) {
if (functions == null)
createFunctions(colors);
createFunctions(qplace.colors);
double result = constant;
for (int i = 0; i < functions.length; i++)
result += functions[i].calculate(tokenNumbers[i]);
result += functions[i].calculate(qplace.getQueueTokenPop()[i]);
try {
return new Exponential(1 / result, RandomNumberGenerator.nextRandNumGen()).nextDouble();
} catch (SimQPNException e) {
......
......@@ -41,6 +41,8 @@
*/
package de.tud.cs.simqpn.kernel.loading.distributions;
import de.tud.cs.simqpn.kernel.entities.QPlace;
public class Periodical implements AbstractDistribution {
private final double[] data;
......@@ -58,7 +60,7 @@ public class Periodical implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
public double nextDouble(QPlace qplace, int color) {
double result = data[currentPos];
currentPos = (currentPos + 1) % data.length;
return result;
......
......@@ -40,6 +40,8 @@
*/
package de.tud.cs.simqpn.kernel.loading.distributions;
import de.tud.cs.simqpn.kernel.entities.QPlace;
public class Replay implements AbstractDistribution {
private double[] replayValues;
......@@ -53,7 +55,7 @@ public class Replay implements AbstractDistribution {
}
@Override
public double nextDouble(int concurrency, String[] colors, int[] tokenNumbers) {
public double nextDouble(QPlace qplace, int color) {
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