Skip to content

Commit

Permalink
getIjkl() -> extractIjkl(), getStart() -> extractStart()
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 7, 2024
1 parent 64c019c commit c513a8f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/de/nqueensfaf/impl/CPUSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public int getNumberOfConstellations() {

public LinkedHashMap<Integer, Long> getSolutionsPerIjkl() {
LinkedHashMap<Integer, Long> solutionsPerIjkl = new LinkedHashMap<Integer, Long>();
constellations.stream().collect(Collectors.groupingBy(Constellation::getIjkl)).values().stream()
.forEach(cPerIjkl -> solutionsPerIjkl.put(cPerIjkl.get(0).getIjkl(),
constellations.stream().collect(Collectors.groupingBy(Constellation::extractIjkl)).values().stream()
.forEach(cPerIjkl -> solutionsPerIjkl.put(cPerIjkl.get(0).extractIjkl(),
cPerIjkl.stream().map(Constellation::getSolutions).reduce(0L, Long::sum)));
return solutionsPerIjkl;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/nqueensfaf/impl/Constellation.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public void setSolutions(long solutions) {
this.solutions = solutions;
}

public int getIjkl() {
public int extractIjkl() {
return startIjkl & 0b11111111111111111111;
}

public int getStart() {
public int extractStart() {
return startIjkl >> 20;
}
}
6 changes: 3 additions & 3 deletions src/main/java/de/nqueensfaf/impl/ConstellationsGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ public ArrayList<Constellation> generateSubConstellations(ArrayList<Constellatio
// counts all subconstellations
subConstellationsCounter = 0;

placePresetQueens(bc.getLd(), bc.getRd(), bc.getCol(), getk(bc.getIjkl()), getl(bc.getIjkl()),
bc.getStart(), bc.getStart()); // from row start to row presetQueens
placePresetQueens(bc.getLd(), bc.getRd(), bc.getCol(), getk(bc.extractIjkl()), getl(bc.extractIjkl()),
bc.extractStart(), bc.extractStart()); // from row start to row presetQueens
currentSize = constellations.size();

// jkl and sym and start are the same for all subconstellations
for (int a = 0; a < subConstellationsCounter; a++) {
var c = constellations.get(currentSize - a - 1);
c.setStartIjkl(c.getStartIjkl() | bc.getIjkl());
c.setStartIjkl(c.getStartIjkl() | bc.extractIjkl());
c.setId(bc.getId());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/nqueensfaf/impl/GPUSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ public int getNumberOfConstellations() {

public LinkedHashMap<Integer, Long> getSolutionsPerIjkl() {
LinkedHashMap<Integer, Long> solutionsPerIjkl = new LinkedHashMap<Integer, Long>();
constellations.stream().collect(Collectors.groupingBy(Constellation::getIjkl)).values().stream()
.forEach(cPerIjkl -> solutionsPerIjkl.put(cPerIjkl.get(0).getIjkl(),
constellations.stream().collect(Collectors.groupingBy(Constellation::extractIjkl)).values().stream()
.forEach(cPerIjkl -> solutionsPerIjkl.put(cPerIjkl.get(0).extractIjkl(),
cPerIjkl.stream().map(Constellation::getSolutions).reduce(0L, Long::sum)));
return solutionsPerIjkl;
}
Expand Down

0 comments on commit c513a8f

Please sign in to comment.