• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / learnlib / 20198569605

13 Dec 2025 10:10PM UTC coverage: 94.914% (+0.4%) from 94.471%
20198569605

Pull #153

github

web-flow
Merge 6a71fc929 into 879958926
Pull Request #153: Implementation for learning MMLTs, new model for collecting statistics

1823 of 1873 new or added lines in 77 files covered. (97.33%)

1 existing line in 1 file now uncovered.

14258 of 15022 relevant lines covered (94.91%)

1.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
/api/src/main/java/de/learnlib/sul/TimedSUL.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of LearnLib <https://learnlib.de>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package de.learnlib.sul;
17

18
import java.util.ArrayList;
19
import java.util.List;
20

21
import net.automatalib.automaton.mmlt.MMLT;
22
import net.automatalib.symbol.time.InputSymbol;
23
import net.automatalib.symbol.time.TimeStepSequence;
24
import net.automatalib.symbol.time.TimedInput;
25
import net.automatalib.symbol.time.TimedOutput;
26
import net.automatalib.symbol.time.TimeoutSymbol;
27
import net.automatalib.word.Word;
28
import org.checkerframework.checker.nullness.qual.Nullable;
29

30
/**
31
 * Interface for a {@link SUL} with {@link MMLT} semantics.
32
 *
33
 * @param <I>
34
 *         input symbol type (of non-delaying inputs)
35
 * @param <O>
36
 *         output symbol type
37
 */
38
public interface TimedSUL<I, O> extends SUL<InputSymbol<I>, TimedOutput<O>> {
39

40
    /**
41
     * Follows the provided input word, starting at the current system state. The input word must not contain timeout
42
     * symbols. Otherwise, an error occurs.
43
     *
44
     * @param input
45
     *         the input word
46
     */
47
    default void follow(Word<TimedInput<I>> input) {
48
        this.follow(input, -1);
1✔
49
    }
1✔
50

51
    /**
52
     * Follows the provided input word, starting at the current configuration.
53
     *
54
     * @param input
55
     *         the input word
56
     * @param maxTimeout
57
     *         the maximum waiting time to use for {@link TimeoutSymbol}s.
58
     */
59
    default void follow(Word<TimedInput<I>> input, long maxTimeout) {
60
        for (TimedInput<I> i : input) {
1✔
61
            if (i instanceof InputSymbol<I> ndi) {
1✔
62
                this.step(ndi);
1✔
63
            } else if (i instanceof TimeStepSequence<I> tss) {
1✔
64
                this.collectTimeouts(tss);
1✔
65
            } else if (i instanceof TimeoutSymbol<I>) {
1✔
66
                if (maxTimeout <= 0) {
1✔
67
                    throw new IllegalArgumentException("Must supply timeout when using timeout symbols.");
1✔
68
                }
69
                this.timeoutStep(maxTimeout);
1✔
70
            } else {
NEW
71
                throw new IllegalArgumentException("Unknown suffix type.");
×
72
            }
73
        }
1✔
74
    }
1✔
75

76
    /**
77
     * Waits until a timeout occurs or the provided time is reached. May observe no timeout if either the waiting time
78
     * is too small or if the active location has no timers.
79
     *
80
     * @param maxTime
81
     *         the maximum waiting time.
82
     *
83
     * @return the observed timer output with waiting time, or {@code null} if no timeout was observed.
84
     */
85
    @Nullable TimedOutput<O> timeoutStep(long maxTime);
86

87
    /**
88
     * Waits for one time unit and returns the observed output.
89
     *
90
     * @return {@code null} if no output occurred, or a timer output if at least one timer expired. The delay of this
91
     * output is set to zero.
92
     */
93

94
    default @Nullable TimedOutput<O> timeStep() {
95
        TimedOutput<O> res = this.timeoutStep(1);
1✔
96
        if (res != null) {
1✔
97
            return new TimedOutput<>(res.symbol());
1✔
98
        }
99
        return null;
1✔
100
    }
101

102
    /**
103
     * Waits for the duration of the given time step and returns all observed timeouts.
104
     *
105
     * @param input
106
     *         the time step to wait.
107
     *
108
     * @return a list of observed timeouts (may be empty if no time outs occurred in the given time)
109
     */
110
    default List<TimedOutput<O>> collectTimeouts(TimeStepSequence<I> input) {
111
        List<TimedOutput<O>> timeouts = new ArrayList<>();
1✔
112

113
        long remainingTime = input.timeSteps();
1✔
114
        while (remainingTime > 0) {
1✔
115
            TimedOutput<O> nextTimeout = this.timeoutStep(remainingTime);
1✔
116
            if (nextTimeout == null) {
1✔
117
                // No timer will expire during remaining waiting time:
118
                break;
1✔
119
            } else {
120
                timeouts.add(nextTimeout);
1✔
121
                remainingTime -= nextTimeout.delay();
1✔
122
            }
123
        }
1✔
124

125
        return timeouts;
1✔
126
    }
127

128
    @Override
129
    default TimedSUL<I, O> fork() {
NEW
130
        throw new UnsupportedOperationException();
×
131
    }
132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc