Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
exports net.automatalib.ts.simple;
exports net.automatalib.visualization;
exports net.automatalib.word;
exports net.automatalib.alphabet.time.mmlt;
exports net.automatalib.automaton.time.mmlt.semantics;
exports net.automatalib.automaton.time.mmlt;

uses VisualizationProvider;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.automatalib.alphabet.time.mmlt;

/**
* Base type for input symbols for the structural automaton of an MMLT.
*/
public interface LocalTimerMealyInputSymbol<I> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package net.automatalib.alphabet.time.mmlt;

import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.Objects;

/**
* Output type for the semantics automaton: an output that occurs with some or no delay.
*/
public class LocalTimerMealyOutputSymbol<U> {

private final U userObject;
private final long delay;

public LocalTimerMealyOutputSymbol(long delay, @NonNull U userObject) {
if (delay < 0) {
throw new IllegalArgumentException("Delay must not be negative.");
}
this.userObject = userObject;
this.delay = delay;
}

public LocalTimerMealyOutputSymbol(@NonNull U userObject) {
this(0, userObject);
}

public long getDelay() {
return delay;
}

public boolean isDelayed() {
return this.delay > 0;
}

public U getSymbol() {
return userObject;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LocalTimerMealyOutputSymbol<?> that = (LocalTimerMealyOutputSymbol<?>) o;
return delay == that.delay && Objects.equals(userObject, that.userObject);
}

@Override
public int hashCode() {
return Objects.hash(userObject, delay);
}

@Override
public String toString() {
if (this.isDelayed()) {
return String.format("[%d]%s", this.getDelay(), this.userObject);
}
return this.userObject.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.automatalib.alphabet.time.mmlt;

/**
* Base class for an input for the semantics automaton of some MMLT.
*
* @param <I>
*/
public interface LocalTimerMealySemanticInputSymbol<I> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package net.automatalib.alphabet.time.mmlt;

import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.Objects;

/**
* An non-delaying input for the structural and semantics automaton.
*
* @param <U>
*/
public class NonDelayingInput<U> implements LocalTimerMealySemanticInputSymbol<U>, LocalTimerMealyInputSymbol<U> {
private final U symbol;

public NonDelayingInput(@NonNull U input) {
this.symbol = input;
}

public U getSymbol() {
return this.symbol;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NonDelayingInput<?> that = (NonDelayingInput<?>) o;
return Objects.equals(symbol, that.symbol);
}

@Override
public int hashCode() {
return Objects.hashCode(symbol);
}

@Override
public String toString() {
return symbol.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.automatalib.alphabet.time.mmlt;

import java.util.Objects;

/**
* Convenience type for aggregating multiple subsequent time steps.
*/
public class TimeStepSequence<U> implements LocalTimerMealySemanticInputSymbol<U> {

private long timeSteps;

public TimeStepSequence(long timeSteps) {
this.timeSteps = timeSteps;

if (timeSteps <= 0) {
throw new IllegalArgumentException("Timeout must be larger than zero.");
}
}

public void setTimeSteps(long timeSteps) {
this.timeSteps = timeSteps;
if (timeSteps <= 0) {
throw new IllegalArgumentException("Timeout must be larger than zero.");
}
}

public long getTimeSteps() {
return timeSteps;
}

@Override
public String toString() {
return String.format("wait[%d]", this.timeSteps);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TimeStepSequence<?> that = (TimeStepSequence<?>) o;
return timeSteps == that.timeSteps;
}

@Override
public int hashCode() {
return Objects.hash(timeSteps);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.automatalib.alphabet.time.mmlt;

/**
* Input for the semantics automaton: delay for a single time step.
*/
public class TimeStepSymbol<U> extends TimeStepSequence<U> {

public TimeStepSymbol() {
super(1);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.automatalib.alphabet.time.mmlt;

import java.util.Objects;

/**
* Symbolic input for the semantics automaton: causes a delay until the next timeout.
*/
public class TimeoutSymbol<U> implements LocalTimerMealySemanticInputSymbol<U> {

@Override
public String toString() {
return "timeout";
}

@Override
public boolean equals(Object o) {
return o != null && getClass() == o.getClass();
}

@Override
public int hashCode() {
return Objects.hash(this.toString());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.automatalib.alphabet.time.mmlt;

import java.util.Objects;

/**
* The timeout symbol of a timer, as used by the structural automaton.
* <p>
* This input is used for the transition and output function of some MMLT.
* These symbols are not inputs for the expanded form of an MMLT.
*
* @param <U>
*/
public class TimerTimeoutSymbol<U> implements LocalTimerMealyInputSymbol<U> {
private final String timer;

public TimerTimeoutSymbol(String timer) {
this.timer = timer;
}

public String getTimer() {
return timer;
}

@Override
public String toString() {
return String.format("to[%s]", this.timer);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TimerTimeoutSymbol<?> that = (TimerTimeoutSymbol<?>) o;
return Objects.equals(timer, that.timer);
}

@Override
public int hashCode() {
return Objects.hashCode(timer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.automatalib.automaton.time.mmlt;

import java.util.List;

/**
* In an MMLT, multiple timeouts may occur simultaneously.
* We use these symbol combiners to combine their outputs deterministically.
*
* @param <U> Symbol type
*/
public abstract class AbstractSymbolCombiner<U> {

/**
* Indicates if the provided suffix is a combined suffix.
*
* @param symbol Symbol for testing
* @return True if combined suffix, false if not.
*/
public abstract boolean isCombinedSymbol(U symbol);

/**
* Combines the provided symbols to a single suffix of same data type. Must be deterministic.
*
* @param symbols Provided symbols.
* @return Combined suffix
*/
public abstract U combineSymbols(List<U> symbols);

/**
* Attempts to separate the provided combined suffix into individual symbols.
*
* @param symbol Combined symbols
* @return Individual symbols
*/
public abstract List<U> separateSymbols(U symbol);
}
Loading