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

LearnLib / automatalib / 13138848026

04 Feb 2025 02:53PM UTC coverage: 92.108% (+2.2%) from 89.877%
13138848026

push

github

mtf90
[maven-release-plugin] prepare release automatalib-0.12.0

16609 of 18032 relevant lines covered (92.11%)

1.7 hits per line

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

93.75
/api/src/main/java/net/automatalib/ts/simple/SimpleTS.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
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 net.automatalib.ts.simple;
17

18
import java.util.Collection;
19
import java.util.HashSet;
20
import java.util.Set;
21

22
import net.automatalib.common.util.mapping.MapMapping;
23
import net.automatalib.common.util.mapping.MutableMapping;
24

25
/**
26
 * A simple transition system. A transition system is a (not necessarily finite) collection of states. For an arbitrary
27
 * input symbol, each state has a set of successors.
28
 *
29
 * @param <S>
30
 *         state class.
31
 * @param <I>
32
 *         symbol class.
33
 */
34
public interface SimpleTS<S, I> {
35

36
    /**
37
     * Retrieves the set of successors for the given input symbol.
38
     *
39
     * @param state
40
     *         the source state.
41
     * @param input
42
     *         the input symbol.
43
     *
44
     * @return the set of successors reachable by this input.
45
     */
46
    Set<S> getSuccessors(S state, I input);
47

48
    /**
49
     * Retrieves the set of all successors that can be reached from any of the given source states by the specified
50
     * sequence of input symbols.
51
     *
52
     * @param states
53
     *         the source states.
54
     * @param input
55
     *         the sequence of input symbols.
56
     *
57
     * @return the set of successors reachable by this input.
58
     */
59
    default Set<S> getSuccessors(Collection<? extends S> states, Iterable<? extends I> input) {
60
        Set<S> current = new HashSet<>(states);
1✔
61
        Set<S> succs = new HashSet<>();
1✔
62

63
        for (I sym : input) {
1✔
64
            for (S state : current) {
1✔
65
                Set<S> currSuccs = getSuccessors(state, sym);
1✔
66
                succs.addAll(currSuccs);
1✔
67
            }
1✔
68

69
            Set<S> tmp = current;
1✔
70
            current = succs;
1✔
71
            succs = tmp;
1✔
72
            succs.clear();
1✔
73
        }
1✔
74

75
        return current;
1✔
76
    }
77

78
    /**
79
     * Retrieves the set of all states reachable by the given sequence of input symbols from an initial state. Calling
80
     * this method is equivalent to {@code getSuccessors(getInitialStates(), input)}.
81
     *
82
     * @param input
83
     *         the sequence of input symbols.
84
     *
85
     * @return the set of states reachable by this input from an initial state state is reachable.
86
     */
87
    default Set<S> getStates(Iterable<? extends I> input) {
88
        return getSuccessors(getInitialStates(), input);
1✔
89
    }
90

91
    /**
92
     * Retrieves the set of initial states of the transition system.
93
     *
94
     * @return the initial states.
95
     */
96
    Set<S> getInitialStates();
97

98
    /**
99
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this transition system's states. The
100
     * returned mapping is however only guaranteed to work correctly if the transition system is not modified.
101
     *
102
     * @param <V>
103
     *         the value type of the mapping
104
     *
105
     * @return the mutable mapping
106
     */
107
    default <V> MutableMapping<S, V> createStaticStateMapping() {
108
        return new MapMapping<>();
1✔
109
    }
110

111
    /**
112
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this transition system's states. The
113
     * returned mapping maintains the association even when the transition system is modified.
114
     *
115
     * @param <V>
116
     *         the value type of the mapping
117
     *
118
     * @return the mutable mapping
119
     */
120
    default <V> MutableMapping<S, V> createDynamicStateMapping() {
121
        return new MapMapping<>();
×
122
    }
123

124
}
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

© 2025 Coveralls, Inc