From 4b007895972df04dfec1cab85c3ac9e5ddb7b18d Mon Sep 17 00:00:00 2001
From: Britta Heymann <britta_hey@web.de>
Date: Fri, 1 Sep 2017 12:14:19 +0200
Subject: [PATCH] Use x^21 instead of x^3

Tests had to be adapted.

refs #598
---
 src/core/LocalDatabase.java          | 6 ++++--
 src/test/DatabaseStatisticsTest.java | 4 ++--
 src/test/EpidemicRouterTest.java     | 6 +++---
 src/test/LocalDatabaseTest.java      | 2 +-
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/core/LocalDatabase.java b/src/core/LocalDatabase.java
index 608ee8e1..ace72171 100644
--- a/src/core/LocalDatabase.java
+++ b/src/core/LocalDatabase.java
@@ -20,7 +20,9 @@ import java.util.stream.Collectors;
  * Created by melanie on 07.04.17.
  */
 public class LocalDatabase {
-    private static final int CUBIC = 3;
+    /** Utility threshold for deletion is computed using (used db percentage)^{THRESHOLD_EXPONENT}.*/
+    private static final int THRESHOLD_EXPONENT = 21;
+
     private static final int METERS_IN_KILOMETER = 1000;
     private static final int SECONDS_IN_HOUR = 3600;
 
@@ -115,7 +117,7 @@ public class LocalDatabase {
      * @return A threshold between 0 and 1 that is 0 for empty memory and 1 for full memory.
      */
     private double computeDeletionThreshold() {
-        return Math.pow(getUsedMemoryPercentage(), CUBIC);
+        return Math.pow(getUsedMemoryPercentage(), THRESHOLD_EXPONENT);
     }
 
     /**
diff --git a/src/test/DatabaseStatisticsTest.java b/src/test/DatabaseStatisticsTest.java
index bab79ed3..14638236 100644
--- a/src/test/DatabaseStatisticsTest.java
+++ b/src/test/DatabaseStatisticsTest.java
@@ -36,8 +36,8 @@ public class DatabaseStatisticsTest {
     private static final double HALF_AN_HOUR_LATER =3600;
 
     /* Used locations for all DB operations. */
-    private static final Coord CURR_LOCATION = new Coord(300, 400);
-    private static final Coord CLOSE_TO_CURR_LOCATION = new Coord(400, 400);
+    private static final Coord CURR_LOCATION = new Coord(3000, 4000);
+    private static final Coord CLOSE_TO_CURR_LOCATION = new Coord(4000, 4000);
     private static final Coord ORIGIN = new Coord(0,0);
 
     /* Sizes for data items */
diff --git a/src/test/EpidemicRouterTest.java b/src/test/EpidemicRouterTest.java
index 09af79e8..6dd8e91f 100644
--- a/src/test/EpidemicRouterTest.java
+++ b/src/test/EpidemicRouterTest.java
@@ -27,10 +27,10 @@ import java.util.List;
 public class EpidemicRouterTest extends AbstractRouterTest {
 
 	private static int TTL = 300;
-	private static final int THREE_HOURS = 10_800;
+	private static final int NINE_HOURS = 9 * 60 * 60;
 
 	/* Data base item sizes needed for tests. */
-	private static final int DB_SIZE = 50;
+	private static final int DB_SIZE = 100;
 	private static final int SMALL_SIZE_DIFFERENCE = 2;
 
 	private static final String EXPECTED_DATA_MESSAGE = "Data message should have been sent.";
@@ -330,7 +330,7 @@ public class EpidemicRouterTest extends AbstractRouterTest {
         assertEquals("Expected other data item to be sent.", data, message.getData().get(0));
 
         // Add another, large one to replace the original object. It is more useful so it stays in the database.
-        this.clock.advance(THREE_HOURS);
+        this.clock.advance(NINE_HOURS);
         DisasterData newData = new DisasterData(
                 DisasterData.DataType.SKILL, DB_SIZE - SMALL_SIZE_DIFFERENCE, SimClock.getTime(), h1.getLocation());
         this.setUpAsDataCarrier(h1, newData);
diff --git a/src/test/LocalDatabaseTest.java b/src/test/LocalDatabaseTest.java
index b2706bf7..fca7d307 100644
--- a/src/test/LocalDatabaseTest.java
+++ b/src/test/LocalDatabaseTest.java
@@ -20,7 +20,7 @@ import java.util.List;
  * Created by Britta Heymann on 09.04.2017.
  */
 public class LocalDatabaseTest {
-    private static final int DB_SIZE = 100;
+    private static final int DB_SIZE = 1000;
 
     /* Used locations for all DB operations. */
     private static final Coord CURR_LOCATION = new Coord(300, 400);
-- 
GitLab