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

main.io.github.moonlightsuite.moonlight.domain.DoubleDomain Maven / Gradle / Ivy

Go to download

MoonLight is a light-weight Java-tool for monitoring temporal, spatial and spatio-temporal properties of distributed complex systems, such as Cyber-Physical Systems and Collective Adaptive Systems.

The newest version!
/*
 * MoonLight: a light-weight framework for runtime monitoring
 * Copyright (C) 2018-2021
 *
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.
 *
 * 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 io.github.moonlightsuite.moonlight.domain;

import io.github.moonlightsuite.moonlight.core.io.DataHandler;
import io.github.moonlightsuite.moonlight.core.signal.SignalDomain;
import io.github.moonlightsuite.moonlight.core.space.DistanceDomain;

/**
 * Signal domain to support doubles (i.e. classical robustness).
 *
 * @see SignalDomain
 */
public class DoubleDomain implements
        SignalDomain, DistanceDomain {
    private static final double TOLERANCE = 1E-12;

    @Override
    public Double any() {
        return 0.0;
    }

    @Override
    public Double conjunction(Double x, Double y) {
        return Math.min(x, y);
    }

    @Override
    public Double disjunction(Double x, Double y) {
        return Math.max(x, y);
    }

    @Override
    public Double negation(Double x) {
        return -x;
    }

    @Override
    public Double min() {
        return Double.NEGATIVE_INFINITY;
    }

    @Override
    public Double max() {
        return Double.POSITIVE_INFINITY;
    }

    @Override
    public Double zero() {
        return 0.0;
    }

    @Override
    public Double infinity() {
        return Double.POSITIVE_INFINITY;
    }

    @Override
    public boolean lessOrEqual(Double x, Double y) {
        return x < y || equalTo(x, y);
    }

    @Override
    public boolean equalTo(Double x, Double y) {
        return Math.abs(x - y) < TOLERANCE;
    }

    @Override
    public Double multiply(Double x, int factor) {
        return x * factor;
    }

    @Override
    public Double sum(Double x, Double y) {
        return x + y;
    }

    @Override
    public boolean less(Double x, Double y) {
        return x < y;
    }

    @Override
    public Double valueOf(boolean b) {
        return (b ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY);
    }

    @Override
    public Double valueOf(double v) {
        return v;
    }

    @Override
    public Double computeLessThan(double v1, double v2) {
        return v2 - v1;
    }

    @Override
    public Double computeLessOrEqualThan(double v1, double v2) {
        return v2 - v1;
    }

    @Override
    public Double computeEqualTo(double v1, double v2) {
        return -Math.abs(v1 - v2);
    }

    @Override
    public Double computeGreaterThan(double v1, double v2) {
        return v1 - v2;
    }

    @Override
    public Double computeGreaterOrEqualThan(double v1, double v2) {
        return v1 - v2;
    }

    @Override
    public DataHandler getDataHandler() {
        return DataHandler.REAL;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy