main.io.github.moonlightsuite.moonlight.online.signal.OnlineSpaceTimeSignal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moonlight-engine Show documentation
Show all versions of moonlight-engine Show documentation
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.online.signal;
import io.github.moonlightsuite.moonlight.core.base.Box;
import io.github.moonlightsuite.moonlight.core.signal.SpaceTimeSignal;
import io.github.moonlightsuite.moonlight.online.algorithms.Signals;
import io.github.moonlightsuite.moonlight.core.signal.SignalDomain;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class OnlineSpaceTimeSignal>
implements SpaceTimeSignal>
{
private final TimeChain>> segments;
private final int size;
public OnlineSpaceTimeSignal(int locations,
SignalDomain domain)
{
List> any =
IntStream.range(0, locations).boxed()
.map(i -> new Box<>(domain.min(),
domain.max()))
.collect(Collectors.toList());
segments = new TimeChain<>(new TimeSegment<>(0.0, any), Double.POSITIVE_INFINITY);
size = locations;
}
/**
* Performs an update of the internal representation of the signal,
* given the data available in the update.
*
* @param u the new data available from new knowledge
* @return true
if the refinement actually updates the signal.
* false
otherwise
*/
@Override
public boolean refine(Update>> u) {
return Signals.refine(segments, u,
(v, vNew) -> IntStream.range(0, size)
.filter(i -> v.get(i).contains(vNew.get(i)))
.count() != 0
);
}
@Override
public boolean refine(
TimeChain>> updates)
{
return Signals.refineChain(segments, updates,
(v, vNew) -> IntStream.range(0, size)
.filter(i -> v.get(i).contains(vNew.get(i)))
.count() != 0
);
}
/**
* Returns the internal chain of segments.
*
* @return the total chain of segments of the signal
* @throws UnsupportedOperationException when not allowed by implementors
*/
@Override
public TimeChain>> getSegments() {
return segments;
}
/**
* Temporal projection operation that selects a sub-part of the signal
* delimited by the time instants provided by the input parameters.
*
* @param from beginning of the time frame of interest
* @param to ending of the time frame of interest
* @return the chain of segments of the signal delimited by the input
* @throws UnsupportedOperationException when not allowed by implementors
*/
@Override
public TimeChain>> select(Double from,
Double to)
{
return Signals.select(segments, from, to);
}
/**
* Returns the size of the spatial universe of reference
*
* @return the size of the spatial universe of reference
*/
@Override
public int getSize() {
return size;
}
}