-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PolarisationResult class; moved export package under dna
- Loading branch information
Showing
12 changed files
with
167 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dna/src/main/java/export/BarplotResult.java → ...c/main/java/dna/export/BarplotResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dna/src/main/java/export/DataFrame.java → dna/src/main/java/dna/export/DataFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package export; | ||
package dna.export; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...src/main/java/export/ExportStatement.java → ...main/java/dna/export/ExportStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package export; | ||
package dna.export; | ||
|
||
|
||
import model.Statement; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dna/src/main/java/export/Matrix.java → dna/src/main/java/dna/export/Matrix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package export; | ||
package dna.export; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.ZoneOffset; | ||
|
2 changes: 1 addition & 1 deletion
2
...ain/java/export/NestedBackboneResult.java → ...java/dna/export/NestedBackboneResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package export; | ||
package dna.export; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
package dna.export; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Stores the results of a single run of the genetic algorithm, i.e., for a | ||
* single time step of the time window algorithm or the whole network if no | ||
* time window was set. | ||
*/ | ||
public final class PolarisationResult { | ||
|
||
private final double[] maxQ; | ||
private final double[] avgQ; | ||
private final double[] sdQ; | ||
private final double finalMaxQ; | ||
private final int[] memberships; | ||
private final String[] names; | ||
private final boolean earlyConvergence; | ||
private final LocalDateTime start; | ||
private final LocalDateTime stop; | ||
private final LocalDateTime middle; | ||
|
||
/** | ||
* Creates a PolarizationResult for a single time step. | ||
* | ||
* @param maxQ The maximum quality score for each iteration of the genetic algorithm. | ||
* @param avgQ The mean quality score for each iteration of the genetic algorithm. | ||
* @param sdQ The standard deviation of the quality scores for each iteration of the genetic algorithm. | ||
* @param finalMaxQ The maximum quality score of the final iteration of the genetic algorithm. | ||
* @param memberships A membership array containing the cluster levels for each node, starting with 0 and going up to K - 1. | ||
* @param names The node labels of the network. | ||
* @param earlyConvergence A boolean indicating whether the genetic algorithm converged before the last iteration. | ||
* @param start The start date and time of the time window network. Cannot be null. If no time window was set, this is the date of the network. | ||
* @param stop The end date and time of the time window network. Cannot be null. If no time window was set, this is the date of the network. | ||
* @param middle The mid-point date of the time window network. Cannot be null. If no time window was set, this is the date of the network. | ||
* @throws IllegalArgumentException if any array is null, has invalid sizes, or if start, stop, or middle is null. | ||
*/ | ||
public PolarisationResult(double[] maxQ, double[] avgQ, double[] sdQ, double finalMaxQ, | ||
int[] memberships, String[] names, boolean earlyConvergence, | ||
LocalDateTime start, LocalDateTime stop, LocalDateTime middle) { | ||
|
||
// Validate input | ||
if (maxQ == null || avgQ == null || sdQ == null || memberships == null || names == null) { | ||
throw new IllegalArgumentException("Input arrays cannot be null."); | ||
} | ||
if (start == null || stop == null || middle == null) { | ||
throw new IllegalArgumentException("Start, stop, and middle dates cannot be null."); | ||
} | ||
if (maxQ.length != avgQ.length || maxQ.length != sdQ.length) { | ||
throw new IllegalArgumentException("maxQ, avgQ, and sdQ must have the same length."); | ||
} | ||
if (memberships.length != names.length) { | ||
throw new IllegalArgumentException("Memberships and names must have the same length."); | ||
} | ||
|
||
// Assign fields | ||
this.maxQ = Arrays.copyOf(maxQ, maxQ.length); | ||
this.avgQ = Arrays.copyOf(avgQ, avgQ.length); | ||
this.sdQ = Arrays.copyOf(sdQ, sdQ.length); | ||
this.finalMaxQ = finalMaxQ; | ||
this.memberships = Arrays.copyOf(memberships, memberships.length); | ||
this.names = Arrays.copyOf(names, names.length); | ||
this.earlyConvergence = earlyConvergence; | ||
this.start = start; | ||
this.stop = stop; | ||
this.middle = middle; | ||
} | ||
|
||
public LocalDateTime getStart() { | ||
return start; | ||
} | ||
|
||
public LocalDateTime getStop() { | ||
return stop; | ||
} | ||
|
||
public LocalDateTime getMiddle() { | ||
return middle; | ||
} | ||
|
||
public int[] getMemberships() { | ||
return Arrays.copyOf(memberships, memberships.length); | ||
} | ||
|
||
public String[] getNames() { | ||
return Arrays.copyOf(names, names.length); | ||
} | ||
|
||
public double[] getMaxQ() { | ||
return Arrays.copyOf(maxQ, maxQ.length); | ||
} | ||
|
||
public double[] getAvgQ() { | ||
return Arrays.copyOf(avgQ, avgQ.length); | ||
} | ||
|
||
public double[] getSdQ() { | ||
return Arrays.copyOf(sdQ, sdQ.length); | ||
} | ||
|
||
public double getFinalMaxQ() { | ||
return finalMaxQ; | ||
} | ||
|
||
public boolean isEarlyConvergence() { | ||
return earlyConvergence; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PolarizationResult{" + | ||
"maxQ=" + Arrays.toString(maxQ) + | ||
", avgQ=" + Arrays.toString(avgQ) + | ||
", sdQ=" + Arrays.toString(sdQ) + | ||
", finalMaxQ=" + finalMaxQ + | ||
", memberships=" + Arrays.toString(memberships) + | ||
", names=" + Arrays.toString(names) + | ||
", earlyConvergence=" + earlyConvergence + | ||
", start=" + start + | ||
", stop=" + stop + | ||
", middle=" + middle + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PolarisationResult that = (PolarisationResult) o; | ||
return Double.compare(that.finalMaxQ, finalMaxQ) == 0 && | ||
earlyConvergence == that.earlyConvergence && | ||
Arrays.equals(maxQ, that.maxQ) && | ||
Arrays.equals(avgQ, that.avgQ) && | ||
Arrays.equals(sdQ, that.sdQ) && | ||
Arrays.equals(memberships, that.memberships) && | ||
Arrays.equals(names, that.names) && | ||
Objects.equals(start, that.start) && | ||
Objects.equals(stop, that.stop) && | ||
Objects.equals(middle, that.middle); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(finalMaxQ, earlyConvergence, start, stop, middle); | ||
result = 31 * result + Arrays.hashCode(maxQ); | ||
result = 31 * result + Arrays.hashCode(avgQ); | ||
result = 31 * result + Arrays.hashCode(sdQ); | ||
result = 31 * result + Arrays.hashCode(memberships); | ||
result = 31 * result + Arrays.hashCode(names); | ||
return result; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ort/SimulatedAnnealingBackboneResult.java → ...ort/SimulatedAnnealingBackboneResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package export; | ||
package dna.export; | ||
|
||
import java.io.Serializable; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters