diff --git a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java
index 4375cee2b2fb5543b03e79daa7b52e5146c6c141..0f52bfc99780bbd99cffd32ef9278160cac4822a 100644
--- a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java
+++ b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java
@@ -67,11 +67,7 @@ public class ModelBasedSegmentDatabase
// There is already this Type
if (models.get(type).containsKey(segmentID)) {
// There is already this SegID
- if (models.get(type).get(segmentID).containsKey(dir)
- || (dir.equals(Direction.BOTH) && (models.get(type)
- .get(segmentID).containsKey(Direction.UPLOAD)
- || models.get(type).get(segmentID)
- .containsKey(Direction.DOWNLOAD)))) {
+ if (models.get(type).get(segmentID).containsKey(dir) || (models.get(type).get(segmentID).containsKey(Direction.BOTH) && (dir.equals(Direction.DOWNLOAD) || dir.equals(Direction.UPLOAD)))|| (dir.equals(Direction.BOTH) && (models.get(type).get(segmentID).containsKey(Direction.DOWNLOAD) || models.get(type).get(segmentID).containsKey(Direction.UPLOAD)))) {
// There is already a model defined
throw new ConfigurationException(
"Conflicting Models for SegmentID " + segmentID
@@ -102,6 +98,8 @@ public class ModelBasedSegmentDatabase
models.put(type, tmp2);
}
+
+ System.out.println(models.toString());
}
AbstractModel getModel(int segID, ParameterType type, Boolean isUpload) {
@@ -171,9 +169,10 @@ public class ModelBasedSegmentDatabase
if (!isAvailable) {
return 1;
}
-
- return getModel(new Integer(getSegmentID()), ParameterType.DROPRATE, isUpload)
- .getDouble(this.hostsInSegment.size());
+
+ // TODO: Eval other parameters first
+ return getModel(new Integer(getSegmentID()), ParameterType.DROPRATE,
+ isUpload).getDouble(this.hostsInSegment.size());
}
@Override
@@ -182,8 +181,9 @@ public class ModelBasedSegmentDatabase
return 9999 * Time.MILLISECOND;
}
- return getModel(new Integer(getSegmentID()), ParameterType.LATENCY, isUpload)
- .getLong(this.hostsInSegment.size());
+ // TODO: Eval other parameters first
+ return getModel(new Integer(getSegmentID()), ParameterType.LATENCY,
+ isUpload).getLong(this.hostsInSegment.size());
}
@Override
@@ -192,8 +192,10 @@ public class ModelBasedSegmentDatabase
return 0;
}
- return getModel(new Integer(getSegmentID()), ParameterType.BANDWIDTH, isUpload)
- .getLong(this.hostsInSegment.size());
+ // TODO: Eval other parameters first
+ return getModel(new Integer(getSegmentID()),
+ ParameterType.BANDWIDTH, isUpload)
+ .getLong(this.hostsInSegment.size());
}
@Override
diff --git a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/CutOffModel.java b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/CutOffModel.java
new file mode 100644
index 0000000000000000000000000000000000000000..1699d573691d9f4d6502163bec1eb771df1abc52
--- /dev/null
+++ b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/CutOffModel.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
+ *
+ * This file is part of PeerfactSim.KOM.
+ *
+ * PeerfactSim.KOM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * PeerfactSim.KOM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PeerfactSim.KOM. If not, see .
+ *
+ */
+
+package de.tud.kom.p2psim.impl.topology.views.fiveg.models;
+
+public class CutOffModel extends AbstractModel {
+
+ private long a = 1;
+
+ private long b = 0;
+
+ private long c = 1;
+
+ private long d = 0;
+
+ public void setA(long a) {
+ this.a = a;
+ }
+
+ public void setB(long b) {
+ this.b = b;
+ }
+
+ public void setC(long c) {
+ this.c = c;
+ }
+
+ public void setD(long d) {
+ this.d = d;
+ }
+
+ private long heaviside(long x) {
+ if(x < 0) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ @Override
+ public long getLong(int users) {
+ return (long) getDouble(users);
+ }
+
+ @Override
+ public double getDouble(int users) {
+ return this.a * heaviside(this.c * users + this.d) + this.b;
+ }
+
+ @Override
+ public String toString() {
+ return "CutOffModel: cut(u) = " + this.a + " * θ(" + this.c + " * u + " + this.d + ") + " + this.b;
+ }
+
+}
diff --git a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/ExponentialModel.java b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/ExponentialModel.java
new file mode 100644
index 0000000000000000000000000000000000000000..27b98616b9f6eb87ea99d001c3f44be1c793010a
--- /dev/null
+++ b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/ExponentialModel.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
+ *
+ * This file is part of PeerfactSim.KOM.
+ *
+ * PeerfactSim.KOM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * PeerfactSim.KOM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PeerfactSim.KOM. If not, see .
+ *
+ */
+
+package de.tud.kom.p2psim.impl.topology.views.fiveg.models;
+
+public class ExponentialModel extends AbstractModel {
+ // exp(u) = a * e ^(c * u + d) + b
+
+ private long a = 1;
+
+ private long b = 0;
+
+ private long c = 1;
+
+ private long d = 0;
+
+ public void setA(long a) {
+ this.a = a;
+ }
+
+ public void setB(long b) {
+ this.b = b;
+ }
+
+ public void setC(long c) {
+ this.c = c;
+ }
+
+ public void setD(long d) {
+ this.d = d;
+ }
+
+ @Override
+ public long getLong(int users) {
+ return (long) getDouble(users);
+ }
+
+ @Override
+ public double getDouble(int users) {
+ return this.a * Math.exp(this.c * users + this.d) + this.b;
+ }
+
+ @Override
+ public String toString() {
+ return "Exponential Model: exp(u) = " + this.a + " * e^(" + this.c + " * u + " + this.d + ") + " + this.b;
+ }
+
+}
diff --git a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LinearModel.java b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LinearModel.java
index 64b3b5ebb3c39de9797fef0be2f5cced42d69614..89aebab9cbf7a270fa33b191c1881e50c2d4005b 100644
--- a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LinearModel.java
+++ b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LinearModel.java
@@ -42,5 +42,9 @@ public class LinearModel extends AbstractModel {
public double getDouble(int users) {
return (double) this.a * users + this.b;
}
+
+ public String toString() {
+ return "Linear Model: f(u) = " + a + " * u + " + b;
+ }
}
diff --git a/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LogarithmicModel.java b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LogarithmicModel.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0dbb59aefcd6b1fb264b139288927f27d34177c
--- /dev/null
+++ b/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/LogarithmicModel.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
+ *
+ * This file is part of PeerfactSim.KOM.
+ *
+ * PeerfactSim.KOM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * PeerfactSim.KOM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PeerfactSim.KOM. If not, see .
+ *
+ */
+
+package de.tud.kom.p2psim.impl.topology.views.fiveg.models;
+
+public class LogarithmicModel extends AbstractModel {
+
+ // log(u) = a * ln(c * u + d) + b
+
+ private long a = 1;
+
+ private long b = 0;
+
+ private long c = 1;
+
+ private long d = 0;
+
+ public void setA(long a) {
+ this.a = a;
+ }
+
+ public void setB(long b) {
+ this.b = b;
+ }
+
+ public void setC(long c) {
+ this.c = c;
+ }
+
+ public void setD(long d) {
+ this.d = d;
+ }
+
+ @Override
+ public long getLong(int users) {
+ return (long) getDouble(users);
+ }
+
+ @Override
+ public double getDouble(int users) {
+ return this.a * Math.log(this.c * users + this.d) + this.b;
+ }
+
+ @Override
+ public String toString() {
+ return "Logarithmic Model: log(u) = " + this.a + " * ln(" + this.c + " * u + " + this.d + ") + " + this.b;
+ }
+
+}