mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 06:49:56 +00:00
bug 4469 added boat changes and boat assignment quality as parameters to
pairinglistCreationDialog, added boat changes and boat assignment quality to pltemplateImpl, listbox is now working
This commit is contained in:
1 parent
d2fe91fac9
commit
41f1ce6d87
7 files changed
+103
-13
No files matched your search
+22
-6
@@ -11,36 +11,44 @@ public class PairingListTemplateDTO implements Serializable {
|
||||
private int competitorCount = 0;
|
||||
private int flightMultiplier = 0;
|
||||
private int tolerance = 0;
|
||||
private int boatchanges;
|
||||
private int[][] pairingListTemplate;
|
||||
private double quality;
|
||||
|
||||
private double boatassignmentqualitiy;
|
||||
|
||||
private Iterable<String> selectedFlightNames;
|
||||
|
||||
public PairingListTemplateDTO() { }
|
||||
|
||||
public PairingListTemplateDTO(int competitorCount, int flightMultiplier, int tolerance) {
|
||||
this(0, 0, competitorCount, flightMultiplier, tolerance, null, 0.0, /* selected flight names */ null);
|
||||
this(0, 0, competitorCount, flightMultiplier, tolerance,0 , null, 0.0, 0.0, /* selected flight names */ null);
|
||||
}
|
||||
|
||||
public PairingListTemplateDTO(int competitorCount, int flightMultiplier, int[][] pairingListTemplate, double quality) {
|
||||
this(0, 0, competitorCount, flightMultiplier, 0, pairingListTemplate, quality, /* selected flight names */ null);
|
||||
this(0, 0, competitorCount, flightMultiplier, 0, 0, pairingListTemplate, quality, 0.0, /* selected flight names */ null);
|
||||
}
|
||||
|
||||
public PairingListTemplateDTO(int competitorCount, int[][] pairingListTemplate, double quality) {
|
||||
this(0, 0, competitorCount, 0, 0, pairingListTemplate, quality, /* selected flight names */ null);
|
||||
this(0, 0, competitorCount, 0, 0, 0, pairingListTemplate, quality, 0.0, /* selected flight names */ null);
|
||||
}
|
||||
|
||||
public PairingListTemplateDTO(int flightCount, int groupCount, int competitorCount, int flightMultiplier, int tolerance, int[][] pairingListTemplate, double quality) {
|
||||
this(flightCount, groupCount, competitorCount, flightMultiplier, tolerance, pairingListTemplate, quality, /* selected flight names */ null);
|
||||
this(flightCount, groupCount, competitorCount, flightMultiplier, tolerance, 0, pairingListTemplate, quality, 0.0, /* selected flight names */ null);
|
||||
}
|
||||
|
||||
public PairingListTemplateDTO(int flightCount, int groupCount, int competitorCount, int flightMultiplier, int tolerance,int boatchanges, int[][] pairingListTemplate, double quality, double boatassignmentqualitiy) {
|
||||
this(flightCount, groupCount, competitorCount, flightMultiplier, tolerance, boatchanges, pairingListTemplate, quality, boatassignmentqualitiy, /* selected flight names */ null);
|
||||
}
|
||||
|
||||
public PairingListTemplateDTO(int flightCount, int groupCount, int competitorCount, int flightMultiplier, int tolerance,
|
||||
int[][] pairingListTemplate, double quality, Iterable<String> selectedFlightNames) {
|
||||
int boatchanges, int[][] pairingListTemplate, double quality, double boatassigmentqualitiy, Iterable<String> selectedFlightNames) {
|
||||
this.flightCount = flightCount;
|
||||
this.groupCount = groupCount;
|
||||
this.competitorCount = competitorCount;
|
||||
this.flightMultiplier = flightMultiplier;
|
||||
this.tolerance = tolerance;
|
||||
this.boatchanges = boatchanges;
|
||||
this.boatassignmentqualitiy = boatassigmentqualitiy;
|
||||
this.quality = quality;
|
||||
this.pairingListTemplate = pairingListTemplate;
|
||||
this.selectedFlightNames = selectedFlightNames;
|
||||
@@ -74,6 +82,14 @@ public class PairingListTemplateDTO implements Serializable {
|
||||
return this.quality;
|
||||
}
|
||||
|
||||
public double getBoatAssignmentQuality(){
|
||||
return this.boatassignmentqualitiy;
|
||||
}
|
||||
|
||||
public int getBoatChanges(){
|
||||
return this.boatchanges;
|
||||
}
|
||||
|
||||
public int getFlightCount() {
|
||||
return this.flightCount;
|
||||
}
|
||||
|
||||
+8
-3
@@ -87,7 +87,7 @@ public class PairingListCreationDialog extends DataEntryDialog<PairingListTempla
|
||||
|
||||
CaptionPanel dataPanel = new CaptionPanel();
|
||||
dataPanel.setCaptionText(stringMessages.parameters());
|
||||
Grid formGrid = new Grid(6, 2);
|
||||
Grid formGrid = new Grid(8, 2);
|
||||
dataPanel.add(formGrid);
|
||||
Label flights = new Label(String.valueOf(this.template.getFlightCount()));
|
||||
flights.ensureDebugId("FlightCountLabel");
|
||||
@@ -116,10 +116,15 @@ public class PairingListCreationDialog extends DataEntryDialog<PairingListTempla
|
||||
});
|
||||
formGrid.setWidget(4, 0, qualityPanel);
|
||||
formGrid.setWidget(4, 1, new Label(String.valueOf(Math.floor(this.template.getQuality() * 1000) / 1000)));
|
||||
//TODO Stringmessages
|
||||
formGrid.setWidget(5, 0, new Label("Boat Assignment Quality"));
|
||||
formGrid.setWidget(5, 1, new Label(String.valueOf(Math.floor(this.template.getBoatAssignmentQuality()*1000) / 1000)));
|
||||
formGrid.setWidget(6, 0, new Label("Boat Changes"));
|
||||
formGrid.setWidget(6, 1, new Label(String.valueOf(template.getBoatChanges())));
|
||||
if (this.template.getFlightMultiplier() > 1) {
|
||||
Label flightMultiplierLabel = new Label(String.valueOf(this.template.getFlightMultiplier()));
|
||||
formGrid.setWidget(5, 0, new Label(stringMessages.amountOfFlightRepeats()));
|
||||
formGrid.setWidget(5, 1, flightMultiplierLabel);
|
||||
formGrid.setWidget(7, 0, new Label(stringMessages.amountOfFlightRepeats()));
|
||||
formGrid.setWidget(7, 1, flightMultiplierLabel);
|
||||
flightMultiplierLabel.ensureDebugId("FlightMultiplierCountLabel");
|
||||
}
|
||||
formGrid.setCellSpacing(10);
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ public class PairingListCreationSetupDialog extends AbstractPairingListCreationS
|
||||
dto.setSelectedFlightNames(selectedFlightNames);
|
||||
dto.setFlightCount(selectedFlightNames.size());
|
||||
// TODO get tolerance from ui component
|
||||
dto.setTolerance(3);
|
||||
dto.setTolerance(Integer.parseInt(boatChangeFactorListBox.getSelectedValue()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7263,7 +7263,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
PairingListTemplate template = getService().createPairingListTemplate(flightCount, groupCount, competitorCount,
|
||||
flightMultiplier, tolerance);
|
||||
return new PairingListTemplateDTO(flightCount, groupCount, competitorCount, flightMultiplier, tolerance,
|
||||
template.getPairingListTemplate(), template.getQuality());
|
||||
template.getBoatChanges(),template.getPairingListTemplate(), template.getQuality(),template.getAssignmentQuality());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -132,4 +132,20 @@ public class PairingListTemplateTest extends PairingListTemplateImpl {
|
||||
{ 3, 4, 5, 6, 7, 9 }, { 17, 12, 14, 16, 3, 4 } };
|
||||
assertArrayEquals(allSeeds, expectedResult);
|
||||
}
|
||||
@Test
|
||||
public void testGetBoatChanges(){
|
||||
int[][] givenPairingList = { { 0, 15, 17, 14, 16, 8 }, { 13, 1, 10, 9, 12, 11 }, { 3, 5, 2, 4, 6, 7 },
|
||||
{ 0, 13, 17, 4, 12, 7 }, { 11, 15, 16, 6, 1, 5 }, { 14, 10, 8, 2, 9, 3 }, { 15, 0, 11, 2, 13, 3 },
|
||||
{ 17, 10, 14, 6, 7, 1 }, { 8, 4, 16, 5, 9, 12 }, { 7, 3, 16, 1, 9, 0 }, { 12, 15, 10, 17, 5, 2 },
|
||||
{ 6, 11, 4, 13, 8, 14 }, { 16, 11, 4, 17, 3, 10 }, { 12, 2, 6, 8, 0, 1 }, { 7, 13, 5, 15, 14, 9 },
|
||||
{ 1, 3, 12, 15, 14, 4 }, { 9, 17, 6, 16, 13, 2 }, { 5, 0, 7, 11, 10, 8 }, { 16, 2, 7, 11, 14, 12 },
|
||||
{ 3, 1, 5, 8, 17, 13 }, { 6, 9, 4, 10, 15, 0 }, { 14, 16, 13, 10, 5, 0 }, { 11, 2, 1, 9, 4, 17 },
|
||||
{ 8, 12, 3, 7, 6, 15 }, { 10, 13, 8, 7, 16, 15 }, { 2, 14, 0, 4, 5, 1 }, { 6, 17, 9, 12, 11, 3 },
|
||||
{ 14, 17, 0, 12, 11, 5 }, { 15, 16, 13, 1, 4, 2 }, { 8, 6, 3, 10, 7, 9 }, { 16, 6, 12, 0, 2, 10 },
|
||||
{ 1, 8, 15, 14, 17, 9 }, { 5, 7, 13, 3, 4, 11 }, { 9, 7, 0, 2, 15, 11 }, { 13, 3, 14, 1, 12, 10 },
|
||||
{ 17, 4, 5, 16, 8, 6 }, { 17, 4, 12, 15, 10, 7 }, { 3, 1, 11, 0, 8, 16 }, { 2, 9, 6, 5, 13, 14 },
|
||||
{ 0, 9, 17, 5, 3, 15 }, { 12, 7, 1, 13, 16, 6 }, { 10, 14, 2, 8, 11, 4 }, { 7, 14, 2, 17, 3, 16 },
|
||||
{ 15, 5, 10, 11, 1, 6 }, { 4, 12, 8, 9, 0, 13 } };
|
||||
Assert.assertEquals(56,this.getBoatchangesFromPairinglist(givenPairingList, 15, 3, 18));
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,21 @@ public interface PairingListTemplate {
|
||||
* @return double, stated as the standard deviation.
|
||||
*/
|
||||
double getQuality();
|
||||
|
||||
/**
|
||||
* The value corresponds to the quality of the distribution of competitors on the different boats. The quality is calculated by the standard
|
||||
* deviation of values in assignment matrix.
|
||||
*
|
||||
* @return double, stated as the standard deviation.
|
||||
*/
|
||||
double getAssignmentQuality();
|
||||
|
||||
/**
|
||||
* This value represents the number of boat changes needed in the whole competition.
|
||||
*
|
||||
* @return int, sum of boat changes.
|
||||
*/
|
||||
int getBoatChanges();
|
||||
|
||||
/**
|
||||
* Every row of this array represents a single group of a flight with competitors per group (competitors/groups) in
|
||||
|
||||
@@ -18,8 +18,8 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
|
||||
private final Random random = new Random();
|
||||
private final int[][] pairingListTemplate;
|
||||
private final double standardDev;
|
||||
private final int flightMultiplier, tolerance;
|
||||
private final double standardDev,assignmentQuality;
|
||||
private final int flightMultiplier, tolerance,boatchanges;
|
||||
private final int dummies;
|
||||
private final ExecutorService executorService = ThreadPoolUtil.INSTANCE
|
||||
.getDefaultBackgroundTaskThreadPoolExecutor();
|
||||
@@ -57,6 +57,12 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
this.standardDev = this.calcStandardDev(incrementAssociations(this.pairingListTemplate,
|
||||
new int[pairingFrameProvider.getCompetitorsCount()
|
||||
+ dummies][pairingFrameProvider.getCompetitorsCount() + dummies]));
|
||||
this.assignmentQuality = this.calcStandardDev(getAssignmentAssociations(this.pairingListTemplate,
|
||||
new int[pairingFrameProvider.getCompetitorsCount()][pairingFrameProvider.getCompetitorsCount()
|
||||
/ pairingFrameProvider.getGroupsCount()]));
|
||||
this.boatchanges = this.getBoatchangesFromPairinglist(this.pairingListTemplate,
|
||||
pairingFrameProvider.getFlightsCount(), pairingFrameProvider.getGroupsCount(),
|
||||
pairingFrameProvider.getCompetitorsCount());
|
||||
this.resetDummies(pairingListTemplate, pairingFrameProvider.getCompetitorsCount() + dummies);
|
||||
} else {
|
||||
this.pairingListTemplate = this.createPairingListTemplate(
|
||||
@@ -65,6 +71,12 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
this.standardDev = this.calcStandardDev(incrementAssociations(this.pairingListTemplate,
|
||||
new int[pairingFrameProvider.getCompetitorsCount()
|
||||
+ dummies][pairingFrameProvider.getCompetitorsCount() + dummies]));
|
||||
this.assignmentQuality = this.calcStandardDev(getAssignmentAssociations(this.pairingListTemplate,
|
||||
new int[pairingFrameProvider.getCompetitorsCount()][pairingFrameProvider.getCompetitorsCount()
|
||||
/ pairingFrameProvider.getGroupsCount()]));
|
||||
this.boatchanges = this.getBoatchangesFromPairinglist(this.pairingListTemplate,
|
||||
pairingFrameProvider.getFlightsCount(), pairingFrameProvider.getGroupsCount(),
|
||||
pairingFrameProvider.getCompetitorsCount()) * flightMultiplier + flightMultiplier*(this.getMatches(this.pairingListTemplate[pairingListTemplate.length-1], this.pairingListTemplate[0]));
|
||||
this.resetDummies(pairingListTemplate, pairingFrameProvider.getCompetitorsCount() + dummies);
|
||||
}
|
||||
} else {
|
||||
@@ -96,6 +108,11 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
|
||||
this.standardDev = this.calcStandardDev(incrementAssociations(this.pairingListTemplate,
|
||||
new int[competitorsCount + this.dummies][competitorsCount + this.dummies]));
|
||||
this.assignmentQuality = this.calcStandardDev(getAssignmentAssociations(template,
|
||||
new int[competitorsCount][competitorsCount
|
||||
/ groupCount]));
|
||||
this.boatchanges = this.getBoatchangesFromPairinglist(template,
|
||||
template.length/groupCount, groupCount, competitorsCount);
|
||||
this.resetDummies(this.pairingListTemplate, competitorsCount + this.dummies);
|
||||
this.iterations = 100000;
|
||||
this.flightMultiplier = flightMultiplier;
|
||||
@@ -106,6 +123,15 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
public double getQuality() {
|
||||
return this.standardDev;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAssignmentQuality(){
|
||||
return this.assignmentQuality;
|
||||
}
|
||||
@Override
|
||||
public int getBoatChanges(){
|
||||
return this.boatchanges;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Flight, Group, Competitor, CompetitorAllocation> PairingList<Flight, Group, Competitor, CompetitorAllocation> createPairingList(
|
||||
@@ -855,4 +881,16 @@ public class PairingListTemplateImpl implements PairingListTemplate {
|
||||
}
|
||||
return bestPLT;
|
||||
}
|
||||
|
||||
protected int getBoatchangesFromPairinglist(int[][] pairinglist, int flightcount, int groupcount,
|
||||
int competitorcount) {
|
||||
int sumOfBoatchanges = 0;
|
||||
for (int groupindex = groupcount-1; groupindex < flightcount * groupcount; groupindex += groupcount) {
|
||||
if (groupindex + 1 < pairinglist.length) {
|
||||
sumOfBoatchanges += ((competitorcount/groupcount)
|
||||
- this.getMatches(pairinglist[groupindex], pairinglist[groupindex + 1]));
|
||||
}
|
||||
}
|
||||
return sumOfBoatchanges;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user