All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tools.aqua.stars.logic.kcmftbl.once.kt Maven / Gradle / Ivy

/*
 * Copyright 2023-2024 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.
 */

@file:Suppress("unused")

package tools.aqua.stars.logic.kcmftbl

import tools.aqua.stars.core.types.*

/**
 * CMFTBL implementation of the 'once' operator i.e. "In a past tick in the interval phi holds at
 * least once".
 *
 * @param E [EntityType].
 * @param T [TickDataType].
 * @param S [SegmentType].
 * @param U [TickUnit].
 * @param D [TickDifference].
 * @param tickData Current [TickDataType].
 * @param interval Observation interval.
 * @param phi Predicate.
 */
fun <
    E : EntityType,
    T : TickDataType,
    S : SegmentType,
    U : TickUnit,
    D : TickDifference> once(
    tickData: T,
    interval: Pair? = null,
    phi: (T) -> Boolean
): Boolean = since(tickData, interval, phi1 = { _ -> true }, phi2 = { td -> phi(td) })

/**
 * CMFTBL implementation of the 'once' operator for one entity i.e. "In a past tick in the interval
 * phi holds at least once".
 *
 * @param E1 [EntityType].
 * @param E [EntityType].
 * @param T [TickDataType].
 * @param S [SegmentType].
 * @param U [TickUnit].
 * @param D [TickDifference].
 * @param entity Current [EntityType] of which the tickData gets retrieved.
 * @param interval Observation interval.
 * @param phi Predicate.
 */
fun <
    E1 : E,
    E : EntityType,
    T : TickDataType,
    S : SegmentType,
    U : TickUnit,
    D : TickDifference> once(
    entity: E1,
    interval: Pair? = null,
    phi: (E1) -> Boolean
): Boolean = since(entity, interval, phi1 = { _ -> true }, phi2 = { e -> phi(e) })

/**
 * CMFTBL implementation of the 'once' operator for two entities i.e. "In a past tick in the
 * interval phi holds at least once".
 *
 * @param E1 [EntityType].
 * @param E2 [EntityType].
 * @param E [EntityType].
 * @param T [TickDataType].
 * @param S [SegmentType].
 * @param U [TickUnit].
 * @param D [TickDifference].
 * @param entity1 First [EntityType].
 * @param entity2 Second [EntityType].
 * @param interval Observation interval.
 * @param phi Predicate.
 */
fun <
    E1 : E,
    E2 : E,
    E : EntityType,
    T : TickDataType,
    S : SegmentType,
    U : TickUnit,
    D : TickDifference> once(
    entity1: E1,
    entity2: E2,
    interval: Pair? = null,
    phi: (E1, E2) -> Boolean
): Boolean =
    since(entity1, entity2, interval, phi1 = { _, _ -> true }, phi2 = { e1, e2 -> phi(e1, e2) })




© 2015 - 2024 Weber Informatics LLC | Privacy Policy