Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

141 serializable metrics #156

Open
wants to merge 138 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
ba0fda4
Create reproduction-check.yml
dominikmaeckel Aug 13, 2024
1240cdb
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
2abec10
Comment out check for DRAFT state
dominikmaeckel Aug 13, 2024
aaf205c
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
2d0264a
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
f19db1c
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
c927e71
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
7922405
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
1d12ab9
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
f72cf75
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
41583fe
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
9222526
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
3301e43
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
565a9af
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
c447329
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
56c62de
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
0a2f737
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
24eecf6
Create reproduction-check-all.yml
dominikmaeckel Aug 13, 2024
c081512
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
a50741b
Update reproduction-check-all.yml
dominikmaeckel Aug 13, 2024
4df6029
Update reproduction-check.yml
dominikmaeckel Aug 13, 2024
c23be8e
Update reproduction-check-all.yml
dominikmaeckel Aug 13, 2024
882c126
Update reproduction-check-all.yml
dominikmaeckel Aug 13, 2024
fa09134
Add first draft of metric serialization
tillschallau Aug 14, 2024
89571b9
Merge remote-tracking branch 'refs/remotes/origin/main' into 141-seri…
tillschallau Aug 15, 2024
460e2ca
Add second draft of metric serialization
tillschallau Aug 15, 2024
896b420
Add saving and loading of serialized results
tillschallau Aug 15, 2024
b91d033
Add serialization of new SerializationResultComparison
tillschallau Aug 15, 2024
a20064e
Change return type from single SerializableResult to List of Serializ…
tillschallau Aug 15, 2024
846c434
Add helper functions and tests
tillschallau Aug 16, 2024
178afe3
Add tests for SerializationHelpers.kt
tillschallau Aug 16, 2024
fb8deac
Update getSerializedResultsFromFolder functions
tillschallau Aug 16, 2024
0c46441
Change Path to File
tillschallau Aug 19, 2024
59cc1f0
Fix all
tillschallau Aug 19, 2024
aa706e0
[WIP]
dominikmaeckel Aug 19, 2024
ae5630e
[WIP]
dominikmaeckel Aug 19, 2024
065cb02
Only execute result comparison and writing when there are Serializabl…
tillschallau Aug 19, 2024
ad3bcb0
Remove test main.kt
tillschallau Aug 19, 2024
2cf816c
Fix SegmentCountMetricSerializationTest
tillschallau Aug 19, 2024
b7d1ada
Remove unused functions, fix SerializationHelpersTest and add KDoc
tillschallau Aug 19, 2024
247d0b5
Add missing KDoc for Serializable
tillschallau Aug 19, 2024
11b5833
Fix SerializationHelpersTest
tillschallau Aug 19, 2024
361ef6a
Remove unused files
tillschallau Aug 19, 2024
4eb6a0c
Add missing KDoc and replace "/ground-truth" and "/latest-evaluation"…
tillschallau Aug 19, 2024
79d9885
Add missing KDoc and remove unused functions
tillschallau Aug 19, 2024
1eda67a
Add KDoc and rename placeholder variables
tillschallau Aug 19, 2024
62d0ba8
Rename SerializableResultExtensions.kt to SerializableResultSourceMap…
tillschallau Aug 19, 2024
d223359
Add KDoc to SerializableResult and move extrude some functions as ext…
tillschallau Aug 19, 2024
fb0b69d
SpotlessApply
tillschallau Aug 19, 2024
db225fb
Add KDoc to SerializableResultComparison and move getJsonString() fun…
tillschallau Aug 19, 2024
776bbc8
Add KDoc to SerializableIntResult
tillschallau Aug 19, 2024
cece559
Add KDoc to SerializableResultComparisonVerdict
tillschallau Aug 19, 2024
3dc4bc5
Add KDoc to SerializationResultTest
tillschallau Aug 19, 2024
281edbc
Add KDoc to SerializableIntResultTest
tillschallau Aug 19, 2024
743220c
Add KDoc to SerializationResultExtensionsTest and remove unused tests
tillschallau Aug 19, 2024
1668eed
Update KDoc for SegmentCountMetric
tillschallau Aug 19, 2024
91e6a9c
Remove SerialVersionUIDInSerializableClass detekt rule as we have our…
tillschallau Aug 19, 2024
71feb19
Merge branch 'main' into 141-serializable-metrics
dominikmaeckel Aug 20, 2024
c5c0242
[WIP]
dominikmaeckel Aug 20, 2024
65656b2
Moved comparison verdict to TSCEvaluation.
dominikmaeckel Aug 20, 2024
32e8edd
Synchronized result fields.
dominikmaeckel Aug 20, 2024
f0d6fd4
Update reproduction-check-all.yml
dominikmaeckel Aug 20, 2024
6bd53e9
Update reproduction-check-all.yml
dominikmaeckel Aug 20, 2024
e37b7c2
Update reproduction-check.yml
dominikmaeckel Aug 20, 2024
8b6eedc
Update reproduction-check.yml
dominikmaeckel Aug 20, 2024
b9c873d
Renamed extension files.
dominikmaeckel Aug 20, 2024
df23726
Renamed extension files.
dominikmaeckel Aug 20, 2024
16e1120
Merge branch '141-serializable-metrics' of github.com:tudo-aqua/stars…
dominikmaeckel Aug 20, 2024
81b6536
trigger pipeline
tillschallau Aug 20, 2024
5115033
Add artifact saving.
dominikmaeckel Aug 22, 2024
291cda1
Add artifact saving.
dominikmaeckel Aug 22, 2024
78b9ffa
Add artifact saving.
dominikmaeckel Aug 22, 2024
68fc53b
Upgraded Gh actions.
dominikmaeckel Aug 22, 2024
0073528
Merge branch 'main' into 141-serializable-metrics
dominikmaeckel Aug 23, 2024
9506063
Merged main.
dominikmaeckel Aug 23, 2024
183acb9
Moved helper functions to companion objects of corresponding types.
dominikmaeckel Aug 23, 2024
f09de41
Removed file existence check.
dominikmaeckel Aug 23, 2024
78e515a
Added configurable ground-truth.
dominikmaeckel Aug 23, 2024
d4b6552
Fixed gradle config for reproduction.
dominikmaeckel Aug 23, 2024
944adce
Fixed gradle config for reproduction.
dominikmaeckel Aug 23, 2024
bcb5a6d
Merged reporduction workflow
dominikmaeckel Aug 26, 2024
c5daed7
Add reproduction runner.
dominikmaeckel Sep 27, 2024
8a89b32
Update analyze-build-deploy.yml
dominikmaeckel Sep 27, 2024
0304d56
Update analyze-build-deploy.yml
dominikmaeckel Sep 27, 2024
a1b5b03
Merge branch 'main' into 141-serializable-metrics
dominikmaeckel Sep 27, 2024
8cc382e
Update analyze-build-deploy.yml
dominikmaeckel Sep 27, 2024
138e0e0
Update analyze-build-deploy.yml
dominikmaeckel Sep 27, 2024
ef832a6
Update analyze-build-deploy.yml
dominikmaeckel Sep 27, 2024
2ae3ddc
Update analyze-build-deploy.yml
dominikmaeckel Sep 27, 2024
da5768d
WIP
dominikmaeckel Sep 27, 2024
c14ab1b
WIP
dominikmaeckel Sep 27, 2024
94a136f
WIP
dominikmaeckel Sep 27, 2024
759fd3e
WIP
dominikmaeckel Sep 27, 2024
0356000
Readded old checks to workflow.
dominikmaeckel Sep 27, 2024
e2b919a
Prettified PreSegmentEvaluationHook.evaluate().
dominikmaeckel Oct 1, 2024
5033924
Fixed memory leak.
dominikmaeckel Oct 1, 2024
2d03cf9
Update analyze-build-deploy.yml
dominikmaeckel Oct 2, 2024
8e03c88
Fix wording
tillschallau Oct 7, 2024
d1ecc1c
Changed minTicks to 11.
dominikmaeckel Oct 8, 2024
d2436e1
Added serializability to TotalSegmentTickDifferencePerIdentifierMetric.
dominikmaeckel Oct 8, 2024
4027e9f
Serializable TSC result [WIP]
dominikmaeckel Oct 9, 2024
62e580e
Added TSC serialization.
dominikmaeckel Oct 10, 2024
8b92375
Fixed tests.
dominikmaeckel Oct 10, 2024
fad6bdc
Fixed KDoc.
dominikmaeckel Oct 10, 2024
c347152
Merge branch 'main' into 141-serializable-metrics
dominikmaeckel Oct 22, 2024
c5e2412
Removed unused generic.
dominikmaeckel Oct 22, 2024
234210c
Clarify return type for getSerializedResults() for all serializable m…
tillschallau Oct 22, 2024
7d47d85
Add missing changes to CHANGELOG.md
tillschallau Oct 22, 2024
a8db0ff
Update files
tillschallau Oct 23, 2024
bf6836e
Added explicit type parameters in test.
dominikmaeckel Oct 24, 2024
969a980
Upgraded kotlin compiler version.
dominikmaeckel Oct 24, 2024
19d0cfb
SpotlessApply
tillschallau Oct 24, 2024
edb061f
Simplify generic parameters
tillschallau Oct 24, 2024
0050732
Add tests for valid/invalid TSC instances serialization comparison
tillschallau Oct 24, 2024
91c1659
Make MissedTSCInstancesPerTSCMetric serializable
tillschallau Oct 24, 2024
53cc93e
Add missing documentation
tillschallau Oct 24, 2024
bb35123
Add missing documentation
tillschallau Oct 24, 2024
dc0d108
Add specific Serializable result for MissedTSCInstancesPerTSCMetric.kt
tillschallau Oct 24, 2024
528b467
Clarify "must not" change
tillschallau Oct 24, 2024
ec7b443
Add exhaustive TSC test helper
tillschallau Oct 24, 2024
37e8f1b
Add more tests for metrics
tillschallau Oct 24, 2024
c143d48
Let MissedPredicateCombinationsPerTSCMetric.kt implement Serializable…
tillschallau Oct 24, 2024
c191ee0
Fix wording in docstring
tillschallau Oct 24, 2024
30dfbb1
Add TSC to SerializablePredicateCombinationResult
tillschallau Oct 24, 2024
553ca9b
Add serialization of FailedMonitorsMetric
tillschallau Oct 24, 2024
53c6a45
Update docstring
tillschallau Oct 24, 2024
1306fd1
Add test for SerializableFailedMonitorResult
tillschallau Oct 24, 2024
db19f32
Add missing documentation
tillschallau Oct 24, 2024
a8b115c
Add loggerIdentifier field to Loggable interface
tillschallau Oct 25, 2024
018a5bb
Rename evaluationResult to evaluationResultCache in MissedPredicateCo…
tillschallau Oct 25, 2024
dc4a329
Add loggerIdentifier field to missing Loggable classes
tillschallau Oct 25, 2024
9247b00
Add delegated segment count for each segment
tillschallau Oct 25, 2024
02330b1
Remove extension from source filename which is passed as SegmentSource
tillschallau Oct 25, 2024
1baa145
Rename segmentIdentifier to segmentSource
tillschallau Oct 25, 2024
bb14e75
Fix missing missedPredicateCombinations
tillschallau Oct 25, 2024
18e5a1b
Fix failing tests
tillschallau Oct 25, 2024
e84524e
Fix failing tests
tillschallau Oct 25, 2024
156ce77
Add count to serializable results, where Lists are present as value
tillschallau Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .github/workflows/analyze-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Analyze, Build and Deploy

on:
pull_request:
types: [opened, synchronize]
types: [opened, synchronize, ready_for_review]
branches:
- main
push:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Discover Projects and save into matrix
run: |
run: |
./gradlew projects --quiet | grep "Project ':" | awk -F"'" '{print $2}' | sed 's/^://' > projects.txt
projects=$(cat projects.txt | sed '/^$/d' | awk '{print "\""$0"\""}' | paste -sd "," - | sed 's/^/[/' | sed 's/$/]/')
echo "matrix=${projects}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
mkdir sarif &&
find * -name detekt.sarif -print0 |
xargs -n1 -0 bash -c 'cp "$1" "sarif/${1//\//-}"' '{}'

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
Expand Down Expand Up @@ -142,10 +142,30 @@ jobs:

- name: Upload test results
uses: mikepenz/action-junit-report@v4
if: always() # Must execute after failed tests
if: ${{ !cancelled() }} # Must execute after failed tests
with:
report_paths: '**/build/test-results/test/TEST-*.xml'

reproduction:
name: Trigger reproduction check
needs: compile
runs-on: ubuntu-latest
steps:
- name: Trigger GitLab
run: |
curl -X POST \
--fail \
-F token=$REPRODUCTION_RUNNER_TRIGGER_TOKEN \
-F ref=main \
-F variables[TARGET_BRANCH]=${{ github.head_ref || github.ref_name }} \
-F variables[IS_DRAFT]=${{ github.event.pull_request.draft }} \
-F variables[TARGET_SHA]=${{ github.event.pull_request.head.sha }} \
-s -o /dev/null \
$REPRODUCTION_RUNNER_URL
env:
REPRODUCTION_RUNNER_TRIGGER_TOKEN: ${{ secrets.REPRODUCTION_RUNNER_TRIGGER_TOKEN }}
REPRODUCTION_RUNNER_URL: ${{ secrets.REPRODUCTION_RUNNER_URL }}

spotless:
name: Run Spotless (${{ matrix.project }})
needs: discover-projects
Expand Down Expand Up @@ -173,11 +193,11 @@ jobs:
run: ./gradlew :${{ matrix.project }}:spotlessCheck

- name: Apply Spotless fixes
if: failure()
if: ${{ failure() }}
run: ./gradlew :${{ matrix.project }}:spotlessApply

- name: Generate diff
if: failure()
if: ${{ failure() }}
shell: sh
run: |
echo "# Spotless violations" >> $GITHUB_STEP_SUMMARY
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@ All notable changes to this project will be documented in this file.
- Add `identifier` field to `TSC`.
- Add `euclideanDistance` function to `Location`.
- Add `vehicleType` field to `Vehicle`.
- Add `loggerIdentifier` field to `Loggable` interface.
- Add `Serializable` interface.
- This adds the functionality to compare your current analysis results with the previous run or a specified ground-truth.

### Changed
- `TSCEvaluation` now accepts multiple `TSCs` instead of `TSCProjections`.
- `registerMetricProviders` now throws an `IllegalArgumentException` when multiple instances of the same `MetricProvider` class is registered.
- Root nodes in a `TSC` now **must not** have a condition.
- Move `label` from `TSCEdge` to `TSCNode`.
- All default metrics now implement the new `Serializable` interface.
- Rename `ProjectionMetricProvider` to `TSCMetricProvider`.
- Rename `ProjectionAndTSCInstanceNodeMetricProvider` to `TSCAndTSCInstanceNodeMetricProvider`.
- Rename `InvalidTSCInstancesPerProjectionMetric` to `InvalidTSCInstancesPerTSCMetric`.
- Rename `ValidTSCInstancesPerProjectionMetric` to `ValidTSCInstancesPerTSCMetric`.
- Rename `MissedTSCInstancesPerProjectionMetric` to `MissedTSCInstancesPerTSCMetric`.
- Rename `MissingPredicateCombinationsPerProjectionMetric` to `MissingPredicateCombinationsPerTSCMetric`.
- Root nodes in a `TSC` now must not have a condition.
- Rename `DataSaver` to `PlotDataSaver`.

### Fixed
- Fix `toString()` function of `TSCNode` to include the root node's label.
Expand Down
2 changes: 1 addition & 1 deletion contrib/detekt-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ style:
SafeCast:
active: true
SerialVersionUIDInSerializableClass:
active: true
active: false
SpacingBetweenPackageAndImports:
# Rationale: handled by spotless
active: false
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ letsplot-imageexport = { group = "org.jetbrains.lets-plot", name = "lets-plot-im
kotlin-test = { group = "org.jetbrains.kotlin", name="kotlin-test" }

# Gradle Plugins
gradle-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version = "2.0.0" }
gradle-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version = "2.0.21" }
gradle-dokka = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version = "1.9.20" }
gradle-detekt = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version = "1.23.6" }
gradle-bmVersions = { group = "com.github.ben-manes", name = "gradle-versions-plugin", version = "0.51.0" }
Expand Down
6 changes: 5 additions & 1 deletion stars-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* limitations under the License.
*/

plugins { id("tools.aqua.stars.library-conventions") }
plugins {
id("tools.aqua.stars.library-conventions")
kotlin("plugin.serialization") version "2.0.10"
}

mavenMetadata {
name.set("STARS Core Library")
Expand All @@ -27,4 +30,5 @@ dependencies {
implementation(libs.letsplot.imageexport)
implementation(libs.slf4j.api)
implementation(libs.slf4j.simple)
implementation(libs.kotlinx.serialization.json)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import tools.aqua.stars.core.hooks.PreSegmentEvaluationHook.Companion.evaluate
import tools.aqua.stars.core.hooks.PreTSCEvaluationHook.Companion.evaluate
import tools.aqua.stars.core.hooks.defaulthooks.MinTicksPerSegmentHook
import tools.aqua.stars.core.metric.providers.*
import tools.aqua.stars.core.metric.serialization.SerializableResultComparison.Companion.noMismatch
import tools.aqua.stars.core.metric.serialization.extensions.compareToGroundTruthResults
import tools.aqua.stars.core.metric.serialization.extensions.compareToPreviousResults
import tools.aqua.stars.core.metric.serialization.extensions.writeSerializedResults
import tools.aqua.stars.core.metric.utils.saveAsJsonFiles
import tools.aqua.stars.core.tsc.TSC
import tools.aqua.stars.core.tsc.instance.TSCInstanceNode
import tools.aqua.stars.core.types.*
Expand All @@ -40,9 +45,16 @@ import tools.aqua.stars.core.types.*
* @param S [SegmentType].
* @param U [TickUnit].
* @param D [TickDifference].
* @param writeSerializedResults (Default: ``true``) Whether to write result files and compare them
* to previous runs after the analysis.
* @param compareToGroundTruth (Default: ``false``) Whether to compare the results to the ground
* truth.
* @param compareToPreviousRun (Default: ``false``) Whether to compare the results to the previous
* run.
* @property tscList The list of [TSC]s to evaluate.
* @property writePlots (Default: ``true``) Whether to write plots after the analysis.
* @property writePlotDataCSV (Default: ``false``) Whether to write CSV files after the analysis.
* @property loggerIdentifier identifier (name) for the logger.
* @property logger [Logger] instance.
*/
class TSCEvaluation<
Expand All @@ -54,9 +66,45 @@ class TSCEvaluation<
val tscList: List<TSC<E, T, S, U, D>>,
val writePlots: Boolean = true,
val writePlotDataCSV: Boolean = false,
override val logger: Logger = Loggable.getLogger("evaluation-time")
val writeSerializedResults: Boolean = true,
val compareToGroundTruth: Boolean = false,
val compareToPreviousRun: Boolean = false,
override val loggerIdentifier: String = "evaluation-time",
override val logger: Logger = Loggable.getLogger(loggerIdentifier),
) : Loggable {

private val mutex: Any = Any()

/**
* Holds the aggregated [Boolean] verdict of all compared results with the ground-truth data.
* Setting a new value will be conjugated with the old value such that a verdict 'false' may not
* be changed to 'true' again.
*/
var resultsReproducedFromGroundTruth: Boolean? = null
set(value) {
synchronized(mutex) {
when {
field == null -> field = value
field != null && value != null -> field = field!! && value
}
}
}

/**
* Holds the aggregated [Boolean] verdict of all compared results with the previous evaluation
* results. Setting a new value will be conjugated with the old value such that a verdict 'false'
* may not be changed to 'true' again.
*/
var resultsReproducedFromPreviousRun: Boolean? = null
set(value) {
synchronized(mutex) {
when {
field == null -> field = value
field != null && value != null -> field = field!! && value
}
}
}

/** Holds a [List] of all [MetricProvider]s registered by [registerMetricProviders]. */
private val metricProviders: MutableList<MetricProvider<E, T, S, U, D>> = mutableListOf()

Expand All @@ -71,7 +119,12 @@ class TSCEvaluation<
private val preTSCEvaluationHooks: MutableList<PreTSCEvaluationHook<E, T, S, U, D>> =
mutableListOf()

/** Holds the results of the [PreSegmentEvaluationHook]s after calling [runEvaluation]. */
/**
* Holds the results (Map of [PreSegmentEvaluationHook.identifier] to [EvaluationHookResult]) of
* the [PreSegmentEvaluationHook]s after calling [runEvaluation] that did not return
* [EvaluationHookResult.OK] for each segment identifier obtained by
* [SegmentType.getSegmentIdentifier].
*/
val preSegmentEvaluationHookResults: MutableMap<String, Map<String, EvaluationHookResult>> =
mutableMapOf()

Expand Down Expand Up @@ -275,5 +328,34 @@ class TSCEvaluation<
println("Writing CSVs")
metricProviders.filterIsInstance<Plottable>().forEach { it.writePlotDataCSV() }
}

val serializableMetrics = metricProviders.filterIsInstance<Serializable>()
if (serializableMetrics.any()) {
// Write JSON files of all Serializable metrics
if (writeSerializedResults) {
println("Writing serialized results")
serializableMetrics.forEach { t -> t.writeSerializedResults() }
}

// Compare the results to the ground truth
if (compareToGroundTruth) {
println("Comparing to ground truth")
serializableMetrics.compareToGroundTruthResults().let {
resultsReproducedFromGroundTruth = it.noMismatch()

if (writeSerializedResults) it.saveAsJsonFiles(comparedToGroundTruth = true)
}
}

// Compare the results to the latest run
if (compareToPreviousRun) {
println("Comparing to previous run")
serializableMetrics.compareToPreviousResults().let {
resultsReproducedFromPreviousRun = it.noMismatch()

if (writeSerializedResults) it.saveAsJsonFiles(comparedToGroundTruth = false)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ package tools.aqua.stars.core.metric.metrics.evaluation

import java.util.logging.Logger
import tools.aqua.stars.core.metric.providers.Loggable
import tools.aqua.stars.core.metric.providers.Serializable
import tools.aqua.stars.core.metric.providers.Stateful
import tools.aqua.stars.core.metric.providers.TSCAndTSCInstanceNodeMetricProvider
import tools.aqua.stars.core.metric.serialization.SerializableTSCOccurrenceResult
import tools.aqua.stars.core.metric.serialization.tsc.SerializableTSCNode
import tools.aqua.stars.core.metric.serialization.tsc.SerializableTSCOccurrence
import tools.aqua.stars.core.metric.utils.ApplicationConstantsHolder.CONSOLE_INDENT
import tools.aqua.stars.core.metric.utils.ApplicationConstantsHolder.CONSOLE_SEPARATOR
import tools.aqua.stars.core.tsc.TSC
Expand All @@ -35,13 +39,17 @@ import tools.aqua.stars.core.types.*
* This class implements the [Stateful] interface. Its state contains the [Map] of [TSC]s to a
* [List] of invalid [TSCInstance]s.
*
* This class implements the [Serializable] interface. It serializes all invalid [TSCInstance] for
* their respective [TSC].
*
* This class implements [Loggable] and logs the final [Map] of invalid [TSCInstance]s for [TSC]s.
*
* @param E [EntityType].
* @param T [TickDataType].
* @param S [SegmentType].
* @param U [TickUnit].
* @param D [TickDifference].
* @property loggerIdentifier identifier (name) for the logger.
* @property logger [Logger] instance.
*/
@Suppress("unused")
Expand All @@ -51,8 +59,9 @@ class InvalidTSCInstancesPerTSCMetric<
S : SegmentType<E, T, S, U, D>,
U : TickUnit<U, D>,
D : TickDifference<D>>(
override val logger: Logger = Loggable.getLogger("invalid-tsc-instances-per-tsc")
) : TSCAndTSCInstanceNodeMetricProvider<E, T, S, U, D>, Stateful, Loggable {
override val loggerIdentifier: String = "invalid-tsc-instances-per-tsc",
override val logger: Logger = Loggable.getLogger(loggerIdentifier)
) : TSCAndTSCInstanceNodeMetricProvider<E, T, S, U, D>, Stateful, Serializable, Loggable {
/** Map the [TSC] to a map in which the occurrences of invalid [TSCInstance]s are stored. */
private val invalidInstancesMap:
MutableMap<
Expand Down Expand Up @@ -124,4 +133,19 @@ class InvalidTSCInstancesPerTSCMetric<
}
}
}

override fun getSerializableResults(): List<SerializableTSCOccurrenceResult> =
invalidInstancesMap.map { (tsc, invalidInstances) ->
val resultList =
invalidInstances.map { (tscInstanceNode, tscInstances) ->
SerializableTSCOccurrence(
tscInstance = SerializableTSCNode(tscInstanceNode),
segmentIdentifiers = tscInstances.map { it.sourceSegmentIdentifier })
}
SerializableTSCOccurrenceResult(
identifier = tsc.identifier,
source = loggerIdentifier,
count = resultList.size,
value = resultList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
package tools.aqua.stars.core.metric.metrics.evaluation

import java.util.logging.Logger
import kotlin.collections.component1
import kotlin.collections.component2
import tools.aqua.stars.core.metric.providers.Loggable
import tools.aqua.stars.core.metric.providers.Serializable
import tools.aqua.stars.core.metric.providers.Stateful
import tools.aqua.stars.core.metric.providers.TSCAndTSCInstanceNodeMetricProvider
import tools.aqua.stars.core.metric.serialization.SerializableTSCResult
import tools.aqua.stars.core.metric.serialization.tsc.SerializableTSCNode
import tools.aqua.stars.core.metric.utils.ApplicationConstantsHolder.CONSOLE_INDENT
import tools.aqua.stars.core.metric.utils.ApplicationConstantsHolder.CONSOLE_SEPARATOR
import tools.aqua.stars.core.tsc.TSC
Expand All @@ -35,13 +40,17 @@ import tools.aqua.stars.core.types.*
* This class implements the [Stateful] interface. Its state contains the [Map] of [TSC]s to a
* [List] of missed [TSCInstance]s.
*
* This class implements the [Serializable] interface. It serializes all missed [TSCInstance] for
* their respective [TSC].
*
* This class implements [Loggable] and logs the final [Map] of missed [TSCInstance]s for [TSC]s.
*
* @param E [EntityType].
* @param T [TickDataType].
* @param S [SegmentType].
* @param U [TickUnit].
* @param D [TickDifference].
* @property loggerIdentifier identifier (name) for the logger.
* @property logger [Logger] instance.
*/
@Suppress("unused")
Expand All @@ -51,8 +60,9 @@ class MissedTSCInstancesPerTSCMetric<
S : SegmentType<E, T, S, U, D>,
U : TickUnit<U, D>,
D : TickDifference<D>>(
override val logger: Logger = Loggable.getLogger("missed-tsc-instances-per-tsc")
) : TSCAndTSCInstanceNodeMetricProvider<E, T, S, U, D>, Stateful, Loggable {
override val loggerIdentifier: String = "missed-tsc-instances-per-tsc",
override val logger: Logger = Loggable.getLogger(loggerIdentifier)
) : TSCAndTSCInstanceNodeMetricProvider<E, T, S, U, D>, Stateful, Serializable, Loggable {
/**
* Map a [TSC] to a map in which the missed valid [TSCInstanceNode]s are stored:
* Map<tsc,Map<referenceInstance,missed>>.
Expand Down Expand Up @@ -110,4 +120,17 @@ class MissedTSCInstancesPerTSCMetric<
missedInstances.forEach { logFine(it) }
}
}

override fun getSerializableResults(): List<SerializableTSCResult> =
missedInstancesMap.map { (tsc, missedInstances) ->
val resultList =
missedInstances
.filter { it.value }
.map { (tscInstanceNode, _) -> SerializableTSCNode(tscInstanceNode) }
SerializableTSCResult(
identifier = tsc.identifier,
source = loggerIdentifier,
count = resultList.size,
value = resultList)
}
}
Loading