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;
* 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);
}
/**
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment