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

LearnLib / automatalib / 6672550055

27 Oct 2023 09:48PM UTC coverage: 89.796% (+0.1%) from 89.69%
6672550055

push

github

mtf90
bump ADDLib version

15832 of 17631 relevant lines covered (89.8%)

1.66 hits per line

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

88.24
/api/src/main/java/net/automatalib/ts/simple/SimpleTS.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of AutomataLib, http://www.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.Collections;
20
import java.util.HashSet;
21
import java.util.Set;
22

23
import net.automatalib.common.util.mapping.MapMapping;
24
import net.automatalib.common.util.mapping.MutableMapping;
25
import org.checkerframework.checker.nullness.qual.Nullable;
26

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

38
    /**
39
     * Retrieves the set of successors for the given sequence of input symbols.
40
     *
41
     * @param state
42
     *         the source state.
43
     * @param input
44
     *         the sequence of input symbols.
45
     *
46
     * @return the set of successors reachable by this input.
47
     */
48
    default Set<S> getSuccessors(S state, Iterable<? extends I> input) {
49
        return getSuccessors(Collections.singleton(state), input);
×
50
    }
51

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

67
        for (I sym : input) {
1✔
68
            for (S state : current) {
1✔
69
                Set<? extends S> currSuccs = getSuccessors(state, sym);
1✔
70
                succs.addAll(currSuccs);
1✔
71
            }
1✔
72

73
            Set<S> tmp = current;
1✔
74
            current = succs;
1✔
75
            succs = tmp;
1✔
76
            succs.clear();
1✔
77
        }
1✔
78

79
        return current;
1✔
80
    }
81

82
    /**
83
     * Retrieves the set of successors for the given input symbol.
84
     *
85
     * @param state
86
     *         the source state.
87
     * @param input
88
     *         the input symbol.
89
     *
90
     * @return the set of successors reachable by this input.
91
     */
92
    Set<S> getSuccessors(S state, I input);
93

94
    /**
95
     * Retrieves the set of all states reachable by the given sequence of input symbols from an initial state. Calling
96
     * this method is equivalent to <code>getSuccessors(getInitialStates(), input)</code>.
97
     *
98
     * @param input
99
     *         the sequence of input symbols.
100
     *
101
     * @return the set of states reachable by this input from an initial state, or <code>null</code> if no successor
102
     * state is reachable.
103
     */
104
    default Set<S> getStates(Iterable<? extends I> input) {
105
        return getSuccessors(getInitialStates(), input);
1✔
106
    }
107

108
    /**
109
     * Retrieves the set of initial states of the transition system.
110
     *
111
     * @return the initial states.
112
     */
113
    Set<S> getInitialStates();
114

115
    /**
116
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this transition system's states. The
117
     * returned mapping is however only guaranteed to work correctly if the transition system is not modified.
118
     *
119
     * @param <V>
120
     *         the value type of the mapping
121
     *
122
     * @return the mutable mapping
123
     */
124
    default <@Nullable V> MutableMapping<S, V> createStaticStateMapping() {
125
        return new MapMapping<>();
1✔
126
    }
127

128
    /**
129
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this transition system's states. The
130
     * returned mapping maintains the association even when the transition system is modified.
131
     *
132
     * @param <V>
133
     *         the value type of the mapping
134
     *
135
     * @return the mutable mapping
136
     */
137
    default <@Nullable V> MutableMapping<S, V> createDynamicStateMapping() {
138
        return new MapMapping<>();
×
139
    }
140

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