Skip to content
Snippets Groups Projects
Commit 4b007895 authored by Britta Heymann's avatar Britta Heymann
Browse files

Use x^21 instead of x^3

Tests had to be adapted.

refs #598
parent 030da964
No related branches found
No related tags found
1 merge request!147Use x^21 instead of x^3
Pipeline #
...@@ -20,7 +20,9 @@ import java.util.stream.Collectors; ...@@ -20,7 +20,9 @@ import java.util.stream.Collectors;
* Created by melanie on 07.04.17. * Created by melanie on 07.04.17.
*/ */
public class LocalDatabase { 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 METERS_IN_KILOMETER = 1000;
private static final int SECONDS_IN_HOUR = 3600; private static final int SECONDS_IN_HOUR = 3600;
...@@ -115,7 +117,7 @@ public class LocalDatabase { ...@@ -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. * @return A threshold between 0 and 1 that is 0 for empty memory and 1 for full memory.
*/ */
private double computeDeletionThreshold() { private double computeDeletionThreshold() {
return Math.pow(getUsedMemoryPercentage(), CUBIC); return Math.pow(getUsedMemoryPercentage(), THRESHOLD_EXPONENT);
} }
/** /**
......
...@@ -36,8 +36,8 @@ public class DatabaseStatisticsTest { ...@@ -36,8 +36,8 @@ public class DatabaseStatisticsTest {
private static final double HALF_AN_HOUR_LATER =3600; private static final double HALF_AN_HOUR_LATER =3600;
/* Used locations for all DB operations. */ /* Used locations for all DB operations. */
private static final Coord CURR_LOCATION = new Coord(300, 400); private static final Coord CURR_LOCATION = new Coord(3000, 4000);
private static final Coord CLOSE_TO_CURR_LOCATION = new Coord(400, 400); private static final Coord CLOSE_TO_CURR_LOCATION = new Coord(4000, 4000);
private static final Coord ORIGIN = new Coord(0,0); private static final Coord ORIGIN = new Coord(0,0);
/* Sizes for data items */ /* Sizes for data items */
......
...@@ -27,10 +27,10 @@ import java.util.List; ...@@ -27,10 +27,10 @@ import java.util.List;
public class EpidemicRouterTest extends AbstractRouterTest { public class EpidemicRouterTest extends AbstractRouterTest {
private static int TTL = 300; 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. */ /* 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 int SMALL_SIZE_DIFFERENCE = 2;
private static final String EXPECTED_DATA_MESSAGE = "Data message should have been sent."; private static final String EXPECTED_DATA_MESSAGE = "Data message should have been sent.";
...@@ -330,7 +330,7 @@ public class EpidemicRouterTest extends AbstractRouterTest { ...@@ -330,7 +330,7 @@ public class EpidemicRouterTest extends AbstractRouterTest {
assertEquals("Expected other data item to be sent.", data, message.getData().get(0)); 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. // 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 newData = new DisasterData(
DisasterData.DataType.SKILL, DB_SIZE - SMALL_SIZE_DIFFERENCE, SimClock.getTime(), h1.getLocation()); DisasterData.DataType.SKILL, DB_SIZE - SMALL_SIZE_DIFFERENCE, SimClock.getTime(), h1.getLocation());
this.setUpAsDataCarrier(h1, newData); this.setUpAsDataCarrier(h1, newData);
......
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
* Created by Britta Heymann on 09.04.2017. * Created by Britta Heymann on 09.04.2017.
*/ */
public class LocalDatabaseTest { public class LocalDatabaseTest {
private static final int DB_SIZE = 100; private static final int DB_SIZE = 1000;
/* Used locations for all DB operations. */ /* Used locations for all DB operations. */
private static final Coord CURR_LOCATION = new Coord(300, 400); private static final Coord CURR_LOCATION = new Coord(300, 400);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment