Net creation #2
@@ -71,6 +71,28 @@ public class ServerNode {
|
|||||||
return Distribution.getPositiveSample(this.unavailable, rng);
|
return Distribution.getPositiveSample(this.unavailable, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
try {
|
||||||
|
var build = new StringBuilder()
|
||||||
|
.append(this.name)
|
||||||
|
.append("[servers:")
|
||||||
|
.append(this.maxServers)
|
||||||
|
.append(", queue:")
|
||||||
|
.append(this.maxQueue)
|
||||||
|
.append(", spawn:")
|
||||||
|
.append(this.spawnArrivals)
|
||||||
|
.append(", ")
|
||||||
|
.append(Distribution.toString(this.service));
|
||||||
|
if (this.unavailable != null)
|
||||||
|
build.append(", u:").append(Distribution.toString(this.unavailable));
|
||||||
|
return build.append(']').toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof ServerNode))
|
if (!(obj instanceof ServerNode))
|
||||||
|
|||||||
@@ -29,6 +29,27 @@ public class TestInteractions {
|
|||||||
assertEquals("UnavailableTime(0.1, Exponential(1.0))", Distribution.toString(unavailable));
|
assertEquals("UnavailableTime(0.1, Exponential(1.0))", Distribution.toString(unavailable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nodeToString() {
|
||||||
|
var exp = new Distribution.Exponential(1.0);
|
||||||
|
var normal = new Distribution.Normal(3.2, 0.6);
|
||||||
|
var unavailable = new Distribution.UnavailableTime(0.1, exp);
|
||||||
|
|
||||||
|
var node = new ServerNode.Builder("Source", exp).build();
|
||||||
|
assertEquals("Source[servers:1, queue:100, spawn:0, Exponential(1.0)]", node.toString());
|
||||||
|
|
||||||
|
node = new ServerNode.Builder("Queue", normal).build();
|
||||||
|
assertEquals("Queue[servers:1, queue:100, spawn:0, Normal(3.2, 0.6)]", node.toString());
|
||||||
|
|
||||||
|
node = new ServerNode.Builder("Queue", normal).queue(10).servers(5).spawn(100).build();
|
||||||
|
assertEquals("Queue[servers:5, queue:10, spawn:100, Normal(3.2, 0.6)]", node.toString());
|
||||||
|
|
||||||
|
node = new ServerNode.Builder("Queue", normal).queue(10).servers(5).spawn(100).unavailable(unavailable).build();
|
||||||
|
assertEquals(
|
||||||
|
"Queue[servers:5, queue:10, spawn:100, Normal(3.2, 0.6), u:UnavailableTime(0.1, Exponential(1.0))]",
|
||||||
|
node.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void netToString() {
|
public void netToString() {
|
||||||
var net = new Net();
|
var net = new Net();
|
||||||
|
|||||||
Reference in New Issue
Block a user