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

main.io.github.moonlightsuite.moonlight.domain.ListDomain 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!
package io.github.moonlightsuite.moonlight.domain;

import io.github.moonlightsuite.moonlight.core.base.Box;
import io.github.moonlightsuite.moonlight.core.base.Semiring;
import io.github.moonlightsuite.moonlight.core.signal.SignalDomain;
import io.github.moonlightsuite.moonlight.core.io.DataHandler;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class ListDomain>
        implements SignalDomain>>
{
    private final
    List>> domains;

    public ListDomain(List> domains) {
        this.domains = new ArrayList<>();
        for(SignalDomain d: domains) {
            this.domains.add(new BoxDomain<>(d));
        }
    }

    public ListDomain(int size, SignalDomain domain) {
        this.domains = new ArrayList<>();
        for(int i = 0; i < size; i++) {
            this.domains.add(new BoxDomain<>(domain));
        }
    }

    /**
     * Negation function s.t. De Morgan laws, double negation
     * and inversion of the idempotent elements hold.
     *
     * @param x element to negate
     * @return the negation of the x element
     */
    @Override
    public List> negation(List> x) {
        return IntStream.range(0, domains.size())
                        .mapToObj(i -> domains.get(i).negation(x.get(i)))
                        .collect(Collectors.toList());
    }

    /**
     * Associative, commutative, idempotent operator that chooses a value.
     *
     * @param x first available value
     * @param y second available value
     * @return a result satisfying conjunction properties
     */
    @Override
    public List> conjunction(List> x,
                                    List> y)
    {
        return IntStream.range(0, domains.size())
                        .mapToObj(i -> domains.get(i)
                                              .conjunction(x.get(i), y.get(i)))
                        .collect(Collectors.toList());
    }

    /**
     * Associative, commutative operator that combines values.
     *
     * @param x first value to combine
     * @param y second value to combine
     * @return a result satisfying disjunction properties
     */
    @Override
    public List> disjunction(List> x,
                                    List> y)
    {
        return IntStream.range(0, domains.size())
                        .mapToObj(i -> domains.get(i)
                                              .disjunction(x.get(i), y.get(i)))
                        .collect(Collectors.toList());
    }

    /**
     * @return the infimum (aka meet) of the lattice defined over the semiring.
     */
    @Override
    public List> min() {
        return domains.stream().map(Semiring::min).collect(Collectors.toList());
    }

    /**
     * @return the supremum (aka join) of the lattice defined over the semiring.
     */
    @Override
    public List> max() {
        return domains.stream().map(Semiring::max).collect(Collectors.toList());
    }



    /**
     * Unknown element: this is an element of the set that represents
     * undefined areas of the signal.
     * Examples of this could be 0 for real numbers,
     * a third value for booleans, or the total interval for intervals.
     *
     * @return the element of the set representing absence of knowledge
     */
    @Override
    public List> any() {
        return domains.stream().map(SignalDomain::any)
                      .collect(Collectors.toList());
    }

    /**
     * @return an helper class to manage data parsing over the given type.
     */
    @Override
    public DataHandler>> getDataHandler() {
        return null;
    }

    @Override
    public boolean equalTo(List> x, List> y) {
        return false;
    }

    @Override
    public List> valueOf(boolean b) {
        return null;
    }

    @Override
    public List> valueOf(double v) {
        return null;
    }

    @Override
    public List> computeLessThan(double v1, double v2) {
        return null;
    }

    @Override
    public List> computeLessOrEqualThan(double v1, double v2) {
        return null;
    }

    @Override
    public List> computeEqualTo(double v1, double v2) {
        return null;
    }

    @Override
    public List> computeGreaterThan(double v1, double v2) {
        return null;
    }

    @Override
    public List> computeGreaterOrEqualThan(double v1, double v2) {
        return null;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy