Tests for sim

- added event and node tests
This commit is contained in:
2025-01-24 11:44:39 +01:00
parent 00a09be756
commit bbb069d4d1
4 changed files with 154 additions and 6 deletions

View File

@@ -54,13 +54,24 @@ public class ServerNode {
/**
* Creates a generic node with the given name and distribution.
* The servers number must be 1 or higher; if lower will be put to 1.
* The spawn number must be 0 or higher; if lower will be put to 0.
* The distribution can't be null, otherwise an exception is thrown.
*
* @param name The name of the node.
* @param maxServers The maximum number of servers in the queue.
* @param distribution The distribution of the service times.
* @param spawnArrivals The number of arrivals to spawn.
* @param name The name of the node.
* @param maxServers The maximum number of servers in the queue.
* @param distribution The distribution of the service times.
* @param spawnArrivals The number of arrivals to spawn.
* @throws NullPointerException if the distribution is null
*/
public ServerNode(String name, int maxServers, Distribution distribution, int spawnArrivals) {
if (distribution == null)
throw new NullPointerException("Distribution can't be null");
if (maxServers <= 0)
maxServers = 1;
if (spawnArrivals < 0)
spawnArrivals = 0;
this.name = name;
this.maxServers = maxServers;
this.distribution = distribution;
@@ -91,6 +102,6 @@ public class ServerNode {
* @return True if the node should spawn an arrival, false otherwise.
*/
public boolean shouldSpawnArrival(double numArrivals) {
return this.spawnArrivals > numArrivals;
return this.spawnArrivals > Math.max(0, numArrivals);
}
}

View File

@@ -15,6 +15,10 @@ import net.berack.upo.valpre.sim.stats.Result;
public class SimulationMultiple {
private final Net net;
/**
* TODO
* @param net
*/
public SimulationMultiple(Net net) {
this.net = net;
}

View File

@@ -88,7 +88,7 @@ public class Statistics {
}
/**
*
* TODO
*
* @param save
* @param val1