mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
bug3484 create suffix
This commit is contained in:
1 parent
891c3fb083
commit
974fbca97d
32 files changed
+387
-86
No files matched your search
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:02:54
|
||||
Pid: 10044
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [13612] 10:02:54 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:34:16
|
||||
Pid: 10048
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [9272] 10:34:16 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1712:09:35
|
||||
Pid: 10904
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [14964] 12:09:35 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1714:01:17
|
||||
Pid: 11056
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [15448] 14:01:17 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:33:30
|
||||
Pid: 12768
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [13724] 10:33:30 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1614:01:32
|
||||
Pid: 13104
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [12756] 14:01:32 ***ERROR (:0): Java assert: "The calculation of Pairing Lists took longer than expected!" in junit.framework.Assert.fail(Assert.java:47)
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:08:48
|
||||
Pid: 13456
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [16324] 10:08:48 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1712:08:39
|
||||
Pid: 14332
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [10680] 12:08:39 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:24:12
|
||||
Pid: 14840
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [9260] 10:24:12 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:30:16
|
||||
Pid: 14864
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [13820] 10:30:16 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:19:28
|
||||
Pid: 15652
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [7276] 10:19:28 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:54:32
|
||||
Pid: 16004
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [15844] 10:54:32 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:01:06
|
||||
Pid: 16356
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [5268] 10:01:06 ***ERROR (:0): Java assert: "The competitors are not divided up correctly!" in junit.framework.Assert.fail(Assert.java:47)
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:26:10
|
||||
Pid: 2312
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [15120] 10:26:10 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:20:22
|
||||
Pid: 3060
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [3048] 10:20:22 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:32:38
|
||||
Pid: 3224
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [14492] 10:32:38 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1714:05:17
|
||||
Pid: 4184
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [560] 14:05:17 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:58:15
|
||||
Pid: 4832
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [15476] 10:58:15 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:06:46
|
||||
Pid: 5184
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [13160] 10:06:46 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:29:38
|
||||
Pid: 5912
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [4144] 10:29:38 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1711:05:22
|
||||
Pid: 5920
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [15444] 11:05:22 ***ERROR (:0): OutOfMemoryError: Could not allocate 0 bytes
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1711:28:42
|
||||
Pid: 6440
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [13188] 11:28:42 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:28:57
|
||||
Pid: 7192
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [13852] 10:28:57 ***ERROR (:0): Java assert: "Quality of Pairinglist is worse than usual!" in junit.framework.Assert.fail(Assert.java:47)
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:25:38
|
||||
Pid: 7352
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [1744] 10:25:38 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1713:31:58
|
||||
Pid: 7576
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [8816] 13:31:58 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:41:36
|
||||
Pid: 7872
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [6120] 10:41:36 ***ERROR (:0): Java assert: "Quality of Pairinglist is worse than usual!" in junit.framework.Assert.fail(Assert.java:47)
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:57:29
|
||||
Pid: 8424
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [15920] 10:57:29 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:05:04
|
||||
Pid: 8432
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [14844] 10:05:04 ***Warning: DebuggingOnDemand was deactivated
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-11-1710:59:13
|
||||
Pid: 9524
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [14072] 10:59:13 ***Warning: DebuggingOnDemand was deactivated
|
||||
+6
@@ -3,6 +3,7 @@ package com.sap.see.pairinglist.test;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -77,15 +78,20 @@ public class PairingListTemplateFactoryTest {
|
||||
System.out.println(example1.getQuality());
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void qualityCheck(){
|
||||
PairingListTemplate template = factoryImpl.getOrCreatePairingListTemplate(new PairingFrameProviderTest(15, 3, 18));
|
||||
System.out.println(Arrays.deepToString(template.getPairingListTemplate()));
|
||||
System.out.println(template.getQuality());
|
||||
if(template.getQuality()>=0.7) {
|
||||
Assert.fail("Quality of Pairinglist is worse than usual!");
|
||||
}
|
||||
|
||||
PairingListTemplate template2 = factoryImpl.getOrCreatePairingListTemplate(new PairingFrameProviderTest(10, 3, 30));
|
||||
System.out.println(Arrays.deepToString(template2.getPairingListTemplate()));
|
||||
System.out.println(template2.getQuality());
|
||||
if(template2.getQuality()>=1.2) {
|
||||
Assert.fail("Quality of Pairinglist is worse than usual!");
|
||||
}
|
||||
|
||||
+19
-1
@@ -2,6 +2,8 @@ package com.sap.see.pairinglist.test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sse.pairinglist.impl.PairingListTemplateFactoryImpl;
|
||||
@@ -15,6 +17,7 @@ public class PairingListTemplateTest extends PairingListTemplateImpl {
|
||||
|
||||
public PairingListTemplateTest() {
|
||||
super(new PairingFrameProviderTest(15, 3, 18));
|
||||
System.out.println(Arrays.deepToString(this.getPairingListTemplate()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,10 +102,25 @@ public class PairingListTemplateTest extends PairingListTemplateImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAverageQualityForSingleCase() {
|
||||
final int count = 20;
|
||||
double[] results = new double[20];
|
||||
for (int i = 0; i < count; i++) {
|
||||
int[][] template = this.createPairingListTemplate(15, 3, 18);
|
||||
results[i] = calcStandardDev(incrementAssociations(template, new int[18][18]));
|
||||
}
|
||||
double sum = 0;
|
||||
for (double quality: results) {
|
||||
sum += quality;
|
||||
}
|
||||
System.out.println(sum / count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncrementAndDecrementAssociations() {
|
||||
int[][] associations = new int[18][18];
|
||||
int[][] flight = this.createFlight(15, 3, 18, associations, 5);
|
||||
int[][] flight = this.createFlight(3, 18, associations, 5);
|
||||
|
||||
associations = this.incrementAssociations(flight, associations);
|
||||
associations = this.decrementAssociations(flight, associations);
|
||||
|
||||
@@ -22,7 +22,6 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
.getDefaultBackgroundTaskThreadPoolExecutor();
|
||||
|
||||
private final int maxConstantFlights;
|
||||
private final int MAX_TASKS = 1024;
|
||||
private final int seedsCount;
|
||||
private final int iterations;
|
||||
|
||||
@@ -34,15 +33,28 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
public PairingListTemplateImpl(PairingFrameProvider pairingFrameProvider, int iterations) {
|
||||
this.iterations = iterations;
|
||||
|
||||
this.seedsCount = (int) ((Math.log(iterations))/(Math.log(pairingFrameProvider.getFlightsCount())));
|
||||
this.maxConstantFlights = (int) ((Math.log(MAX_TASKS))/(Math.log(seedsCount)));
|
||||
if (0.9 * pairingFrameProvider.getFlightsCount() > 10) {
|
||||
this.maxConstantFlights = 10;
|
||||
this.seedsCount = 2;
|
||||
} else if (pairingFrameProvider.getFlightsCount() > 4) {
|
||||
this.maxConstantFlights = (int) ((pairingFrameProvider.getFlightsCount()) * 0.5);
|
||||
this.seedsCount = (int) (Math.pow(512, (1.0 / maxConstantFlights)));
|
||||
} else {
|
||||
maxConstantFlights = 0;
|
||||
seedsCount = 0;
|
||||
}
|
||||
|
||||
if (this.checkValues(pairingFrameProvider.getFlightsCount(), pairingFrameProvider.getGroupsCount(),
|
||||
if (this.checkValues(pairingFrameProvider.getFlightsCount(), pairingFrameProvider.getGroupsCount(),
|
||||
|
||||
pairingFrameProvider.getCompetitorsCount())) {
|
||||
|
||||
this.pairingListTemplate = this.createPairingListTemplate(pairingFrameProvider.getFlightsCount(),
|
||||
pairingFrameProvider.getGroupsCount(), pairingFrameProvider.getCompetitorsCount());
|
||||
if (maxConstantFlights > 0) {
|
||||
this.pairingListTemplate = this.createPairingListTemplate(pairingFrameProvider.getFlightsCount(),
|
||||
pairingFrameProvider.getGroupsCount(), pairingFrameProvider.getCompetitorsCount());
|
||||
} else {
|
||||
pairingListTemplate = this.createPairingListTemplateWithoutPrefix(
|
||||
pairingFrameProvider.getFlightsCount(), pairingFrameProvider.getGroupsCount(),
|
||||
pairingFrameProvider.getCompetitorsCount());
|
||||
}
|
||||
this.standardDev = this.calcStandardDev(incrementAssociations(this.pairingListTemplate,
|
||||
new int[pairingFrameProvider.getCompetitorsCount()][pairingFrameProvider.getCompetitorsCount()]));
|
||||
} else {
|
||||
@@ -124,7 +136,7 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
int[][] bestPLT = new int[flightCount * groupCount][competitors / groupCount];
|
||||
double bestDev = Double.POSITIVE_INFINITY;
|
||||
|
||||
ArrayList<Future<int[][]>> futures = this.createConstantFlights(flightCount, groupCount, competitors,
|
||||
ArrayList<Future<int[][]>> futures = this.createPrefix(flightCount, groupCount, competitors,
|
||||
new int[competitors][competitors], new int[flightCount * groupCount][competitors / groupCount], seeds,
|
||||
new ArrayList<>(), 0);
|
||||
|
||||
@@ -170,7 +182,11 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
* @return int array of random competitors
|
||||
*/
|
||||
private int[] generateSeeds(int flights, int competitors) {
|
||||
int[] seeds=new int[seedsCount];
|
||||
return this.generateSeeds(flights, competitors, this.seedsCount);
|
||||
}
|
||||
|
||||
private int[] generateSeeds(int flights, int competitors, int count) {
|
||||
int[] seeds=new int[count];
|
||||
for(int x=0;x<seeds.length;x++){
|
||||
int random=this.getRandomIntegerBetween(0, competitors - 1);
|
||||
while(this.contains(seeds, random)) {
|
||||
@@ -182,7 +198,7 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
}
|
||||
|
||||
class SuffixCreationTask implements Callable<int[][]> {
|
||||
int flights, groups, competitors, seedLength;
|
||||
int flights, groups, competitors, seedLength,tasks;
|
||||
int[][] plt, associations;
|
||||
/**
|
||||
* This task is created every time a constant is generated. It generates a specific number of PairingListTemplates,which is based on the constant flights
|
||||
@@ -200,7 +216,25 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
this.seedLength = seedLength;
|
||||
this.plt = new int[flights * groups][competitors / groups];
|
||||
this.associations = new int[competitors][competitors];
|
||||
|
||||
this.tasks=(int)Math.pow(seedLength, maxConstantFlights);
|
||||
// we use here System.arraycopy, because else, we would work on the reference of constantPLT. Besides we
|
||||
// want to avoid changing the reference.
|
||||
for (int i = 0; i < constantPLT.length; i++) {
|
||||
System.arraycopy(constantPLT[i], 0, this.plt[i], 0, competitors / groups);
|
||||
}
|
||||
for (int i = 0; i < associations.length; i++) {
|
||||
System.arraycopy(associations[i], 0, this.associations[i], 0, competitors);
|
||||
}
|
||||
}
|
||||
|
||||
SuffixCreationTask(int flights, int groups, int competitors, int[][] constantPLT, int[][] associations, int seedLength,int tasks) {
|
||||
this.flights = flights;
|
||||
this.groups = groups;
|
||||
this.competitors = competitors;
|
||||
this.seedLength = seedLength;
|
||||
this.plt = new int[flights * groups][competitors / groups];
|
||||
this.associations = new int[competitors][competitors];
|
||||
this.tasks=(tasks);
|
||||
// we use here System.arraycopy, because else, we would work on the reference of constantPLT. Besides we
|
||||
// want to avoid changing the reference.
|
||||
for (int i = 0; i < constantPLT.length; i++) {
|
||||
@@ -213,11 +247,38 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
|
||||
@Override
|
||||
public int[][] call() {
|
||||
return createSuffix(flights, groups, competitors, (int) (iterations / Math.pow(seedLength, maxConstantFlights)),
|
||||
plt, associations);
|
||||
return createSuffix(flights, groups, competitors, plt, associations,
|
||||
generateSeeds(flights, competitors,
|
||||
((int) Math.pow((iterations /tasks ),
|
||||
1.0 / (flights - maxConstantFlights)))), maxConstantFlights);
|
||||
}
|
||||
}
|
||||
|
||||
private int[][] createPairingListTemplateWithoutPrefix(int flightsCount, int groupsCount,int competitorsCount){
|
||||
double bestDev=Double.POSITIVE_INFINITY;
|
||||
int[][] bestPLT=new int[flightsCount*groupsCount][competitorsCount/groupsCount];
|
||||
ArrayList<Future<int[][]>> futures=new ArrayList<>();
|
||||
for(int i=0;i<1024;i++){
|
||||
futures.add(executorService.submit(new SuffixCreationTask(flightsCount, groupsCount, competitorsCount,
|
||||
new int[flightsCount * groupsCount][competitorsCount / groupsCount],
|
||||
new int[competitorsCount][competitorsCount],flightsCount,1024)));
|
||||
}
|
||||
for (Future<int[][]> f : futures) {
|
||||
try {
|
||||
int[][] currentPLT = f.get();
|
||||
double currentStandardDev = calcStandardDev(
|
||||
incrementAssociations(currentPLT, new int[competitorsCount][competitorsCount]));
|
||||
|
||||
if (currentStandardDev < bestDev) {
|
||||
bestPLT = currentPLT;
|
||||
bestDev = currentStandardDev;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return bestPLT;
|
||||
}
|
||||
/**
|
||||
* Creates constant flights.
|
||||
*
|
||||
@@ -231,43 +292,36 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
* @param seeds
|
||||
* @return <code>ArrayList</code> of <code>Futures</code> in which the result of a single task is saved
|
||||
*/
|
||||
private ArrayList<Future<int[][]>> createConstantFlights(int flights, int groups, int competitors, int[][] associations,
|
||||
private ArrayList<Future<int[][]>> createPrefix(int flights, int groups, int competitors, int[][] associations,
|
||||
int[][]currentPLT, int[] seeds, ArrayList<Future<int[][]>> futures, int level) {
|
||||
|
||||
if (level < this.maxConstantFlights) {
|
||||
if (currentPLT[level * groups][0] == 0) {
|
||||
// calculate Flights for current recurrence level
|
||||
for (int seedIndex = 0; seedIndex < seeds.length; seedIndex++) {
|
||||
int[][] temp = this.createFlight(flights, groups, competitors, associations, seeds[seedIndex]);
|
||||
// TODO: change arraycopy + refactor fleet
|
||||
int[][] temp = this.createFlight(groups, competitors, associations, seeds[seedIndex]);
|
||||
for (int m = 0; m < groups; m++) {
|
||||
System.arraycopy(temp[m], 0, currentPLT[level * groups + m], 0, competitors / groups);
|
||||
}
|
||||
level++;
|
||||
associations = this.incrementAssociations(temp, associations);
|
||||
this.createConstantFlights(flights, groups, competitors, associations, currentPLT, seeds,
|
||||
this.createPrefix(flights, groups, competitors, associations, currentPLT, this.generateSeeds(flights, competitors),
|
||||
futures, level);
|
||||
level--;
|
||||
associations = this.decrementAssociations(temp, associations);
|
||||
}
|
||||
int[][] temp = new int[groups][competitors / groups];
|
||||
|
||||
// reset last recurrence step
|
||||
for (int i = level * groups; i < level * groups + groups; i++) {
|
||||
System.arraycopy(currentPLT[i], 0, temp[i - level * groups], 0, competitors / groups);
|
||||
Arrays.fill(currentPLT[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Task start
|
||||
Future<int[][]> future = executorService.submit((new SuffixCreationTask(flights, groups, competitors, currentPLT, associations, seeds.length)));
|
||||
futures.add(future);
|
||||
|
||||
int[][] temp = new int[groups][competitors / groups];
|
||||
|
||||
// reset last recurrence step
|
||||
for (int i = maxConstantFlights * groups - 1; i >= maxConstantFlights * groups - groups; i--) {
|
||||
System.arraycopy(currentPLT[i], 0, temp[i - maxConstantFlights * groups + groups], 0, competitors / groups);
|
||||
Arrays.fill(currentPLT[i], 0);
|
||||
}
|
||||
}
|
||||
@@ -286,7 +340,7 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
*
|
||||
* @return generated flight as <code>int[groups][competitors / groups]</code> array
|
||||
*/
|
||||
protected int[][] createFlight(int flightCount, int groupCount, int competitorCount, int[][] currentAssociations, int seed) {
|
||||
protected int[][] createFlight(int groupCount, int competitorCount, int[][] currentAssociations, int seed) {
|
||||
int[][] flightColumn = new int[groupCount][competitorCount / groupCount];
|
||||
|
||||
// filling the array with -1, because our competitor number starts at 0. So if we later ask, whether the
|
||||
@@ -300,7 +354,7 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
flightColumn[0][0] = seed;
|
||||
for (int assignmentIndex = 1; assignmentIndex < (competitorCount / groupCount); assignmentIndex++) {
|
||||
int associationSum = Integer.MAX_VALUE;
|
||||
associationHigh[0] = flightCount + 1;
|
||||
associationHigh[0] = Integer.MAX_VALUE;
|
||||
associationRow = copyInto3rdDimension(competitorCount, currentAssociations, associationRow, flightColumn,
|
||||
assignmentIndex, 0);
|
||||
|
||||
@@ -324,14 +378,14 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
|
||||
for (int assignmentIndex = 1; assignmentIndex < (competitorCount / groupCount); assignmentIndex++) {
|
||||
int associationSum = Integer.MAX_VALUE;
|
||||
associationHigh[groupIndex] = flightCount + 1;
|
||||
associationHigh[groupIndex] = Integer.MAX_VALUE;
|
||||
associationRow = copyInto3rdDimension(competitorCount, currentAssociations, associationRow, flightColumn,
|
||||
assignmentIndex, groupIndex);
|
||||
|
||||
for (int competitorIndex = 0; competitorIndex < competitorCount; competitorIndex++) {
|
||||
if ((sumOf3rdDimension(associationRow, groupIndex, competitorIndex) <= associationSum)
|
||||
&& !contains(flightColumn, competitorIndex) && findMaxValue(associationRow, groupIndex,
|
||||
competitorIndex) <= associationHigh[groupIndex]) {
|
||||
&& !contains(flightColumn, competitorIndex)
|
||||
&& findMaxValue(associationRow, groupIndex, competitorIndex) <= associationHigh[groupIndex]) {
|
||||
flightColumn[groupIndex][assignmentIndex] = competitorIndex;
|
||||
associationSum = sumOf3rdDimension(associationRow, groupIndex, competitorIndex);
|
||||
associationHigh[groupIndex] = findMaxValue(associationRow, groupIndex, competitorIndex);
|
||||
@@ -359,62 +413,42 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
* @param groupCount count of groups in flight
|
||||
* @param competitorCount count of competitors
|
||||
* @param iterationCount repetitions of generating pairing lists
|
||||
* @param constantPLT constant generated flights
|
||||
* @param currentPLT constant generated flights
|
||||
* @param associations current matrix that describes how often a competitor competed
|
||||
* against another competitor.
|
||||
* @return best complete pairing list out of given iterations
|
||||
*/
|
||||
protected int[][] createSuffix(int flightCount, int groupCount, int competitorCount, int iterationCount,
|
||||
int[][] constantPLT, int[][] associations) {
|
||||
int[][] seeds = new int[iterationCount][flightCount - this.maxConstantFlights];
|
||||
int[][] bestPLT = new int[groupCount * flightCount][competitorCount / groupCount];
|
||||
for (int m = 0; m < this.maxConstantFlights * groupCount; m++) {
|
||||
System.arraycopy(constantPLT[m], 0, bestPLT[m], 0, constantPLT[0].length);
|
||||
}
|
||||
int[][] currentAssociations = new int[competitorCount][competitorCount];
|
||||
double bestDev = Double.POSITIVE_INFINITY;
|
||||
for (int[] row : seeds) {
|
||||
do {
|
||||
for (int i = 0; i < seeds[0].length; i++) {
|
||||
row[i] = this.getRandomIntegerBetween(0, competitorCount - 1);
|
||||
}
|
||||
} while (!this.containsRow(seeds, row));
|
||||
}
|
||||
// TODO change method to incremental calculation
|
||||
for (int[] row : seeds) {
|
||||
for (int m = 0; m < associations.length; m++) {
|
||||
System.arraycopy(associations[m], 0, currentAssociations[m], 0, associations[0].length);
|
||||
}
|
||||
int[][] currentPLT = new int[groupCount * flightCount][competitorCount / groupCount];
|
||||
|
||||
for (int i = this.maxConstantFlights; i < this.maxConstantFlights + seeds[0].length; i++) {
|
||||
int[][] flightColumn = this.createFlight(flightCount, groupCount, competitorCount, currentAssociations,
|
||||
row[i - this.maxConstantFlights]);
|
||||
currentAssociations = this.incrementAssociations(flightColumn, currentAssociations);
|
||||
protected int[][] createSuffix(int flightCount, int groupCount, int competitorCount,
|
||||
int[][] currentPLT, int[][] associations, int[] seeds, int level) {
|
||||
|
||||
if (level < flightCount) {
|
||||
double bestDev = Double.POSITIVE_INFINITY;
|
||||
|
||||
for (int seed : seeds) {
|
||||
int[][] flight = this.createFlight(groupCount, competitorCount, associations, seed);
|
||||
for (int m = 0; m < groupCount; m++) {
|
||||
System.arraycopy(flightColumn[m], 0, currentPLT[(i * groupCount) + m], 0, competitorCount / groupCount);
|
||||
System.arraycopy(flight[m], 0, currentPLT[level * groupCount + m], 0, competitorCount / groupCount);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < currentAssociations.length; j++) {
|
||||
currentAssociations[j][j] = -1;
|
||||
}
|
||||
if (this.calcStandardDev(currentAssociations) < bestDev) {
|
||||
for (int z = this.maxConstantFlights * groupCount; z < flightCount * groupCount; z++) {
|
||||
bestPLT[z] = currentPLT[z];
|
||||
|
||||
level++;
|
||||
associations = this.incrementAssociations(flight, associations);
|
||||
|
||||
int[][] suffix = this.createSuffix(flightCount, groupCount, competitorCount, currentPLT, associations,
|
||||
this.generateSeeds(flightCount, competitorCount), level);
|
||||
double currentDev = this.calcStandardDev(this.incrementAssociations(suffix,
|
||||
new int[competitorCount][competitorCount]));
|
||||
|
||||
if (currentDev < bestDev) {
|
||||
currentPLT = suffix;
|
||||
bestDev = currentDev;
|
||||
}
|
||||
bestDev = this.calcStandardDev(currentAssociations);
|
||||
|
||||
level--;
|
||||
associations = this.decrementAssociations(flight, associations);
|
||||
}
|
||||
}
|
||||
return bestPLT;
|
||||
}
|
||||
|
||||
private boolean containsRow(int[][] seeds, int[] row) {
|
||||
for(int[] line : seeds){
|
||||
if(Arrays.toString(row).equals(Arrays.toString(line))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return currentPLT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user