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

LearnLib / automatalib / 8208485978

03 Mar 2024 10:58PM UTC coverage: 89.882% (-0.03%) from 89.915%
8208485978

push

github

mtf90
allow non-deterministic targets in FSABuilder

0 of 10 new or added lines in 2 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

15813 of 17593 relevant lines covered (89.88%)

1.66 hits per line

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

90.91
/api/src/main/java/net/automatalib/ts/simple/SimpleTS.java
1
/* Copyright (C) 2013-2024 TU Dortmund University
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 input symbol.
40
     *
41
     * @param state
42
     *         the source state.
43
     * @param input
44
     *         the input symbol.
45
     *
46
     * @return the set of successors reachable by this input.
47
     */
48
    Set<S> getSuccessors(S state, I input);
49

50
    /**
51
     * Retrieves the set of successors for the given sequence of input symbols.
52
     *
53
     * @param state
54
     *         the source state.
55
     * @param input
56
     *         the sequence of input symbols.
57
     *
58
     * @return the set of successors reachable by this input.
59
     */
60
    default Set<S> getSuccessors(S state, Iterable<? extends I> input) {
UNCOV
61
        return getSuccessors(Collections.singleton(state), input);
×
62
    }
63

64
    /**
65
     * Retrieves the set of all successors that can be reached from any of the given source states by the specified
66
     * input symbol.
67
     *
68
     * @param states
69
     *         the source states.
70
     * @param input
71
     *         the input symbol.
72
     *
73
     * @return the set of successors reachable by this input.
74
     */
75
    default Set<S> getSuccessors(Collection<? extends S> states, I input) {
76
        final Set<S> result = new HashSet<>();
1✔
77

78
        for (S state : states) {
1✔
79
            result.addAll(getSuccessors(state, input));
1✔
80
        }
1✔
81

82
        return result;
1✔
83
    }
84

85
    /**
86
     * Retrieves the set of all successors that can be reached from any of the given source states by the specified
87
     * sequence of input symbols.
88
     *
89
     * @param states
90
     *         the source states.
91
     * @param input
92
     *         the sequence of input symbols.
93
     *
94
     * @return the set of successors reachable by this input.
95
     */
96
    default Set<S> getSuccessors(Collection<? extends S> states, Iterable<? extends I> input) {
97
        Set<S> current = new HashSet<>(states);
1✔
98
        Set<S> succs = new HashSet<>();
1✔
99

100
        for (I sym : input) {
1✔
101
            for (S state : current) {
1✔
102
                Set<? extends S> currSuccs = getSuccessors(state, sym);
1✔
103
                succs.addAll(currSuccs);
1✔
104
            }
1✔
105

106
            Set<S> tmp = current;
1✔
107
            current = succs;
1✔
108
            succs = tmp;
1✔
109
            succs.clear();
1✔
110
        }
1✔
111

112
        return current;
1✔
113
    }
114

115
    /**
116
     * Retrieves the set of all states reachable by the given sequence of input symbols from an initial state. Calling
117
     * this method is equivalent to <code>getSuccessors(getInitialStates(), input)</code>.
118
     *
119
     * @param input
120
     *         the sequence of input symbols.
121
     *
122
     * @return the set of states reachable by this input from an initial state state is reachable.
123
     */
124
    default Set<S> getStates(Iterable<? extends I> input) {
125
        return getSuccessors(getInitialStates(), input);
1✔
126
    }
127

128
    /**
129
     * Retrieves the set of initial states of the transition system.
130
     *
131
     * @return the initial states.
132
     */
133
    Set<S> getInitialStates();
134

135
    /**
136
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this transition system's states. The
137
     * returned mapping is however only guaranteed to work correctly if the transition system is not modified.
138
     *
139
     * @param <V>
140
     *         the value type of the mapping
141
     *
142
     * @return the mutable mapping
143
     */
144
    default <@Nullable V> MutableMapping<S, V> createStaticStateMapping() {
145
        return new MapMapping<>();
1✔
146
    }
147

148
    /**
149
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this transition system's states. The
150
     * returned mapping maintains the association even when the transition system is modified.
151
     *
152
     * @param <V>
153
     *         the value type of the mapping
154
     *
155
     * @return the mutable mapping
156
     */
157
    default <@Nullable V> MutableMapping<S, V> createDynamicStateMapping() {
UNCOV
158
        return new MapMapping<>();
×
159
    }
160

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