-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19 tackle code scanning alerts (#20)
* Moved Json objects from CarlaDataClasses.kt to dedicated files. * Restructured RunSegmentation.kt. A * Restructured CarlaToAVConverter.kt. * Restructured CarlaDataFileHandling.kt. * Extracted AV data classes to dedicated files. * Removed outdated version binding from kotlin-dsl plugin * Split CMFTBL extensions into separate files. * Upgraded kotlin version from 1.7.10 to 1.7.20. * Upgraded serialization plugin version to 1.9.10.
- Loading branch information
1 parent
bf1a5b2
commit 6ec4fc9
Showing
130 changed files
with
6,329 additions
and
3,563 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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# Platforms | ||
|
||
kotlin = "1.7.10" | ||
kotlin = "1.9.10" | ||
spring = "2.7.2" | ||
vaadin = "23.1.6" | ||
|
||
|
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
87 changes: 87 additions & 0 deletions
87
stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt
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,87 @@ | ||
/* | ||
* Copyright 2023 The STARS Project Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package tools.aqua.stars.core.evaluation | ||
|
||
import kotlin.reflect.KClass | ||
import tools.aqua.stars.core.types.EntityType | ||
import tools.aqua.stars.core.types.SegmentType | ||
import tools.aqua.stars.core.types.TickDataType | ||
|
||
/** | ||
* Binary predicate. | ||
* | ||
* @param E1 [EntityType] | ||
* 1. | ||
* @param E2 [EntityType] | ||
* 2. | ||
* @param E [EntityType]. | ||
* @param T [TickDataType]. | ||
* @param S [SegmentType]. | ||
* @property eval The evaluation function on the [PredicateContext]. | ||
* @property kClasses The actors. | ||
*/ | ||
class BinaryPredicate< | ||
E1 : E, E2 : E, E : EntityType<E, T, S>, T : TickDataType<E, T, S>, S : SegmentType<E, T, S>>( | ||
val eval: (PredicateContext<E, T, S>, E1, E2) -> Boolean, | ||
val kClasses: Pair<KClass<E1>, KClass<E2>> | ||
) { | ||
|
||
/** | ||
* Checks if this predicate holds (i.e. is true) in the given context. | ||
* | ||
* @param ctx The context this predicate is evaluated in. | ||
* @param tickId The time stamp to evaluate this predicate in. default: first tick in context. | ||
* @param actor1 The ID of the first actor to evaluate this predicate for. default: ego vehicle. | ||
* @param actor2 The ID of the second actor to evaluate this predicate for. | ||
*/ | ||
fun holds( | ||
ctx: PredicateContext<E, T, S>, | ||
tickId: Double = ctx.segment.firstTickId, | ||
actor1: Int = ctx.primaryEntityId, | ||
actor2: Int | ||
): Boolean = ctx.holds(this, tickId, actor1, actor2) | ||
|
||
/** | ||
* Checks if this predicate holds (i.e. is true) in the given context on current tick. | ||
* | ||
* @param ctx The context this predicate is evaluated in. | ||
* @param actor1 The ID of the first actor to evaluate this predicate for. default: ego vehicle. | ||
* @param actor2 The ID of the second actor to evaluate this predicate for. | ||
*/ | ||
fun holds(ctx: PredicateContext<E, T, S>, actor1: E1, actor2: E2): Boolean = | ||
holds( | ||
ctx, | ||
actor1.tickData.currentTick.apply { | ||
if (this != actor2.tickData.currentTick) error("ticks don't match") | ||
}, | ||
actor1.id, | ||
actor2.id) | ||
|
||
companion object { | ||
/** Creates a binary tick predicate in this context. */ | ||
fun < | ||
E1 : E, | ||
E2 : E, | ||
E : EntityType<E, T, S>, | ||
T : TickDataType<E, T, S>, | ||
S : SegmentType<E, T, S>> predicate( | ||
kClasses: Pair<KClass<E1>, KClass<E2>>, | ||
eval: (PredicateContext<E, T, S>, E1, E2) -> Boolean | ||
): BinaryPredicate<E1, E2, E, T, S> = BinaryPredicate(eval, kClasses) | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/NullaryPredicate.kt
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,55 @@ | ||
/* | ||
* Copyright 2023 The STARS Project Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package tools.aqua.stars.core.evaluation | ||
|
||
import tools.aqua.stars.core.types.EntityType | ||
import tools.aqua.stars.core.types.SegmentType | ||
import tools.aqua.stars.core.types.TickDataType | ||
|
||
/** | ||
* Nullary predicate. | ||
* | ||
* @param E [EntityType]. | ||
* @param T [TickDataType]. | ||
* @param S [SegmentType]. | ||
* @property eval The evaluation function on the [PredicateContext]. | ||
*/ | ||
class NullaryPredicate< | ||
E : EntityType<E, T, S>, T : TickDataType<E, T, S>, S : SegmentType<E, T, S>>( | ||
val eval: (PredicateContext<E, T, S>, T) -> Boolean, | ||
) { | ||
|
||
/** Evaluates predicate on [PredicateContext]. */ | ||
fun evaluate(ctx: PredicateContext<E, T, S>): List<Double> = ctx.evaluate(this) | ||
|
||
/** | ||
* Checks if this predicate holds (i.e. is true) in the given context and tick identifier. | ||
* | ||
* @param ctx The context this predicate is evaluated in. | ||
* @param tickId The time stamp to evaluate this predicate in. default: first tick in context. | ||
*/ | ||
fun holds(ctx: PredicateContext<E, T, S>, tickId: Double): Boolean = | ||
evaluate(ctx).contains(tickId) | ||
|
||
companion object { | ||
/** Creates a nullary tick predicate. */ | ||
fun <E : EntityType<E, T, S>, T : TickDataType<E, T, S>, S : SegmentType<E, T, S>> predicate( | ||
eval: (PredicateContext<E, T, S>, T) -> Boolean | ||
): NullaryPredicate<E, T, S> = NullaryPredicate(eval) | ||
} | ||
} |
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
Oops, something went wrong.