diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation')
65 files changed, 0 insertions, 3395 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath deleted file mode 100644 index 428337e5..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.classpath +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <classpath> | ||
3 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
4 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
5 | <classpathentry kind="src" path="src"/> | ||
6 | <classpathentry kind="src" path="xtend-gen"/> | ||
7 | <classpathentry kind="output" path="bin"/> | ||
8 | </classpath> | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.gitignore +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | /bin/ | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project deleted file mode 100644 index ba51fe06..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.project +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <projectDescription> | ||
3 | <name>hu.bme.mit.inf.dslreasoner.faulttree.transformation</name> | ||
4 | <comment></comment> | ||
5 | <projects> | ||
6 | </projects> | ||
7 | <buildSpec> | ||
8 | <buildCommand> | ||
9 | <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
10 | <arguments> | ||
11 | </arguments> | ||
12 | </buildCommand> | ||
13 | <buildCommand> | ||
14 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
15 | <arguments> | ||
16 | </arguments> | ||
17 | </buildCommand> | ||
18 | <buildCommand> | ||
19 | <name>org.eclipse.pde.ManifestBuilder</name> | ||
20 | <arguments> | ||
21 | </arguments> | ||
22 | </buildCommand> | ||
23 | <buildCommand> | ||
24 | <name>org.eclipse.pde.SchemaBuilder</name> | ||
25 | <arguments> | ||
26 | </arguments> | ||
27 | </buildCommand> | ||
28 | </buildSpec> | ||
29 | <natures> | ||
30 | <nature>org.eclipse.pde.PluginNature</nature> | ||
31 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
32 | <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
33 | </natures> | ||
34 | </projectDescription> | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.settings/org.eclipse.jdt.core.prefs b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/.settings/org.eclipse.jdt.core.prefs +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | eclipse.preferences.version=1 | ||
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
4 | org.eclipse.jdt.core.compiler.compliance=1.8 | ||
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
7 | org.eclipse.jdt.core.compiler.source=1.8 | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF deleted file mode 100644 index 5ee6a4f1..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/META-INF/MANIFEST.MF +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | Manifest-Version: 1.0 | ||
2 | Bundle-ManifestVersion: 2 | ||
3 | Bundle-Name: Transformation | ||
4 | Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.faulttree.transformation | ||
5 | Bundle-Version: 1.0.0.qualifier | ||
6 | Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.faulttree.transformation | ||
7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | ||
8 | Require-Bundle: com.google.guava, | ||
9 | org.eclipse.xtext.xbase.lib, | ||
10 | org.eclipse.xtend.lib, | ||
11 | org.eclipse.xtend.lib.macro, | ||
12 | org.eclipse.emf.ecore, | ||
13 | org.eclipse.viatra.query.runtime, | ||
14 | org.eclipse.viatra.query.runtime.rete, | ||
15 | org.eclipse.viatra.query.runtime.localsearch, | ||
16 | hu.bme.mit.inf.dslreasoner.faulttree.components, | ||
17 | hu.bme.mit.inf.dslreasoner.logic.model, | ||
18 | org.apache.commons.lang;bundle-version="2.6.0" | ||
19 | Export-Package: hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft, | ||
20 | hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft, | ||
21 | hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo, | ||
22 | hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/build.properties b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/build.properties deleted file mode 100644 index d8e2f0e9..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/build.properties +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | source.. = src/,\ | ||
2 | xtend-gen/ | ||
3 | output.. = bin/ | ||
4 | bin.includes = META-INF/,\ | ||
5 | . | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend deleted file mode 100644 index a522654c..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.xtend +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent | ||
7 | |||
8 | class Cft2FtTransformation { | ||
9 | def createFaultTree(ComponentFaultTree componentFaultTree) { | ||
10 | val materializer = new EventMaterializer | ||
11 | val topEvent = materializer.getOrMaterialize(componentFaultTree.topEvent) | ||
12 | switch (topEvent) { | ||
13 | ConstantEvent: | ||
14 | FtFactory.eINSTANCE.createConstantModel => [ | ||
15 | failed = topEvent.failed | ||
16 | ] | ||
17 | RandomEvent: { | ||
18 | val builder = new FaultTreeBuilder | ||
19 | builder.addTopLevel(topEvent) | ||
20 | builder.faultTree | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.xtend deleted file mode 100644 index 102dc57e..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.xtend +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft | ||
2 | |||
3 | import com.google.common.collect.ImmutableSet | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent | ||
7 | import java.util.Set | ||
8 | import org.eclipse.xtend.lib.annotations.Data | ||
9 | |||
10 | @Data | ||
11 | class EventCollection { | ||
12 | val int falseEventCount | ||
13 | val int trueEventCount | ||
14 | val Set<RandomEvent> randomEvents | ||
15 | |||
16 | def containsFalseEvent() { | ||
17 | falseEventCount >= 1 | ||
18 | } | ||
19 | |||
20 | def containsTrueEvent() { | ||
21 | trueEventCount >= 1 | ||
22 | } | ||
23 | |||
24 | def getVariableEventCount() { | ||
25 | randomEvents.size | ||
26 | } | ||
27 | |||
28 | def containsRandomEvent() { | ||
29 | variableEventCount >= 1 | ||
30 | } | ||
31 | |||
32 | def getCount() { | ||
33 | falseEventCount + trueEventCount + variableEventCount | ||
34 | } | ||
35 | |||
36 | def isEmpty() { | ||
37 | !containsFalseEvent && !containsTrueEvent && !containsRandomEvent | ||
38 | } | ||
39 | |||
40 | def containsExactlyOneRandomEvent() { | ||
41 | !containsFalseEvent && !containsTrueEvent && variableEventCount == 1 | ||
42 | } | ||
43 | |||
44 | def toSingleRandomEvent() { | ||
45 | if (!containsExactlyOneRandomEvent) { | ||
46 | throw new IllegalStateException("Input collection is not a single random event") | ||
47 | } | ||
48 | randomEvents.head | ||
49 | } | ||
50 | |||
51 | static def builder() { | ||
52 | new Builder() | ||
53 | } | ||
54 | |||
55 | static class Builder { | ||
56 | var falseEventCount = 0 | ||
57 | var trueEventCount = 0 | ||
58 | val randomEventsBuilder = ImmutableSet.<RandomEvent>builder | ||
59 | |||
60 | private new() { | ||
61 | } | ||
62 | |||
63 | def add(Event event) { | ||
64 | switch (event) { | ||
65 | ConstantEvent: | ||
66 | if (event.failed) { | ||
67 | trueEventCount++ | ||
68 | } else { | ||
69 | falseEventCount++ | ||
70 | } | ||
71 | RandomEvent: | ||
72 | randomEventsBuilder.add(event) | ||
73 | default: | ||
74 | throw new IllegalArgumentException("Unknown event: " + event) | ||
75 | } | ||
76 | this | ||
77 | } | ||
78 | |||
79 | def addAll(EventCollection materializedEvens) { | ||
80 | falseEventCount += materializedEvens.falseEventCount | ||
81 | trueEventCount += materializedEvens.trueEventCount | ||
82 | randomEventsBuilder.addAll(materializedEvens.randomEvents) | ||
83 | this | ||
84 | } | ||
85 | |||
86 | def build() { | ||
87 | new EventCollection(falseEventCount, trueEventCount, randomEventsBuilder.build) | ||
88 | } | ||
89 | } | ||
90 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend deleted file mode 100644 index 6b3ed0d0..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend +++ /dev/null | |||
@@ -1,208 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.AndGateDefinition | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.BasicEventDefinition | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.GateDefinition | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.KOfMGateDefinition | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.OrGateDefinition | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory | ||
15 | import java.util.LinkedHashSet | ||
16 | import java.util.Map | ||
17 | import org.eclipse.emf.ecore.util.EcoreUtil | ||
18 | import org.eclipse.xtend.lib.annotations.Data | ||
19 | |||
20 | import static extension hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions.* | ||
21 | |||
22 | class EventMaterializer { | ||
23 | extension val FtFactory = FtFactory.eINSTANCE | ||
24 | |||
25 | val Map<EventKey<EventDeclaration>, Event> materializationCache = newHashMap | ||
26 | val Map<EventKey<InputEvent>, EventCollection> multipleInputCache = newHashMap | ||
27 | val ConstantEvent falseEvent | ||
28 | val ConstantEvent trueEvent | ||
29 | val path = new LinkedHashSet<EventKey<? extends EventDeclaration>> | ||
30 | |||
31 | new() { | ||
32 | falseEvent = createConstantEvent => [ | ||
33 | failed = false | ||
34 | ] | ||
35 | trueEvent = createConstantEvent => [ | ||
36 | failed = true | ||
37 | ] | ||
38 | } | ||
39 | |||
40 | def getOrMaterialize(Output output) { | ||
41 | getOrMaterialize(output.component, output.eventDeclaration) | ||
42 | } | ||
43 | |||
44 | def Event getOrMaterialize(Component component, EventDeclaration eventDeclaration) { | ||
45 | val eventKey = new EventKey(component, eventDeclaration) | ||
46 | pushEventKey(eventKey) | ||
47 | try { | ||
48 | // computeIfAbsent cannot be used recursively, so we must manually cache the event. | ||
49 | var event = materializationCache.get(eventKey) | ||
50 | if (event === null) { | ||
51 | event = materialize(component, eventDeclaration) | ||
52 | materializationCache.put(eventKey, event) | ||
53 | } | ||
54 | event | ||
55 | } finally { | ||
56 | popEventKey(eventKey) | ||
57 | } | ||
58 | } | ||
59 | |||
60 | protected def materialize(Component component, EventDeclaration eventDeclaration) { | ||
61 | val eventName = component.name + "_" + eventDeclaration.name | ||
62 | val event = switch (eventDeclaration) { | ||
63 | InputEvent: | ||
64 | return materializeConnectedEvent(component, eventDeclaration) | ||
65 | BasicEventDefinition: { | ||
66 | val basicEvent = createBasicEvent | ||
67 | basicEvent.distribution = EcoreUtil.copy(eventDeclaration.distribution) | ||
68 | basicEvent | ||
69 | } | ||
70 | GateDefinition: { | ||
71 | val inputs = collectInputs(component, eventDeclaration) | ||
72 | val gate = switch (eventDeclaration) { | ||
73 | AndGateDefinition: | ||
74 | if (inputs.containsFalseEvent) { | ||
75 | return falseEvent | ||
76 | } else if (inputs.empty) { | ||
77 | return trueEvent | ||
78 | } else if (inputs.containsExactlyOneRandomEvent) { | ||
79 | return inputs.toSingleRandomEvent | ||
80 | } else { | ||
81 | createAndGate | ||
82 | } | ||
83 | OrGateDefinition: | ||
84 | if (inputs.containsTrueEvent) { | ||
85 | return trueEvent | ||
86 | } else if (inputs.empty) { | ||
87 | return falseEvent | ||
88 | } else if (inputs.containsExactlyOneRandomEvent) { | ||
89 | return inputs.toSingleRandomEvent | ||
90 | } else { | ||
91 | createOrGate | ||
92 | } | ||
93 | KOfMGateDefinition: { | ||
94 | val requiredTrueInputs = inputs.count * eventDeclaration.k / eventDeclaration.m | ||
95 | val k = requiredTrueInputs - inputs.getTrueEventCount | ||
96 | val m = inputs.variableEventCount | ||
97 | if (k == 0) { | ||
98 | return trueEvent | ||
99 | } else if (k > m) { | ||
100 | return falseEvent | ||
101 | } else if (inputs.containsExactlyOneRandomEvent) { | ||
102 | return inputs.toSingleRandomEvent | ||
103 | } else if (k == 1) { | ||
104 | createOrGate | ||
105 | } else if (k == m) { | ||
106 | createAndGate | ||
107 | } else { | ||
108 | val kOfMGate = createKOfMGate | ||
109 | kOfMGate.k = k | ||
110 | kOfMGate | ||
111 | } | ||
112 | } | ||
113 | default: | ||
114 | throw new IllegalArgumentException("Unknown gate definition: " + eventDeclaration) | ||
115 | } | ||
116 | gate.inputEvents.addAll(inputs.getRandomEvents) | ||
117 | gate | ||
118 | } | ||
119 | default: | ||
120 | throw new IllegalArgumentException("Unknown event declaration: " + eventDeclaration) | ||
121 | } | ||
122 | event.name = eventName | ||
123 | event | ||
124 | } | ||
125 | |||
126 | protected def materializeConnectedEvent(Component component, InputEvent inputEvent) { | ||
127 | if (inputEvent.multiple) { | ||
128 | throw new IllegalArgumentException('''Cannot materialize multiple nput «component.name»_«inputEvent.name»''') | ||
129 | } | ||
130 | val input = findInput(component, inputEvent) | ||
131 | val incomingConnections = input.incomingConnections | ||
132 | if (incomingConnections.size != 1) { | ||
133 | throw new IllegalArgumentException('''Input «component.name»_«inputEvent.name» has «incomingConnections.size» connections instead of 1''') | ||
134 | } | ||
135 | val output = incomingConnections.head.output | ||
136 | getOrMaterialize(output.component, output.eventDeclaration) | ||
137 | } | ||
138 | |||
139 | protected def collectInputs(Component component, GateDefinition gateDefinition) { | ||
140 | val builder = EventCollection.builder | ||
141 | for (inputEventDeclaration : gateDefinition.inputEvents) { | ||
142 | switch (inputEventDeclaration) { | ||
143 | InputEvent case inputEventDeclaration.multiple: { | ||
144 | val materializedEvents = getOrMaterializeConnectedEvents(component, inputEventDeclaration) | ||
145 | builder.addAll(materializedEvents) | ||
146 | } | ||
147 | default: | ||
148 | builder.add(getOrMaterialize(component, inputEventDeclaration)) | ||
149 | } | ||
150 | } | ||
151 | builder.build | ||
152 | } | ||
153 | |||
154 | protected def getOrMaterializeConnectedEvents(Component component, InputEvent inputEvent) { | ||
155 | val inputKey = new EventKey(component, inputEvent) | ||
156 | pushEventKey(inputKey) | ||
157 | try { | ||
158 | // computeIfAbsent cannot be used recursively, so we must manually cache the event. | ||
159 | var eventCollection = multipleInputCache.get(inputKey) | ||
160 | if (eventCollection === null) { | ||
161 | eventCollection = materializeConnectedEvents(component, inputEvent) | ||
162 | multipleInputCache.put(inputKey, eventCollection) | ||
163 | } | ||
164 | eventCollection | ||
165 | } finally { | ||
166 | popEventKey(inputKey) | ||
167 | } | ||
168 | } | ||
169 | |||
170 | protected def materializeConnectedEvents(Component component, InputEvent inputEvent) { | ||
171 | val input = findInput(component, inputEvent) | ||
172 | val builder = EventCollection.builder | ||
173 | for (connection : input.incomingConnections) { | ||
174 | if (connection.isCurrentlyConnected) { | ||
175 | val materializedEvent = getOrMaterialize(connection.output) | ||
176 | builder.add(materializedEvent) | ||
177 | } | ||
178 | } | ||
179 | builder.build | ||
180 | } | ||
181 | |||
182 | protected def findInput(Component component, InputEvent inputEvent) { | ||
183 | val input = component.inputs.findFirst[it.inputEvent == inputEvent] | ||
184 | if (input === null) { | ||
185 | throw new IllegalArgumentException('''No input «inputEvent» in component «component»''') | ||
186 | } | ||
187 | return input | ||
188 | } | ||
189 | |||
190 | private def pushEventKey(EventKey<? extends EventDeclaration> eventKey) { | ||
191 | if (!path.add(eventKey)) { | ||
192 | throw new IllegalStateException( | ||
193 | '''Circular dependency [«FOR ancestor : path»«ancestor», «ENDFOR»«eventKey»] detected''') | ||
194 | } | ||
195 | } | ||
196 | |||
197 | private def popEventKey(EventKey<? extends EventDeclaration> eventKey) { | ||
198 | path.remove(eventKey) | ||
199 | } | ||
200 | |||
201 | @Data | ||
202 | protected static class EventKey<T extends EventDeclaration> { | ||
203 | val Component component | ||
204 | val T event | ||
205 | |||
206 | override toString() '''«component.name»_«event.name»''' | ||
207 | } | ||
208 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.xtend deleted file mode 100644 index 0b0afea6..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.xtend +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent | ||
6 | import java.util.Collection | ||
7 | import org.eclipse.xtend.lib.annotations.Accessors | ||
8 | |||
9 | class FaultTreeBuilder { | ||
10 | @Accessors | ||
11 | val faultTree = FtFactory.eINSTANCE.createFaultTree | ||
12 | |||
13 | def addTopLevel(RandomEvent event) { | ||
14 | if (faultTree.topEvent !== null) { | ||
15 | throw new IllegalStateException("Top event was already set") | ||
16 | } | ||
17 | add(event) | ||
18 | faultTree.topEvent = event | ||
19 | } | ||
20 | |||
21 | protected def void add(RandomEvent event) { | ||
22 | if (faultTree.eContainer == faultTree) { | ||
23 | return | ||
24 | } | ||
25 | if (faultTree.eContainer !== null) { | ||
26 | throw new IllegalStateException("Event is already in a different fault tree") | ||
27 | } | ||
28 | faultTree.events += event | ||
29 | if (event instanceof Gate) { | ||
30 | addAll(event.inputEvents) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | protected def addAll(Collection<RandomEvent> events) { | ||
35 | for (event : events) { | ||
36 | add(event) | ||
37 | } | ||
38 | } | ||
39 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend deleted file mode 100644 index 10c91fb4..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.xtend +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
6 | import java.util.Map | ||
7 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
8 | import org.eclipse.xtend.lib.annotations.Accessors | ||
9 | |||
10 | class ComponentFaultTreeTrace { | ||
11 | @Accessors val componentFaultTree = CftFactory.eINSTANCE.createComponentFaultTree | ||
12 | |||
13 | val nameGenerator = new ComponentNameGenerator | ||
14 | val Map<IPatternMatch, ComponentInstanceTrace> componentInstancesMap = newHashMap | ||
15 | |||
16 | def instantiateComponent(IPatternMatch patternMatch, ComponentDefinition componenDefinition) { | ||
17 | instantiateComponent(patternMatch, componenDefinition, Modality.MUST, false) | ||
18 | } | ||
19 | |||
20 | def instantiateComponent(IPatternMatch patternMatch, ComponentDefinition componenDefinition, Modality exists, | ||
21 | boolean allowMultiple) { | ||
22 | if (componentInstancesMap.containsKey(patternMatch)) { | ||
23 | throw new IllegalArgumentException("Already instantiated component for match: " + patternMatch) | ||
24 | } | ||
25 | val componentTrace = new ComponentInstanceTrace(componentFaultTree, componenDefinition, nameGenerator, | ||
26 | exists, allowMultiple) | ||
27 | componentInstancesMap.put(patternMatch, componentTrace) | ||
28 | componentTrace | ||
29 | } | ||
30 | |||
31 | def setTopLevel(ComponentInstanceTrace trace) { | ||
32 | if (componentFaultTree.topEvent !== null) { | ||
33 | throw new IllegalArgumentException("Top level component already set") | ||
34 | } | ||
35 | val outputs = trace.outputs | ||
36 | if (outputs.size !== 1) { | ||
37 | throw new IllegalArgumentException("Top level component must have 1 output, got " + outputs.size + | ||
38 | " instead") | ||
39 | } | ||
40 | if (!trace.appearsExactlyOnce) { | ||
41 | throw new IllegalArgumentException("Top level must appear in the fault tree exactly once") | ||
42 | } | ||
43 | componentFaultTree.topEvent = outputs.head | ||
44 | } | ||
45 | |||
46 | def lookup(IPatternMatch patternMatch) { | ||
47 | componentInstancesMap.get(patternMatch) | ||
48 | } | ||
49 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend deleted file mode 100644 index 158ab2e1..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.xtend +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import com.google.common.collect.Maps | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output | ||
11 | import java.util.Map | ||
12 | |||
13 | import static extension hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions.* | ||
14 | |||
15 | class ComponentInstanceTrace { | ||
16 | val componentInstance = CftFactory.eINSTANCE.createComponent | ||
17 | val Map<InputEvent, InputTrace> inputEventsMap | ||
18 | val Map<EventDeclaration, Output> outputEventsMap | ||
19 | |||
20 | protected new(ComponentFaultTree faultTree, ComponentDefinition componentDefinition, | ||
21 | ComponentNameGenerator nameGenerator, Modality exists, boolean multipleAllowed) { | ||
22 | componentInstance.componentDefinition = componentDefinition | ||
23 | componentInstance.name = nameGenerator.nextName(componentDefinition) | ||
24 | componentInstance.exists = exists | ||
25 | componentInstance.multipleAllowed = multipleAllowed | ||
26 | inputEventsMap = Maps.newHashMapWithExpectedSize(componentDefinition.inputEvents.size) | ||
27 | for (inputEvent : componentDefinition.inputEvents) { | ||
28 | val inputTrace = new InputTrace(componentInstance, inputEvent) | ||
29 | inputEventsMap.put(inputEvent, inputTrace) | ||
30 | } | ||
31 | outputEventsMap = Maps.newHashMapWithExpectedSize(componentDefinition.outputEvents.size) | ||
32 | for (outputEvent : componentDefinition.outputEvents) { | ||
33 | val output = CftFactory.eINSTANCE.createOutput | ||
34 | output.eventDeclaration = outputEvent | ||
35 | componentInstance.outputs += output | ||
36 | outputEventsMap.put(outputEvent, output) | ||
37 | } | ||
38 | faultTree.components += componentInstance | ||
39 | } | ||
40 | |||
41 | def void assign(EventDeclaration inputEvent, ComponentInstanceTrace sourceComponent, EventDeclaration outputEvent) { | ||
42 | assign(inputEvent, sourceComponent, outputEvent, Modality.MUST) | ||
43 | } | ||
44 | |||
45 | def void assign(EventDeclaration inputEvent, ComponentInstanceTrace sourceComponent, EventDeclaration outputEvent, | ||
46 | Modality exists) { | ||
47 | val inputTrace = inputEventsMap.get(inputEvent) | ||
48 | if (inputTrace === null) { | ||
49 | throw new IllegalArgumentException("Unknown input: " + inputEvent) | ||
50 | } | ||
51 | val output = sourceComponent.outputEventsMap.get(outputEvent) | ||
52 | if (output === null) { | ||
53 | throw new IllegalArgumentException("Unknown output: " + outputEvent) | ||
54 | } | ||
55 | inputTrace.assign(output, exists) | ||
56 | } | ||
57 | |||
58 | protected def getOutputs() { | ||
59 | componentInstance.outputs | ||
60 | } | ||
61 | |||
62 | protected def appearsExactlyOnce() { | ||
63 | componentInstance.appearsExactlyOnce | ||
64 | } | ||
65 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend deleted file mode 100644 index 71d40a9b..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.xtend +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | ||
4 | import java.util.Map | ||
5 | |||
6 | class ComponentNameGenerator { | ||
7 | static val DEFAULT_NAME = "__unnamed" | ||
8 | |||
9 | val Map<ComponentDefinition, Integer> instanceCounts = newHashMap | ||
10 | |||
11 | def nextName(ComponentDefinition componentDefinition) { | ||
12 | val instanceCount = instanceCounts.getOrDefault(componentDefinition, 0) | ||
13 | instanceCounts.put(componentDefinition, instanceCount + 1) | ||
14 | (componentDefinition.name ?: DEFAULT_NAME) + instanceCount | ||
15 | } | ||
16 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend deleted file mode 100644 index 062de3df..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.xtend +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition | ||
5 | import java.util.List | ||
6 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
7 | |||
8 | class Ecore2CftTransformation { | ||
9 | val List<MappingHandler> mappingHandlers | ||
10 | |||
11 | new(TransformationDefinition transformationDefinition, ViatraQueryEngine viatraQueryEngine) { | ||
12 | val mappingQueries = new MappingQueries(transformationDefinition, viatraQueryEngine) | ||
13 | mappingHandlers = ImmutableList.copyOf(transformationDefinition.mappingDefinitions.map [ mappingDefinition | | ||
14 | new MappingHandler(mappingDefinition, mappingQueries) | ||
15 | ]) | ||
16 | } | ||
17 | |||
18 | def createComponentFaultTree() { | ||
19 | val trace = new ComponentFaultTreeTrace | ||
20 | for (handler : mappingHandlers) { | ||
21 | handler.instantiateComponents(trace) | ||
22 | } | ||
23 | for (handler : mappingHandlers) { | ||
24 | handler.instantiateConnections(trace) | ||
25 | } | ||
26 | trace.componentFaultTree | ||
27 | } | ||
28 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend deleted file mode 100644 index b892eff1..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.xtend +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output | ||
10 | import java.util.Map | ||
11 | |||
12 | import static extension hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions.* | ||
13 | |||
14 | class InputTrace { | ||
15 | val Input input = CftFactory.eINSTANCE.createInput | ||
16 | val Map<Output, Connection> connectionsMap = newHashMap | ||
17 | |||
18 | protected new(Component component, InputEvent inputEvent) { | ||
19 | input.inputEvent = inputEvent | ||
20 | component.inputs += input | ||
21 | } | ||
22 | |||
23 | def void assign(Output output, Modality exists) { | ||
24 | val connection = connectionsMap.get(output) | ||
25 | if (connection === null) { | ||
26 | val newConnection = CftFactory.eINSTANCE.createConnection | ||
27 | newConnection.output = output | ||
28 | newConnection.exists = exists | ||
29 | input.incomingConnections += newConnection | ||
30 | connectionsMap.put(output, newConnection) | ||
31 | } else if (exists.isMoreConcreteThan(connection.exists)) { | ||
32 | connection.exists = exists | ||
33 | } | ||
34 | } | ||
35 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend deleted file mode 100644 index 3a06dcc3..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.xtend +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition | ||
5 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
6 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
7 | |||
8 | class LookupHandler { | ||
9 | val int[] argumentIndices | ||
10 | val ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher | ||
11 | |||
12 | new(MappingDefinition mappingDefinition, LookupDefinition lookupDefinition, | ||
13 | ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher) { | ||
14 | if (lookupDefinition.eContainer != mappingDefinition) { | ||
15 | throw new IllegalArgumentException("lookupDefinition must be contained in mappingDefinition") | ||
16 | } | ||
17 | val argumentCount = lookupDefinition.arguments.size | ||
18 | if (argumentCount != lookedUpMatcher.parameterNames.length) { | ||
19 | throw new IllegalArgumentException( | ||
20 | "lookupDefinition (name: " + lookupDefinition.mapping?.pattern?.name + | ||
21 | ") must have as many arguments as lookedUpMatcher (name: " + lookedUpMatcher.patternName + ")") | ||
22 | } | ||
23 | argumentIndices = newIntArrayOfSize(argumentCount) | ||
24 | for (var int i = 0; i < argumentCount; i++) { | ||
25 | val argument = lookupDefinition.arguments.get(i) | ||
26 | val argumentIndex = mappingDefinition.parameters.indexOf(argument) | ||
27 | argumentIndices.set(i, argumentIndex) | ||
28 | } | ||
29 | this.lookedUpMatcher = lookedUpMatcher | ||
30 | } | ||
31 | |||
32 | def lookupForMatch(ComponentFaultTreeTrace faultTreeTrace, IPatternMatch match) { | ||
33 | val lookedUpMatch = createLookedUpMatch(match) | ||
34 | faultTreeTrace.lookup(lookedUpMatch) | ||
35 | } | ||
36 | |||
37 | private def createLookedUpMatch(IPatternMatch match) { | ||
38 | val lookedUpMatch = lookedUpMatcher.newEmptyMatch | ||
39 | val argumentCount = argumentIndices.length | ||
40 | for (var int i = 0; i < argumentCount; i++) { | ||
41 | val argumentIndex = argumentIndices.get(i) | ||
42 | var argumentValue = match.get(argumentIndex) | ||
43 | lookedUpMatch.set(i, argumentValue) | ||
44 | } | ||
45 | lookedUpMatch | ||
46 | } | ||
47 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend deleted file mode 100644 index 643af5c4..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.xtend +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap | ||
4 | import com.google.common.collect.Maps | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable | ||
8 | import java.util.Map | ||
9 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
10 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
11 | |||
12 | class MappingHandler { | ||
13 | val ViatraQueryMatcher<? extends IPatternMatch> matcher | ||
14 | val MappingDefinition mappingDefinition | ||
15 | val Map<LookupDefinition, LookupHandler> lookupHandlers | ||
16 | |||
17 | new(MappingDefinition mappingDefinition, MappingQueries mappingQueries) { | ||
18 | matcher = mappingQueries.getMatcher(mappingDefinition) | ||
19 | this.mappingDefinition = mappingDefinition | ||
20 | val variables = newHashSet | ||
21 | for (assignment : mappingDefinition.assignments) { | ||
22 | variables += assignment.input.component | ||
23 | variables += assignment.output.component | ||
24 | } | ||
25 | lookupHandlers = ImmutableMap.copyOf(variables.filter(LookupDefinition).toMap([it], [ lookupDefinition | | ||
26 | mappingQueries.createLookupHandler(mappingDefinition, lookupDefinition) | ||
27 | ])) | ||
28 | } | ||
29 | |||
30 | def instantiateComponents(ComponentFaultTreeTrace faultTreeTrace) { | ||
31 | if (!hasComponentInstace) { | ||
32 | return | ||
33 | } | ||
34 | matcher.forEachMatch [ match | | ||
35 | val componentTrace = faultTreeTrace.instantiateComponent(match, componentDefinition) | ||
36 | if (isTopLevel) { | ||
37 | faultTreeTrace.topLevel = componentTrace | ||
38 | } | ||
39 | ] | ||
40 | } | ||
41 | |||
42 | def instantiateConnections(ComponentFaultTreeTrace faultTreeTrace) { | ||
43 | if (!hasConnections) { | ||
44 | return | ||
45 | } | ||
46 | matcher.forEachMatch [ match | | ||
47 | val lookedUpComponents = lookupComponents(faultTreeTrace, match) | ||
48 | for (assignment : mappingDefinition.assignments) { | ||
49 | val input = assignment.input | ||
50 | val inputComponent = lookedUpComponents.get(input.component) | ||
51 | val output = assignment.output | ||
52 | val outputComponent = lookedUpComponents.get(output.component) | ||
53 | if (inputComponent !== null && outputComponent !== null) { | ||
54 | inputComponent.assign(input.event, outputComponent, output.event) | ||
55 | } | ||
56 | } | ||
57 | ] | ||
58 | } | ||
59 | |||
60 | private def Map<Variable, ComponentInstanceTrace> lookupComponents(ComponentFaultTreeTrace faultTreeTrace, | ||
61 | IPatternMatch match) { | ||
62 | val lookedUpComponents = Maps.newHashMapWithExpectedSize(lookupHandlers.size + 1) | ||
63 | if (hasComponentInstace) { | ||
64 | val componentInstance = faultTreeTrace.lookup(match) | ||
65 | lookedUpComponents.put(mappingDefinition.componentInstance, componentInstance) | ||
66 | } | ||
67 | for (pair : lookupHandlers.entrySet) { | ||
68 | val componentInstance = pair.value.lookupForMatch(faultTreeTrace, match) | ||
69 | if (componentInstance !== null) { | ||
70 | lookedUpComponents.put(pair.key, componentInstance) | ||
71 | } | ||
72 | } | ||
73 | lookedUpComponents | ||
74 | } | ||
75 | |||
76 | private def getComponentDefinition() { | ||
77 | mappingDefinition.componentInstance?.componentType | ||
78 | } | ||
79 | |||
80 | private def hasComponentInstace() { | ||
81 | componentDefinition !== null | ||
82 | } | ||
83 | |||
84 | private def isTopLevel() { | ||
85 | mappingDefinition.topLevel | ||
86 | } | ||
87 | |||
88 | private def hasConnections() { | ||
89 | !mappingDefinition.assignments.empty | ||
90 | } | ||
91 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend deleted file mode 100644 index 6683b3f8..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.xtend +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition | ||
7 | import java.util.Map | ||
8 | import org.eclipse.viatra.query.patternlanguage.emf.specification.SpecificationBuilder | ||
9 | import org.eclipse.viatra.query.runtime.api.GenericQueryGroup | ||
10 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
11 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
12 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
13 | |||
14 | class MappingQueries { | ||
15 | val Map<MappingDefinition, ViatraQueryMatcher<? extends IPatternMatch>> matchersMap | ||
16 | |||
17 | new(TransformationDefinition transformationDefinition, ViatraQueryEngine viatraQueryEngine) { | ||
18 | val specificationBuilder = new SpecificationBuilder | ||
19 | val querySpecificationsMap = transformationDefinition.mappingDefinitions.toMap([it], [ | ||
20 | specificationBuilder.getOrCreateSpecification(pattern) | ||
21 | ]) | ||
22 | GenericQueryGroup.of(querySpecificationsMap.values).prepare(viatraQueryEngine) | ||
23 | matchersMap = ImmutableMap.copyOf(querySpecificationsMap.mapValues[getMatcher(viatraQueryEngine)]) | ||
24 | } | ||
25 | |||
26 | def getMatcher(MappingDefinition mappingDefinition) { | ||
27 | val matcher = matchersMap.get(mappingDefinition) | ||
28 | if (matcher === null) { | ||
29 | throw new IllegalArgumentException("Unknown mapping definition: " + mappingDefinition) | ||
30 | } | ||
31 | matcher | ||
32 | } | ||
33 | |||
34 | def createLookupHandler(MappingDefinition mappingDefinition, LookupDefinition lookupDefinition) { | ||
35 | val lookedUpMatcher = getMatcher(lookupDefinition.mapping) | ||
36 | new LookupHandler(mappingDefinition, lookupDefinition, lookedUpMatcher) | ||
37 | } | ||
38 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend deleted file mode 100644 index 4a19e2cd..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.xtend +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.AndGate | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.BasicEvent | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantDistribution | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Distribution | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ExponentialDistribution | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.KOfMGate | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.OrGate | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent | ||
13 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
14 | |||
15 | class Ft2GalileoTransformation { | ||
16 | def toGalileo(FaultTree faultTree) ''' | ||
17 | toplevel "«faultTree.topEvent.name»"; | ||
18 | «FOR event : faultTree.events» | ||
19 | "«event.name»" «defineEvent(event)»; | ||
20 | «ENDFOR» | ||
21 | ''' | ||
22 | |||
23 | protected dispatch def defineEvent(BasicEvent basicEvent) { | ||
24 | // ft-diet (https://moves.rwth-aachen.de/ft-diet/) needs a dormancy factor. | ||
25 | '''«defineDistribution(basicEvent.distribution)» dorm=0.0''' | ||
26 | } | ||
27 | |||
28 | protected dispatch def StringConcatenationClient defineDistribution(ConstantDistribution distribution) { | ||
29 | '''p=«distribution.p»''' | ||
30 | } | ||
31 | |||
32 | protected dispatch def StringConcatenationClient defineDistribution(ExponentialDistribution distribution) { | ||
33 | '''lambda=«distribution.lambda»''' | ||
34 | } | ||
35 | |||
36 | protected dispatch def StringConcatenationClient defineDistribution(Distribution distribution) { | ||
37 | throw new IllegalArgumentException("Unknown distribution: " + distribution) | ||
38 | } | ||
39 | |||
40 | protected dispatch def StringConcatenationClient defineEvent(Gate gate) { | ||
41 | '''«defineGate(gate)» «FOR input : gate.inputEvents SEPARATOR " "»"«input.name»"«ENDFOR»''' | ||
42 | } | ||
43 | |||
44 | protected dispatch def StringConcatenationClient defineGate(AndGate gate) '''and''' | ||
45 | |||
46 | protected dispatch def StringConcatenationClient defineGate(OrGate gate) '''or''' | ||
47 | |||
48 | protected dispatch def StringConcatenationClient defineGate(KOfMGate gate) '''«gate.k»of«gate.inputEvents.size»''' | ||
49 | |||
50 | protected dispatch def StringConcatenationClient defineGate(Gate gate) { | ||
51 | throw new IllegalArgumentException("Unknown gate: " + gate) | ||
52 | } | ||
53 | |||
54 | protected dispatch def StringConcatenationClient defineEvent(RandomEvent randomEvent) { | ||
55 | throw new IllegalArgumentException("Unknown random even: " + randomEvent) | ||
56 | } | ||
57 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ReliabilityResult.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ReliabilityResult.xtend deleted file mode 100644 index 19c3d17d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ReliabilityResult.xtend +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver | ||
2 | |||
3 | import org.eclipse.xtend.lib.annotations.Data | ||
4 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
5 | |||
6 | abstract class ReliabilityResult { | ||
7 | public static val TIMEOUT = new Unknown("Solver timed out") | ||
8 | public static val MEMOUT = new Unknown("Solver out of memory") | ||
9 | |||
10 | abstract def Solution getOrThrow() | ||
11 | |||
12 | @Data | ||
13 | static final class Solution extends ReliabilityResult { | ||
14 | val double lowerBound | ||
15 | val double upperBound | ||
16 | |||
17 | new(double value) { | ||
18 | this(value, value) | ||
19 | } | ||
20 | |||
21 | new(double lowerBound, double upperBound) { | ||
22 | if (lowerBound > upperBound) { | ||
23 | throw new IllegalArgumentException("lowerBound must not be larger than upperBound") | ||
24 | } | ||
25 | this.lowerBound = lowerBound | ||
26 | this.upperBound = upperBound | ||
27 | } | ||
28 | |||
29 | override getOrThrow() { | ||
30 | this | ||
31 | } | ||
32 | } | ||
33 | |||
34 | @Data | ||
35 | static final class Unknown extends ReliabilityResult { | ||
36 | val String message | ||
37 | val Throwable cause | ||
38 | |||
39 | @FinalFieldsConstructor | ||
40 | new() { | ||
41 | } | ||
42 | |||
43 | new(String message) { | ||
44 | this(message, null) | ||
45 | } | ||
46 | |||
47 | override getOrThrow() { | ||
48 | throw new RuntimeException(message, cause) | ||
49 | } | ||
50 | } | ||
51 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftConfiguration.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftConfiguration.xtend deleted file mode 100644 index d9059bfc..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftConfiguration.xtend +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolverConfiguration | ||
4 | |||
5 | final class StormDftConfiguration extends SolverConfiguration { | ||
6 | public static val DEFAULT_SOLVER_PATH = "storm-dft" | ||
7 | |||
8 | public double precision = 1e-6 | ||
9 | |||
10 | public boolean bisimulation = true | ||
11 | |||
12 | public boolean symmetryReduction = true | ||
13 | |||
14 | public boolean modularization = true | ||
15 | |||
16 | public boolean dontCarePropagation = true | ||
17 | |||
18 | public double approximation = 0 | ||
19 | |||
20 | public var approximationHeuristic = ApproximationHeuristic.NONE | ||
21 | |||
22 | public FtAnalysisObjective objective | ||
23 | |||
24 | def isApproximationInUse() { | ||
25 | approximationHeuristic != ApproximationHeuristic.NONE | ||
26 | } | ||
27 | } | ||
28 | |||
29 | abstract class FtAnalysisObjective { | ||
30 | public static val MTTF = new FtAnalysisObjective { | ||
31 | } | ||
32 | |||
33 | private new() { | ||
34 | } | ||
35 | |||
36 | static final class TimeBound extends FtAnalysisObjective { | ||
37 | public double timeBound = 0 | ||
38 | } | ||
39 | } | ||
40 | |||
41 | enum ApproximationHeuristic { | ||
42 | NONE, | ||
43 | DEPTH | ||
44 | // See https://github.com/moves-rwth/storm/issues/35 for additional approximation heuristics. | ||
45 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend deleted file mode 100644 index a250a955..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.xtend +++ /dev/null | |||
@@ -1,182 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolverConfiguration | ||
6 | import java.io.BufferedReader | ||
7 | import java.io.IOException | ||
8 | import java.io.InputStream | ||
9 | import java.io.InputStreamReader | ||
10 | import java.util.regex.Pattern | ||
11 | |||
12 | class StormDftException extends RuntimeException { | ||
13 | new(String s) { | ||
14 | super(s) | ||
15 | } | ||
16 | |||
17 | new(String s, Exception e) { | ||
18 | super(s, e) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | class StormDftHandler { | ||
23 | static val DOUBLE_REGEX = "[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" | ||
24 | static val SINGLE_RESULT_GROUP = "single" | ||
25 | static val LOWER_BOUND_GROUP = "lower" | ||
26 | static val UPPER_BOUND_GROUP = "upper" | ||
27 | static val RESULT_REGEX = '''^Result:\s*\[(?:(?<«SINGLE_RESULT_GROUP»>«DOUBLE_REGEX»)|\((?<«LOWER_BOUND_GROUP»>«DOUBLE_REGEX»),\s*(?<«UPPER_BOUND_GROUP»>«DOUBLE_REGEX»)\))\]''' | ||
28 | static val RESULT_PATTERN = Pattern.compile(RESULT_REGEX) | ||
29 | |||
30 | static val SIGNAL_EXIT_VALUE_OFFSET = 0x80 | ||
31 | static val SIGXCPU = 24 | ||
32 | static val SIGXFSZ = 25 | ||
33 | |||
34 | static val STORM_GENERAL_ERROR = (-1).bitwiseAnd(0xff) | ||
35 | static val STORM_TIMEOUT = (-2).bitwiseAnd(0xff) | ||
36 | static val STORM_MEMOUT = (-3).bitwiseAnd(0xff) | ||
37 | |||
38 | def callSolver(String dftFilePath, StormDftConfiguration configuration) { | ||
39 | val commandLine = configuration.toCommandLine(dftFilePath) | ||
40 | val documentationLevel = configuration.documentationLevel | ||
41 | val printOutput = documentationLevel == DocumentationLevel.NORMAL || | ||
42 | documentationLevel == DocumentationLevel.FULL | ||
43 | val processBuilder = new ProcessBuilder().command(commandLine) | ||
44 | var Process process = null | ||
45 | try { | ||
46 | try { | ||
47 | process = processBuilder.start | ||
48 | process.outputStream.close | ||
49 | val result = readOutput(process.inputStream, printOutput) | ||
50 | val error = readError(process.errorStream, printOutput) | ||
51 | val exitValue = process.waitFor | ||
52 | if (result === null) { | ||
53 | interpretExitStatus(exitValue, error) | ||
54 | } else { | ||
55 | result | ||
56 | } | ||
57 | } catch (IOException e) { | ||
58 | throw new StormDftException("Error during input/output handling of the stochastic solver.", e) | ||
59 | } | ||
60 | } catch (Exception e) { | ||
61 | if (process !== null) { | ||
62 | process.destroyForcibly.waitFor | ||
63 | } | ||
64 | throw e | ||
65 | } | ||
66 | } | ||
67 | |||
68 | private def toCommandLine(extension StormDftConfiguration configuration, String dftFilePath) { | ||
69 | extension val optionsBuilder = ImmutableList.builder | ||
70 | add(solverPath ?: StormDftConfiguration.DEFAULT_SOLVER_PATH) | ||
71 | if (runtimeLimit != SolverConfiguration.Unlimited) { | ||
72 | add("--timeout", runtimeLimit.toString) | ||
73 | } | ||
74 | add("--precision", precision.toString) | ||
75 | if (bisimulation) { | ||
76 | add("--bisimulation") | ||
77 | } | ||
78 | if (symmetryReduction) { | ||
79 | add("--symmetryreduction") | ||
80 | } | ||
81 | if (modularization) { | ||
82 | add("--modularisation") | ||
83 | } | ||
84 | if (!dontCarePropagation) { | ||
85 | add("--disabledc") | ||
86 | } | ||
87 | if (approximationInUse) { | ||
88 | val heuristicName = switch (approximationHeuristic) { | ||
89 | case DEPTH: | ||
90 | "depth" | ||
91 | default: | ||
92 | throw new IllegalArgumentException("Unknown approximation heuristic: " + approximationHeuristic) | ||
93 | } | ||
94 | add("--approximation", approximation.toString, "--approximationheuristic", heuristicName) | ||
95 | } | ||
96 | add("--dftfile", dftFilePath) | ||
97 | switch (objective) { | ||
98 | case FtAnalysisObjective.MTTF: | ||
99 | add("--expectedtime") | ||
100 | FtAnalysisObjective.TimeBound: | ||
101 | add("--timebound") | ||
102 | default: | ||
103 | throw new IllegalArgumentException("Unknown analysis objective: " + objective) | ||
104 | } | ||
105 | if (documentationLevel == DocumentationLevel.FULL) { | ||
106 | add("--verbose") | ||
107 | } | ||
108 | build | ||
109 | } | ||
110 | |||
111 | private def readOutput(InputStream inputStream, boolean printOutput) { | ||
112 | val bufferedReader = new BufferedReader(new InputStreamReader(inputStream)) | ||
113 | try { | ||
114 | var String line | ||
115 | while ((line = bufferedReader.readLine) !== null) { | ||
116 | if (printOutput) { | ||
117 | println(line) | ||
118 | } | ||
119 | val matcher = RESULT_PATTERN.matcher(line) | ||
120 | if (matcher.find) { | ||
121 | try { | ||
122 | val single = matcher.group(SINGLE_RESULT_GROUP) | ||
123 | if (single !== null) { | ||
124 | val singleValue = Double.parseDouble(single) | ||
125 | return new ReliabilityResult.Solution(singleValue) | ||
126 | } | ||
127 | val lower = matcher.group(LOWER_BOUND_GROUP) | ||
128 | val upper = matcher.group(UPPER_BOUND_GROUP) | ||
129 | if (lower !== null && upper !== null) { | ||
130 | val lowerValue = Double.parseDouble(lower) | ||
131 | val upperValue = Double.parseDouble(upper) | ||
132 | return new ReliabilityResult.Solution(lowerValue, upperValue) | ||
133 | } | ||
134 | throw new StormDftException("Inconsistent stochastic solver output: " + line) | ||
135 | } catch (NumberFormatException e) { | ||
136 | throw new StormDftException("Malformatted number from stochastic solver.", e) | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } finally { | ||
141 | bufferedReader.close | ||
142 | } | ||
143 | null | ||
144 | } | ||
145 | |||
146 | private def readError(InputStream inputStream, boolean printOutput) { | ||
147 | val bufferedReader = new BufferedReader(new InputStreamReader(inputStream)) | ||
148 | try { | ||
149 | val lines = newArrayList | ||
150 | var String line | ||
151 | while ((line = bufferedReader.readLine) !== null) { | ||
152 | if (printOutput) { | ||
153 | System.err.println(line) | ||
154 | } | ||
155 | lines += line | ||
156 | } | ||
157 | lines.join("\n") | ||
158 | } finally { | ||
159 | bufferedReader.close | ||
160 | } | ||
161 | } | ||
162 | |||
163 | private def interpretExitStatus(int exitValue, String error) { | ||
164 | switch (exitValue) { | ||
165 | case STORM_GENERAL_ERROR: | ||
166 | throw new StormDftException("Storm error: " + error) | ||
167 | case STORM_TIMEOUT, | ||
168 | case SIGNAL_EXIT_VALUE_OFFSET + SIGXCPU: | ||
169 | ReliabilityResult.TIMEOUT | ||
170 | case STORM_MEMOUT, | ||
171 | case SIGNAL_EXIT_VALUE_OFFSET + SIGXFSZ: | ||
172 | ReliabilityResult.MEMOUT | ||
173 | default: { | ||
174 | if (exitValue > SIGNAL_EXIT_VALUE_OFFSET) { | ||
175 | val signalNumber = exitValue - SIGNAL_EXIT_VALUE_OFFSET | ||
176 | throw new StormDftException("Storm unexpectedly killed by signal " + signalNumber + ": " + error) | ||
177 | } | ||
178 | throw new StormDftException("Storm unexpectedly exit with status " + exitValue + ": " + error) | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftSolver.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftSolver.xtend deleted file mode 100644 index 931b9f39..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftSolver.xtend +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantModel | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ReliabilityModel | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo.Ft2GalileoTransformation | ||
7 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | ||
8 | |||
9 | class StormDftSolver { | ||
10 | static val DFT_FILE_NAME = "ft.dft" | ||
11 | |||
12 | val ft2Galileo = new Ft2GalileoTransformation | ||
13 | val handler = new StormDftHandler | ||
14 | |||
15 | def solve(ReliabilityModel reliabilityModel, StormDftConfiguration configuration, | ||
16 | ReasonerWorkspace reasonerWorkspace) { | ||
17 | switch (reliabilityModel) { | ||
18 | FaultTree: | ||
19 | solve(reliabilityModel, configuration, reasonerWorkspace) | ||
20 | ConstantModel: { | ||
21 | val result = if (reliabilityModel.failed) { | ||
22 | 0 | ||
23 | } else { | ||
24 | switch (objective : configuration.objective) { | ||
25 | case FtAnalysisObjective.MTTF: Double.POSITIVE_INFINITY | ||
26 | FtAnalysisObjective.TimeBound: 1 | ||
27 | default: throw new IllegalArgumentException("Unknown objective: " + objective) | ||
28 | } | ||
29 | } | ||
30 | new ReliabilityResult.Solution(result) | ||
31 | } | ||
32 | default: | ||
33 | throw new IllegalArgumentException("Unknown reliability model: " + reliabilityModel) | ||
34 | } | ||
35 | } | ||
36 | |||
37 | def solve(FaultTree faultTree, StormDftConfiguration configuration, ReasonerWorkspace reasonerWorkspace) { | ||
38 | val galileo = ft2Galileo.toGalileo(faultTree) | ||
39 | reasonerWorkspace.writeText(DFT_FILE_NAME, galileo) | ||
40 | val dftFilePath = reasonerWorkspace.getFile(DFT_FILE_NAME).absolutePath | ||
41 | handler.callSolver(dftFilePath, configuration) | ||
42 | } | ||
43 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore deleted file mode 100644 index 49df59a2..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/.gitignore +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | /.CftTransformation.java._trace | ||
2 | /.ComponentFaultTreeTrace.java._trace | ||
3 | /.ComponentInstanceTrace.java._trace | ||
4 | /.InputTrace.java._trace | ||
5 | /.MappingHandler.java._trace | ||
6 | /.ComponentInstantiationHandler.java._trace | ||
7 | /.MappingQueries.java._trace | ||
8 | /.LookupHandler.java._trace | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin deleted file mode 100644 index dfae40e9..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.Cft2FtTransformation.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventCollection.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventCollection.xtendbin deleted file mode 100644 index 0aaf712d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventCollection.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventMaterializer.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventMaterializer.xtendbin deleted file mode 100644 index e51f73a6..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.EventMaterializer.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.FaultTreeBuilder.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.FaultTreeBuilder.xtendbin deleted file mode 100644 index 89e003dc..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.FaultTreeBuilder.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore deleted file mode 100644 index 058cff19..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/.gitignore +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /.Cft2FtTransformation.java._trace | ||
2 | /.EventMaterializer.java._trace | ||
3 | /.MaterializedEvent.java._trace | ||
4 | /.CollectedInputs.java._trace | ||
5 | /.MaterializedEventCollection.java._trace | ||
6 | /.FaultTreeBuilder.java._trace | ||
7 | /.FaultModelBuilder.java._trace | ||
8 | /.EventCollection.java._trace | ||
9 | /.Cft2FtTransformation.xtendbin | ||
10 | /.EventCollection.xtendbin | ||
11 | /.EventMaterializer.xtendbin | ||
12 | /.FaultTreeBuilder.xtendbin | ||
13 | /Cft2FtTransformation.java | ||
14 | /EventCollection.java | ||
15 | /EventMaterializer.java | ||
16 | /FaultTreeBuilder.java | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java deleted file mode 100644 index e87b8865..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/Cft2FtTransformation.java +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantModel; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ReliabilityModel; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft.EventMaterializer; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft.FaultTreeBuilder; | ||
13 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
14 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
15 | |||
16 | @SuppressWarnings("all") | ||
17 | public class Cft2FtTransformation { | ||
18 | public ReliabilityModel createFaultTree(final ComponentFaultTree componentFaultTree) { | ||
19 | ReliabilityModel _xblockexpression = null; | ||
20 | { | ||
21 | final EventMaterializer materializer = new EventMaterializer(); | ||
22 | final Event topEvent = materializer.getOrMaterialize(componentFaultTree.getTopEvent()); | ||
23 | ReliabilityModel _switchResult = null; | ||
24 | boolean _matched = false; | ||
25 | if (topEvent instanceof ConstantEvent) { | ||
26 | _matched=true; | ||
27 | ConstantModel _createConstantModel = FtFactory.eINSTANCE.createConstantModel(); | ||
28 | final Procedure1<ConstantModel> _function = (ConstantModel it) -> { | ||
29 | it.setFailed(((ConstantEvent)topEvent).isFailed()); | ||
30 | }; | ||
31 | _switchResult = ObjectExtensions.<ConstantModel>operator_doubleArrow(_createConstantModel, _function); | ||
32 | } | ||
33 | if (!_matched) { | ||
34 | if (topEvent instanceof RandomEvent) { | ||
35 | _matched=true; | ||
36 | FaultTree _xblockexpression_1 = null; | ||
37 | { | ||
38 | final FaultTreeBuilder builder = new FaultTreeBuilder(); | ||
39 | builder.addTopLevel(((RandomEvent)topEvent)); | ||
40 | _xblockexpression_1 = builder.getFaultTree(); | ||
41 | } | ||
42 | _switchResult = _xblockexpression_1; | ||
43 | } | ||
44 | } | ||
45 | _xblockexpression = _switchResult; | ||
46 | } | ||
47 | return _xblockexpression; | ||
48 | } | ||
49 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.java deleted file mode 100644 index dceef9f8..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventCollection.java +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableSet; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
7 | import java.util.Set; | ||
8 | import org.eclipse.xtend.lib.annotations.Data; | ||
9 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
10 | import org.eclipse.xtext.xbase.lib.Pure; | ||
11 | import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; | ||
12 | |||
13 | @Data | ||
14 | @SuppressWarnings("all") | ||
15 | public class EventCollection { | ||
16 | public static class Builder { | ||
17 | private int falseEventCount = 0; | ||
18 | |||
19 | private int trueEventCount = 0; | ||
20 | |||
21 | private final ImmutableSet.Builder<RandomEvent> randomEventsBuilder = ImmutableSet.<RandomEvent>builder(); | ||
22 | |||
23 | private Builder() { | ||
24 | } | ||
25 | |||
26 | public EventCollection.Builder add(final Event event) { | ||
27 | EventCollection.Builder _xblockexpression = null; | ||
28 | { | ||
29 | boolean _matched = false; | ||
30 | if (event instanceof ConstantEvent) { | ||
31 | _matched=true; | ||
32 | boolean _isFailed = ((ConstantEvent)event).isFailed(); | ||
33 | if (_isFailed) { | ||
34 | this.trueEventCount++; | ||
35 | } else { | ||
36 | this.falseEventCount++; | ||
37 | } | ||
38 | } | ||
39 | if (!_matched) { | ||
40 | if (event instanceof RandomEvent) { | ||
41 | _matched=true; | ||
42 | this.randomEventsBuilder.add(((RandomEvent)event)); | ||
43 | } | ||
44 | } | ||
45 | if (!_matched) { | ||
46 | throw new IllegalArgumentException(("Unknown event: " + event)); | ||
47 | } | ||
48 | _xblockexpression = this; | ||
49 | } | ||
50 | return _xblockexpression; | ||
51 | } | ||
52 | |||
53 | public EventCollection.Builder addAll(final EventCollection materializedEvens) { | ||
54 | EventCollection.Builder _xblockexpression = null; | ||
55 | { | ||
56 | int _falseEventCount = this.falseEventCount; | ||
57 | this.falseEventCount = (_falseEventCount + materializedEvens.falseEventCount); | ||
58 | int _trueEventCount = this.trueEventCount; | ||
59 | this.trueEventCount = (_trueEventCount + materializedEvens.trueEventCount); | ||
60 | this.randomEventsBuilder.addAll(materializedEvens.randomEvents); | ||
61 | _xblockexpression = this; | ||
62 | } | ||
63 | return _xblockexpression; | ||
64 | } | ||
65 | |||
66 | public EventCollection build() { | ||
67 | ImmutableSet<RandomEvent> _build = this.randomEventsBuilder.build(); | ||
68 | return new EventCollection(this.falseEventCount, this.trueEventCount, _build); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | private final int falseEventCount; | ||
73 | |||
74 | private final int trueEventCount; | ||
75 | |||
76 | private final Set<RandomEvent> randomEvents; | ||
77 | |||
78 | public boolean containsFalseEvent() { | ||
79 | return (this.falseEventCount >= 1); | ||
80 | } | ||
81 | |||
82 | public boolean containsTrueEvent() { | ||
83 | return (this.trueEventCount >= 1); | ||
84 | } | ||
85 | |||
86 | public int getVariableEventCount() { | ||
87 | return this.randomEvents.size(); | ||
88 | } | ||
89 | |||
90 | public boolean containsRandomEvent() { | ||
91 | int _variableEventCount = this.getVariableEventCount(); | ||
92 | return (_variableEventCount >= 1); | ||
93 | } | ||
94 | |||
95 | public int getCount() { | ||
96 | int _variableEventCount = this.getVariableEventCount(); | ||
97 | return ((this.falseEventCount + this.trueEventCount) + _variableEventCount); | ||
98 | } | ||
99 | |||
100 | public boolean isEmpty() { | ||
101 | return (((!this.containsFalseEvent()) && (!this.containsTrueEvent())) && (!this.containsRandomEvent())); | ||
102 | } | ||
103 | |||
104 | public boolean containsExactlyOneRandomEvent() { | ||
105 | return (((!this.containsFalseEvent()) && (!this.containsTrueEvent())) && (this.getVariableEventCount() == 1)); | ||
106 | } | ||
107 | |||
108 | public RandomEvent toSingleRandomEvent() { | ||
109 | RandomEvent _xblockexpression = null; | ||
110 | { | ||
111 | boolean _containsExactlyOneRandomEvent = this.containsExactlyOneRandomEvent(); | ||
112 | boolean _not = (!_containsExactlyOneRandomEvent); | ||
113 | if (_not) { | ||
114 | throw new IllegalStateException("Input collection is not a single random event"); | ||
115 | } | ||
116 | _xblockexpression = IterableExtensions.<RandomEvent>head(this.randomEvents); | ||
117 | } | ||
118 | return _xblockexpression; | ||
119 | } | ||
120 | |||
121 | public static EventCollection.Builder builder() { | ||
122 | return new EventCollection.Builder(); | ||
123 | } | ||
124 | |||
125 | public EventCollection(final int falseEventCount, final int trueEventCount, final Set<RandomEvent> randomEvents) { | ||
126 | super(); | ||
127 | this.falseEventCount = falseEventCount; | ||
128 | this.trueEventCount = trueEventCount; | ||
129 | this.randomEvents = randomEvents; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | @Pure | ||
134 | public int hashCode() { | ||
135 | final int prime = 31; | ||
136 | int result = 1; | ||
137 | result = prime * result + this.falseEventCount; | ||
138 | result = prime * result + this.trueEventCount; | ||
139 | return prime * result + ((this.randomEvents== null) ? 0 : this.randomEvents.hashCode()); | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | @Pure | ||
144 | public boolean equals(final Object obj) { | ||
145 | if (this == obj) | ||
146 | return true; | ||
147 | if (obj == null) | ||
148 | return false; | ||
149 | if (getClass() != obj.getClass()) | ||
150 | return false; | ||
151 | EventCollection other = (EventCollection) obj; | ||
152 | if (other.falseEventCount != this.falseEventCount) | ||
153 | return false; | ||
154 | if (other.trueEventCount != this.trueEventCount) | ||
155 | return false; | ||
156 | if (this.randomEvents == null) { | ||
157 | if (other.randomEvents != null) | ||
158 | return false; | ||
159 | } else if (!this.randomEvents.equals(other.randomEvents)) | ||
160 | return false; | ||
161 | return true; | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | @Pure | ||
166 | public String toString() { | ||
167 | ToStringBuilder b = new ToStringBuilder(this); | ||
168 | b.add("falseEventCount", this.falseEventCount); | ||
169 | b.add("trueEventCount", this.trueEventCount); | ||
170 | b.add("randomEvents", this.randomEvents); | ||
171 | return b.toString(); | ||
172 | } | ||
173 | |||
174 | @Pure | ||
175 | public int getFalseEventCount() { | ||
176 | return this.falseEventCount; | ||
177 | } | ||
178 | |||
179 | @Pure | ||
180 | public int getTrueEventCount() { | ||
181 | return this.trueEventCount; | ||
182 | } | ||
183 | |||
184 | @Pure | ||
185 | public Set<RandomEvent> getRandomEvents() { | ||
186 | return this.randomEvents; | ||
187 | } | ||
188 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.java deleted file mode 100644 index 98a82b7d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.java +++ /dev/null | |||
@@ -1,469 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.AndGateDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.BasicEventDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.GateDefinition; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.KOfMGateDefinition; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.OrGateDefinition; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.AndGate; | ||
16 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.BasicEvent; | ||
17 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantEvent; | ||
18 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Distribution; | ||
19 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Event; | ||
20 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory; | ||
21 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate; | ||
22 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.KOfMGate; | ||
23 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.OrGate; | ||
24 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
25 | import hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions; | ||
26 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft.EventCollection; | ||
27 | import java.util.LinkedHashSet; | ||
28 | import java.util.Map; | ||
29 | import org.eclipse.emf.common.util.EList; | ||
30 | import org.eclipse.emf.ecore.util.EcoreUtil; | ||
31 | import org.eclipse.xtend.lib.annotations.Data; | ||
32 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
33 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
34 | import org.eclipse.xtext.xbase.lib.Extension; | ||
35 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
36 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
37 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
38 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
39 | import org.eclipse.xtext.xbase.lib.Pure; | ||
40 | |||
41 | @SuppressWarnings("all") | ||
42 | public class EventMaterializer { | ||
43 | @Data | ||
44 | protected static class EventKey<T extends EventDeclaration> { | ||
45 | private final Component component; | ||
46 | |||
47 | private final T event; | ||
48 | |||
49 | @Override | ||
50 | public String toString() { | ||
51 | StringConcatenation _builder = new StringConcatenation(); | ||
52 | String _name = this.component.getName(); | ||
53 | _builder.append(_name); | ||
54 | _builder.append("_"); | ||
55 | String _name_1 = this.event.getName(); | ||
56 | _builder.append(_name_1); | ||
57 | return _builder.toString(); | ||
58 | } | ||
59 | |||
60 | public EventKey(final Component component, final T event) { | ||
61 | super(); | ||
62 | this.component = component; | ||
63 | this.event = event; | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | @Pure | ||
68 | public int hashCode() { | ||
69 | final int prime = 31; | ||
70 | int result = 1; | ||
71 | result = prime * result + ((this.component== null) ? 0 : this.component.hashCode()); | ||
72 | return prime * result + ((this.event== null) ? 0 : this.event.hashCode()); | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | @Pure | ||
77 | public boolean equals(final Object obj) { | ||
78 | if (this == obj) | ||
79 | return true; | ||
80 | if (obj == null) | ||
81 | return false; | ||
82 | if (getClass() != obj.getClass()) | ||
83 | return false; | ||
84 | EventMaterializer.EventKey<?> other = (EventMaterializer.EventKey<?>) obj; | ||
85 | if (this.component == null) { | ||
86 | if (other.component != null) | ||
87 | return false; | ||
88 | } else if (!this.component.equals(other.component)) | ||
89 | return false; | ||
90 | if (this.event == null) { | ||
91 | if (other.event != null) | ||
92 | return false; | ||
93 | } else if (!this.event.equals(other.event)) | ||
94 | return false; | ||
95 | return true; | ||
96 | } | ||
97 | |||
98 | @Pure | ||
99 | public Component getComponent() { | ||
100 | return this.component; | ||
101 | } | ||
102 | |||
103 | @Pure | ||
104 | public T getEvent() { | ||
105 | return this.event; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | @Extension | ||
110 | private final FtFactory _ftFactory = FtFactory.eINSTANCE; | ||
111 | |||
112 | private final Map<EventMaterializer.EventKey<EventDeclaration>, Event> materializationCache = CollectionLiterals.<EventMaterializer.EventKey<EventDeclaration>, Event>newHashMap(); | ||
113 | |||
114 | private final Map<EventMaterializer.EventKey<InputEvent>, EventCollection> multipleInputCache = CollectionLiterals.<EventMaterializer.EventKey<InputEvent>, EventCollection>newHashMap(); | ||
115 | |||
116 | private final ConstantEvent falseEvent; | ||
117 | |||
118 | private final ConstantEvent trueEvent; | ||
119 | |||
120 | private final LinkedHashSet<EventMaterializer.EventKey<? extends EventDeclaration>> path = new LinkedHashSet<EventMaterializer.EventKey<? extends EventDeclaration>>(); | ||
121 | |||
122 | public EventMaterializer() { | ||
123 | ConstantEvent _createConstantEvent = this._ftFactory.createConstantEvent(); | ||
124 | final Procedure1<ConstantEvent> _function = (ConstantEvent it) -> { | ||
125 | it.setFailed(false); | ||
126 | }; | ||
127 | ConstantEvent _doubleArrow = ObjectExtensions.<ConstantEvent>operator_doubleArrow(_createConstantEvent, _function); | ||
128 | this.falseEvent = _doubleArrow; | ||
129 | ConstantEvent _createConstantEvent_1 = this._ftFactory.createConstantEvent(); | ||
130 | final Procedure1<ConstantEvent> _function_1 = (ConstantEvent it) -> { | ||
131 | it.setFailed(true); | ||
132 | }; | ||
133 | ConstantEvent _doubleArrow_1 = ObjectExtensions.<ConstantEvent>operator_doubleArrow(_createConstantEvent_1, _function_1); | ||
134 | this.trueEvent = _doubleArrow_1; | ||
135 | } | ||
136 | |||
137 | public Event getOrMaterialize(final Output output) { | ||
138 | return this.getOrMaterialize(output.getComponent(), output.getEventDeclaration()); | ||
139 | } | ||
140 | |||
141 | public Event getOrMaterialize(final Component component, final EventDeclaration eventDeclaration) { | ||
142 | Event _xblockexpression = null; | ||
143 | { | ||
144 | final EventMaterializer.EventKey<EventDeclaration> eventKey = new EventMaterializer.EventKey<EventDeclaration>(component, eventDeclaration); | ||
145 | this.pushEventKey(eventKey); | ||
146 | Event _xtrycatchfinallyexpression = null; | ||
147 | try { | ||
148 | Event _xblockexpression_1 = null; | ||
149 | { | ||
150 | Event event = this.materializationCache.get(eventKey); | ||
151 | if ((event == null)) { | ||
152 | event = this.materialize(component, eventDeclaration); | ||
153 | this.materializationCache.put(eventKey, event); | ||
154 | } | ||
155 | _xblockexpression_1 = event; | ||
156 | } | ||
157 | _xtrycatchfinallyexpression = _xblockexpression_1; | ||
158 | } finally { | ||
159 | this.popEventKey(eventKey); | ||
160 | } | ||
161 | _xblockexpression = _xtrycatchfinallyexpression; | ||
162 | } | ||
163 | return _xblockexpression; | ||
164 | } | ||
165 | |||
166 | protected Event materialize(final Component component, final EventDeclaration eventDeclaration) { | ||
167 | RandomEvent _xblockexpression = null; | ||
168 | { | ||
169 | String _name = component.getName(); | ||
170 | String _plus = (_name + "_"); | ||
171 | String _name_1 = eventDeclaration.getName(); | ||
172 | final String eventName = (_plus + _name_1); | ||
173 | RandomEvent _switchResult = null; | ||
174 | boolean _matched = false; | ||
175 | if (eventDeclaration instanceof InputEvent) { | ||
176 | _matched=true; | ||
177 | return this.materializeConnectedEvent(component, ((InputEvent)eventDeclaration)); | ||
178 | } | ||
179 | if (!_matched) { | ||
180 | if (eventDeclaration instanceof BasicEventDefinition) { | ||
181 | _matched=true; | ||
182 | BasicEvent _xblockexpression_1 = null; | ||
183 | { | ||
184 | final BasicEvent basicEvent = this._ftFactory.createBasicEvent(); | ||
185 | basicEvent.setDistribution(EcoreUtil.<Distribution>copy(((BasicEventDefinition)eventDeclaration).getDistribution())); | ||
186 | _xblockexpression_1 = basicEvent; | ||
187 | } | ||
188 | _switchResult = _xblockexpression_1; | ||
189 | } | ||
190 | } | ||
191 | if (!_matched) { | ||
192 | if (eventDeclaration instanceof GateDefinition) { | ||
193 | _matched=true; | ||
194 | Gate _xblockexpression_1 = null; | ||
195 | { | ||
196 | final EventCollection inputs = this.collectInputs(component, ((GateDefinition)eventDeclaration)); | ||
197 | Gate _switchResult_1 = null; | ||
198 | boolean _matched_1 = false; | ||
199 | if (eventDeclaration instanceof AndGateDefinition) { | ||
200 | _matched_1=true; | ||
201 | AndGate _xifexpression = null; | ||
202 | boolean _containsFalseEvent = inputs.containsFalseEvent(); | ||
203 | if (_containsFalseEvent) { | ||
204 | return this.falseEvent; | ||
205 | } else { | ||
206 | AndGate _xifexpression_1 = null; | ||
207 | boolean _isEmpty = inputs.isEmpty(); | ||
208 | if (_isEmpty) { | ||
209 | return this.trueEvent; | ||
210 | } else { | ||
211 | AndGate _xifexpression_2 = null; | ||
212 | boolean _containsExactlyOneRandomEvent = inputs.containsExactlyOneRandomEvent(); | ||
213 | if (_containsExactlyOneRandomEvent) { | ||
214 | return inputs.toSingleRandomEvent(); | ||
215 | } else { | ||
216 | _xifexpression_2 = this._ftFactory.createAndGate(); | ||
217 | } | ||
218 | _xifexpression_1 = _xifexpression_2; | ||
219 | } | ||
220 | _xifexpression = _xifexpression_1; | ||
221 | } | ||
222 | _switchResult_1 = _xifexpression; | ||
223 | } | ||
224 | if (!_matched_1) { | ||
225 | if (eventDeclaration instanceof OrGateDefinition) { | ||
226 | _matched_1=true; | ||
227 | OrGate _xifexpression = null; | ||
228 | boolean _containsTrueEvent = inputs.containsTrueEvent(); | ||
229 | if (_containsTrueEvent) { | ||
230 | return this.trueEvent; | ||
231 | } else { | ||
232 | OrGate _xifexpression_1 = null; | ||
233 | boolean _isEmpty = inputs.isEmpty(); | ||
234 | if (_isEmpty) { | ||
235 | return this.falseEvent; | ||
236 | } else { | ||
237 | OrGate _xifexpression_2 = null; | ||
238 | boolean _containsExactlyOneRandomEvent = inputs.containsExactlyOneRandomEvent(); | ||
239 | if (_containsExactlyOneRandomEvent) { | ||
240 | return inputs.toSingleRandomEvent(); | ||
241 | } else { | ||
242 | _xifexpression_2 = this._ftFactory.createOrGate(); | ||
243 | } | ||
244 | _xifexpression_1 = _xifexpression_2; | ||
245 | } | ||
246 | _xifexpression = _xifexpression_1; | ||
247 | } | ||
248 | _switchResult_1 = _xifexpression; | ||
249 | } | ||
250 | } | ||
251 | if (!_matched_1) { | ||
252 | if (eventDeclaration instanceof KOfMGateDefinition) { | ||
253 | _matched_1=true; | ||
254 | Gate _xblockexpression_2 = null; | ||
255 | { | ||
256 | int _count = inputs.getCount(); | ||
257 | int _k = ((KOfMGateDefinition)eventDeclaration).getK(); | ||
258 | int _multiply = (_count * _k); | ||
259 | int _m = ((KOfMGateDefinition)eventDeclaration).getM(); | ||
260 | final int requiredTrueInputs = (_multiply / _m); | ||
261 | int _trueEventCount = inputs.getTrueEventCount(); | ||
262 | final int k = (requiredTrueInputs - _trueEventCount); | ||
263 | final int m = inputs.getVariableEventCount(); | ||
264 | Gate _xifexpression = null; | ||
265 | if ((k == 0)) { | ||
266 | return this.trueEvent; | ||
267 | } else { | ||
268 | Gate _xifexpression_1 = null; | ||
269 | if ((k > m)) { | ||
270 | return this.falseEvent; | ||
271 | } else { | ||
272 | Gate _xifexpression_2 = null; | ||
273 | boolean _containsExactlyOneRandomEvent = inputs.containsExactlyOneRandomEvent(); | ||
274 | if (_containsExactlyOneRandomEvent) { | ||
275 | return inputs.toSingleRandomEvent(); | ||
276 | } else { | ||
277 | Gate _xifexpression_3 = null; | ||
278 | if ((k == 1)) { | ||
279 | _xifexpression_3 = this._ftFactory.createOrGate(); | ||
280 | } else { | ||
281 | Gate _xifexpression_4 = null; | ||
282 | if ((k == m)) { | ||
283 | _xifexpression_4 = this._ftFactory.createAndGate(); | ||
284 | } else { | ||
285 | KOfMGate _xblockexpression_3 = null; | ||
286 | { | ||
287 | final KOfMGate kOfMGate = this._ftFactory.createKOfMGate(); | ||
288 | kOfMGate.setK(k); | ||
289 | _xblockexpression_3 = kOfMGate; | ||
290 | } | ||
291 | _xifexpression_4 = _xblockexpression_3; | ||
292 | } | ||
293 | _xifexpression_3 = _xifexpression_4; | ||
294 | } | ||
295 | _xifexpression_2 = _xifexpression_3; | ||
296 | } | ||
297 | _xifexpression_1 = _xifexpression_2; | ||
298 | } | ||
299 | _xifexpression = _xifexpression_1; | ||
300 | } | ||
301 | _xblockexpression_2 = _xifexpression; | ||
302 | } | ||
303 | _switchResult_1 = _xblockexpression_2; | ||
304 | } | ||
305 | } | ||
306 | if (!_matched_1) { | ||
307 | throw new IllegalArgumentException(("Unknown gate definition: " + eventDeclaration)); | ||
308 | } | ||
309 | final Gate gate = _switchResult_1; | ||
310 | gate.getInputEvents().addAll(inputs.getRandomEvents()); | ||
311 | _xblockexpression_1 = gate; | ||
312 | } | ||
313 | _switchResult = _xblockexpression_1; | ||
314 | } | ||
315 | } | ||
316 | if (!_matched) { | ||
317 | throw new IllegalArgumentException(("Unknown event declaration: " + eventDeclaration)); | ||
318 | } | ||
319 | final RandomEvent event = _switchResult; | ||
320 | event.setName(eventName); | ||
321 | _xblockexpression = event; | ||
322 | } | ||
323 | return _xblockexpression; | ||
324 | } | ||
325 | |||
326 | protected Event materializeConnectedEvent(final Component component, final InputEvent inputEvent) { | ||
327 | Event _xblockexpression = null; | ||
328 | { | ||
329 | boolean _isMultiple = inputEvent.isMultiple(); | ||
330 | if (_isMultiple) { | ||
331 | StringConcatenation _builder = new StringConcatenation(); | ||
332 | _builder.append("Cannot materialize multiple nput "); | ||
333 | String _name = component.getName(); | ||
334 | _builder.append(_name); | ||
335 | _builder.append("_"); | ||
336 | String _name_1 = inputEvent.getName(); | ||
337 | _builder.append(_name_1); | ||
338 | throw new IllegalArgumentException(_builder.toString()); | ||
339 | } | ||
340 | final Input input = this.findInput(component, inputEvent); | ||
341 | final EList<Connection> incomingConnections = input.getIncomingConnections(); | ||
342 | int _size = incomingConnections.size(); | ||
343 | boolean _notEquals = (_size != 1); | ||
344 | if (_notEquals) { | ||
345 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
346 | _builder_1.append("Input "); | ||
347 | String _name_2 = component.getName(); | ||
348 | _builder_1.append(_name_2); | ||
349 | _builder_1.append("_"); | ||
350 | String _name_3 = inputEvent.getName(); | ||
351 | _builder_1.append(_name_3); | ||
352 | _builder_1.append(" has "); | ||
353 | int _size_1 = incomingConnections.size(); | ||
354 | _builder_1.append(_size_1); | ||
355 | _builder_1.append(" connections instead of 1"); | ||
356 | throw new IllegalArgumentException(_builder_1.toString()); | ||
357 | } | ||
358 | final Output output = IterableExtensions.<Connection>head(incomingConnections).getOutput(); | ||
359 | _xblockexpression = this.getOrMaterialize(output.getComponent(), output.getEventDeclaration()); | ||
360 | } | ||
361 | return _xblockexpression; | ||
362 | } | ||
363 | |||
364 | protected EventCollection collectInputs(final Component component, final GateDefinition gateDefinition) { | ||
365 | EventCollection _xblockexpression = null; | ||
366 | { | ||
367 | final EventCollection.Builder builder = EventCollection.builder(); | ||
368 | EList<EventDeclaration> _inputEvents = gateDefinition.getInputEvents(); | ||
369 | for (final EventDeclaration inputEventDeclaration : _inputEvents) { | ||
370 | boolean _matched = false; | ||
371 | if (inputEventDeclaration instanceof InputEvent) { | ||
372 | boolean _isMultiple = ((InputEvent)inputEventDeclaration).isMultiple(); | ||
373 | if (_isMultiple) { | ||
374 | _matched=true; | ||
375 | final EventCollection materializedEvents = this.getOrMaterializeConnectedEvents(component, ((InputEvent)inputEventDeclaration)); | ||
376 | builder.addAll(materializedEvents); | ||
377 | } | ||
378 | } | ||
379 | if (!_matched) { | ||
380 | builder.add(this.getOrMaterialize(component, inputEventDeclaration)); | ||
381 | } | ||
382 | } | ||
383 | _xblockexpression = builder.build(); | ||
384 | } | ||
385 | return _xblockexpression; | ||
386 | } | ||
387 | |||
388 | protected EventCollection getOrMaterializeConnectedEvents(final Component component, final InputEvent inputEvent) { | ||
389 | EventCollection _xblockexpression = null; | ||
390 | { | ||
391 | final EventMaterializer.EventKey<InputEvent> inputKey = new EventMaterializer.EventKey<InputEvent>(component, inputEvent); | ||
392 | this.pushEventKey(inputKey); | ||
393 | EventCollection _xtrycatchfinallyexpression = null; | ||
394 | try { | ||
395 | EventCollection _xblockexpression_1 = null; | ||
396 | { | ||
397 | EventCollection eventCollection = this.multipleInputCache.get(inputKey); | ||
398 | if ((eventCollection == null)) { | ||
399 | eventCollection = this.materializeConnectedEvents(component, inputEvent); | ||
400 | this.multipleInputCache.put(inputKey, eventCollection); | ||
401 | } | ||
402 | _xblockexpression_1 = eventCollection; | ||
403 | } | ||
404 | _xtrycatchfinallyexpression = _xblockexpression_1; | ||
405 | } finally { | ||
406 | this.popEventKey(inputKey); | ||
407 | } | ||
408 | _xblockexpression = _xtrycatchfinallyexpression; | ||
409 | } | ||
410 | return _xblockexpression; | ||
411 | } | ||
412 | |||
413 | protected EventCollection materializeConnectedEvents(final Component component, final InputEvent inputEvent) { | ||
414 | EventCollection _xblockexpression = null; | ||
415 | { | ||
416 | final Input input = this.findInput(component, inputEvent); | ||
417 | final EventCollection.Builder builder = EventCollection.builder(); | ||
418 | EList<Connection> _incomingConnections = input.getIncomingConnections(); | ||
419 | for (final Connection connection : _incomingConnections) { | ||
420 | boolean _isCurrentlyConnected = CftExtensions.isCurrentlyConnected(connection); | ||
421 | if (_isCurrentlyConnected) { | ||
422 | final Event materializedEvent = this.getOrMaterialize(connection.getOutput()); | ||
423 | builder.add(materializedEvent); | ||
424 | } | ||
425 | } | ||
426 | _xblockexpression = builder.build(); | ||
427 | } | ||
428 | return _xblockexpression; | ||
429 | } | ||
430 | |||
431 | protected Input findInput(final Component component, final InputEvent inputEvent) { | ||
432 | final Function1<Input, Boolean> _function = (Input it) -> { | ||
433 | InputEvent _inputEvent = it.getInputEvent(); | ||
434 | return Boolean.valueOf(Objects.equal(_inputEvent, inputEvent)); | ||
435 | }; | ||
436 | final Input input = IterableExtensions.<Input>findFirst(component.getInputs(), _function); | ||
437 | if ((input == null)) { | ||
438 | StringConcatenation _builder = new StringConcatenation(); | ||
439 | _builder.append("No input "); | ||
440 | _builder.append(inputEvent); | ||
441 | _builder.append(" in component "); | ||
442 | _builder.append(component); | ||
443 | throw new IllegalArgumentException(_builder.toString()); | ||
444 | } | ||
445 | return input; | ||
446 | } | ||
447 | |||
448 | private void pushEventKey(final EventMaterializer.EventKey<? extends EventDeclaration> eventKey) { | ||
449 | boolean _add = this.path.add(eventKey); | ||
450 | boolean _not = (!_add); | ||
451 | if (_not) { | ||
452 | StringConcatenation _builder = new StringConcatenation(); | ||
453 | _builder.append("Circular dependency ["); | ||
454 | { | ||
455 | for(final EventMaterializer.EventKey<? extends EventDeclaration> ancestor : this.path) { | ||
456 | _builder.append(ancestor); | ||
457 | _builder.append(", "); | ||
458 | } | ||
459 | } | ||
460 | _builder.append(eventKey); | ||
461 | _builder.append("] detected"); | ||
462 | throw new IllegalStateException(_builder.toString()); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | private boolean popEventKey(final EventMaterializer.EventKey<? extends EventDeclaration> eventKey) { | ||
467 | return this.path.remove(eventKey); | ||
468 | } | ||
469 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.java deleted file mode 100644 index 9b2dfd76..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/FaultTreeBuilder.java +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.cft2ft; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FtFactory; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
8 | import java.util.Collection; | ||
9 | import org.eclipse.emf.common.util.EList; | ||
10 | import org.eclipse.emf.ecore.EObject; | ||
11 | import org.eclipse.xtend.lib.annotations.Accessors; | ||
12 | import org.eclipse.xtext.xbase.lib.Pure; | ||
13 | |||
14 | @SuppressWarnings("all") | ||
15 | public class FaultTreeBuilder { | ||
16 | @Accessors | ||
17 | private final FaultTree faultTree = FtFactory.eINSTANCE.createFaultTree(); | ||
18 | |||
19 | public void addTopLevel(final RandomEvent event) { | ||
20 | RandomEvent _topEvent = this.faultTree.getTopEvent(); | ||
21 | boolean _tripleNotEquals = (_topEvent != null); | ||
22 | if (_tripleNotEquals) { | ||
23 | throw new IllegalStateException("Top event was already set"); | ||
24 | } | ||
25 | this.add(event); | ||
26 | this.faultTree.setTopEvent(event); | ||
27 | } | ||
28 | |||
29 | protected void add(final RandomEvent event) { | ||
30 | EObject _eContainer = this.faultTree.eContainer(); | ||
31 | boolean _equals = Objects.equal(_eContainer, this.faultTree); | ||
32 | if (_equals) { | ||
33 | return; | ||
34 | } | ||
35 | EObject _eContainer_1 = this.faultTree.eContainer(); | ||
36 | boolean _tripleNotEquals = (_eContainer_1 != null); | ||
37 | if (_tripleNotEquals) { | ||
38 | throw new IllegalStateException("Event is already in a different fault tree"); | ||
39 | } | ||
40 | EList<RandomEvent> _events = this.faultTree.getEvents(); | ||
41 | _events.add(event); | ||
42 | if ((event instanceof Gate)) { | ||
43 | this.addAll(((Gate)event).getInputEvents()); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | protected void addAll(final Collection<RandomEvent> events) { | ||
48 | for (final RandomEvent event : events) { | ||
49 | this.add(event); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | @Pure | ||
54 | public FaultTree getFaultTree() { | ||
55 | return this.faultTree; | ||
56 | } | ||
57 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbin deleted file mode 100644 index 028440a8..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentFaultTreeTrace.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbin deleted file mode 100644 index d542ba2d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentInstanceTrace.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbin deleted file mode 100644 index 949da0cd..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.ComponentNameGenerator.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbin deleted file mode 100644 index 82c045e2..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.Ecore2CftTransformation.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbin deleted file mode 100644 index ffd70c04..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.InputTrace.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbin deleted file mode 100644 index 418c71d4..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.LookupHandler.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbin deleted file mode 100644 index 86c0d704..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingHandler.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbin deleted file mode 100644 index c9dda5c4..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.MappingQueries.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore deleted file mode 100644 index 377aa872..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/.gitignore +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /.ComponentFaultTreeTrace.java._trace | ||
2 | /.ComponentInstanceTrace.java._trace | ||
3 | /.InputTrace.java._trace | ||
4 | /.LookupHandler.java._trace | ||
5 | /.MappingHandler.java._trace | ||
6 | /.MappingQueries.java._trace | ||
7 | /.CftTransformation.java._trace | ||
8 | /.Ecore2CftTransformation.java._trace | ||
9 | /.ComponentNameGenerator.java._trace | ||
10 | /.ComponentFaultTreeTrace.xtendbin | ||
11 | /.ComponentInstanceTrace.xtendbin | ||
12 | /.ComponentNameGenerator.xtendbin | ||
13 | /.Ecore2CftTransformation.xtendbin | ||
14 | /.InputTrace.xtendbin | ||
15 | /.LookupHandler.xtendbin | ||
16 | /.MappingHandler.xtendbin | ||
17 | /.MappingQueries.xtendbin | ||
18 | /ComponentFaultTreeTrace.java | ||
19 | /ComponentInstanceTrace.java | ||
20 | /ComponentNameGenerator.java | ||
21 | /Ecore2CftTransformation.java | ||
22 | /InputTrace.java | ||
23 | /LookupHandler.java | ||
24 | /MappingHandler.java | ||
25 | /MappingQueries.java | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java deleted file mode 100644 index ddcf9036..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentFaultTreeTrace.java +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentNameGenerator; | ||
10 | import java.util.Map; | ||
11 | import org.eclipse.emf.common.util.EList; | ||
12 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
13 | import org.eclipse.xtend.lib.annotations.Accessors; | ||
14 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
15 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
16 | import org.eclipse.xtext.xbase.lib.Pure; | ||
17 | |||
18 | @SuppressWarnings("all") | ||
19 | public class ComponentFaultTreeTrace { | ||
20 | @Accessors | ||
21 | private final ComponentFaultTree componentFaultTree = CftFactory.eINSTANCE.createComponentFaultTree(); | ||
22 | |||
23 | private final ComponentNameGenerator nameGenerator = new ComponentNameGenerator(); | ||
24 | |||
25 | private final Map<IPatternMatch, ComponentInstanceTrace> componentInstancesMap = CollectionLiterals.<IPatternMatch, ComponentInstanceTrace>newHashMap(); | ||
26 | |||
27 | public ComponentInstanceTrace instantiateComponent(final IPatternMatch patternMatch, final ComponentDefinition componenDefinition) { | ||
28 | return this.instantiateComponent(patternMatch, componenDefinition, Modality.MUST, false); | ||
29 | } | ||
30 | |||
31 | public ComponentInstanceTrace instantiateComponent(final IPatternMatch patternMatch, final ComponentDefinition componenDefinition, final Modality exists, final boolean allowMultiple) { | ||
32 | ComponentInstanceTrace _xblockexpression = null; | ||
33 | { | ||
34 | boolean _containsKey = this.componentInstancesMap.containsKey(patternMatch); | ||
35 | if (_containsKey) { | ||
36 | throw new IllegalArgumentException(("Already instantiated component for match: " + patternMatch)); | ||
37 | } | ||
38 | final ComponentInstanceTrace componentTrace = new ComponentInstanceTrace(this.componentFaultTree, componenDefinition, this.nameGenerator, exists, allowMultiple); | ||
39 | this.componentInstancesMap.put(patternMatch, componentTrace); | ||
40 | _xblockexpression = componentTrace; | ||
41 | } | ||
42 | return _xblockexpression; | ||
43 | } | ||
44 | |||
45 | public void setTopLevel(final ComponentInstanceTrace trace) { | ||
46 | Output _topEvent = this.componentFaultTree.getTopEvent(); | ||
47 | boolean _tripleNotEquals = (_topEvent != null); | ||
48 | if (_tripleNotEquals) { | ||
49 | throw new IllegalArgumentException("Top level component already set"); | ||
50 | } | ||
51 | final EList<Output> outputs = trace.getOutputs(); | ||
52 | int _size = outputs.size(); | ||
53 | boolean _tripleNotEquals_1 = (_size != 1); | ||
54 | if (_tripleNotEquals_1) { | ||
55 | int _size_1 = outputs.size(); | ||
56 | String _plus = ("Top level component must have 1 output, got " + Integer.valueOf(_size_1)); | ||
57 | String _plus_1 = (_plus + | ||
58 | " instead"); | ||
59 | throw new IllegalArgumentException(_plus_1); | ||
60 | } | ||
61 | boolean _appearsExactlyOnce = trace.appearsExactlyOnce(); | ||
62 | boolean _not = (!_appearsExactlyOnce); | ||
63 | if (_not) { | ||
64 | throw new IllegalArgumentException("Top level must appear in the fault tree exactly once"); | ||
65 | } | ||
66 | this.componentFaultTree.setTopEvent(IterableExtensions.<Output>head(outputs)); | ||
67 | } | ||
68 | |||
69 | public ComponentInstanceTrace lookup(final IPatternMatch patternMatch) { | ||
70 | return this.componentInstancesMap.get(patternMatch); | ||
71 | } | ||
72 | |||
73 | @Pure | ||
74 | public ComponentFaultTree getComponentFaultTree() { | ||
75 | return this.componentFaultTree; | ||
76 | } | ||
77 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java deleted file mode 100644 index 4034bdf3..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentInstanceTrace.java +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.Maps; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.EventDeclaration; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentNameGenerator; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.InputTrace; | ||
15 | import java.util.Map; | ||
16 | import org.eclipse.emf.common.util.EList; | ||
17 | |||
18 | @SuppressWarnings("all") | ||
19 | public class ComponentInstanceTrace { | ||
20 | private final Component componentInstance = CftFactory.eINSTANCE.createComponent(); | ||
21 | |||
22 | private final Map<InputEvent, InputTrace> inputEventsMap; | ||
23 | |||
24 | private final Map<EventDeclaration, Output> outputEventsMap; | ||
25 | |||
26 | protected ComponentInstanceTrace(final ComponentFaultTree faultTree, final ComponentDefinition componentDefinition, final ComponentNameGenerator nameGenerator, final Modality exists, final boolean multipleAllowed) { | ||
27 | this.componentInstance.setComponentDefinition(componentDefinition); | ||
28 | this.componentInstance.setName(nameGenerator.nextName(componentDefinition)); | ||
29 | this.componentInstance.setExists(exists); | ||
30 | this.componentInstance.setMultipleAllowed(multipleAllowed); | ||
31 | this.inputEventsMap = Maps.<InputEvent, InputTrace>newHashMapWithExpectedSize(componentDefinition.getInputEvents().size()); | ||
32 | EList<InputEvent> _inputEvents = componentDefinition.getInputEvents(); | ||
33 | for (final InputEvent inputEvent : _inputEvents) { | ||
34 | { | ||
35 | final InputTrace inputTrace = new InputTrace(this.componentInstance, inputEvent); | ||
36 | this.inputEventsMap.put(inputEvent, inputTrace); | ||
37 | } | ||
38 | } | ||
39 | this.outputEventsMap = Maps.<EventDeclaration, Output>newHashMapWithExpectedSize(componentDefinition.getOutputEvents().size()); | ||
40 | EList<EventDeclaration> _outputEvents = componentDefinition.getOutputEvents(); | ||
41 | for (final EventDeclaration outputEvent : _outputEvents) { | ||
42 | { | ||
43 | final Output output = CftFactory.eINSTANCE.createOutput(); | ||
44 | output.setEventDeclaration(outputEvent); | ||
45 | EList<Output> _outputs = this.componentInstance.getOutputs(); | ||
46 | _outputs.add(output); | ||
47 | this.outputEventsMap.put(outputEvent, output); | ||
48 | } | ||
49 | } | ||
50 | EList<Component> _components = faultTree.getComponents(); | ||
51 | _components.add(this.componentInstance); | ||
52 | } | ||
53 | |||
54 | public void assign(final EventDeclaration inputEvent, final ComponentInstanceTrace sourceComponent, final EventDeclaration outputEvent) { | ||
55 | this.assign(inputEvent, sourceComponent, outputEvent, Modality.MUST); | ||
56 | } | ||
57 | |||
58 | public void assign(final EventDeclaration inputEvent, final ComponentInstanceTrace sourceComponent, final EventDeclaration outputEvent, final Modality exists) { | ||
59 | final InputTrace inputTrace = this.inputEventsMap.get(inputEvent); | ||
60 | if ((inputTrace == null)) { | ||
61 | throw new IllegalArgumentException(("Unknown input: " + inputEvent)); | ||
62 | } | ||
63 | final Output output = sourceComponent.outputEventsMap.get(outputEvent); | ||
64 | if ((output == null)) { | ||
65 | throw new IllegalArgumentException(("Unknown output: " + outputEvent)); | ||
66 | } | ||
67 | inputTrace.assign(output, exists); | ||
68 | } | ||
69 | |||
70 | protected EList<Output> getOutputs() { | ||
71 | return this.componentInstance.getOutputs(); | ||
72 | } | ||
73 | |||
74 | protected boolean appearsExactlyOnce() { | ||
75 | return CftExtensions.appearsExactlyOnce(this.componentInstance); | ||
76 | } | ||
77 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java deleted file mode 100644 index e7dca003..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/ComponentNameGenerator.java +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
4 | import java.util.Map; | ||
5 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
6 | |||
7 | @SuppressWarnings("all") | ||
8 | public class ComponentNameGenerator { | ||
9 | private static final String DEFAULT_NAME = "__unnamed"; | ||
10 | |||
11 | private final Map<ComponentDefinition, Integer> instanceCounts = CollectionLiterals.<ComponentDefinition, Integer>newHashMap(); | ||
12 | |||
13 | public String nextName(final ComponentDefinition componentDefinition) { | ||
14 | String _xblockexpression = null; | ||
15 | { | ||
16 | final Integer instanceCount = this.instanceCounts.getOrDefault(componentDefinition, Integer.valueOf(0)); | ||
17 | this.instanceCounts.put(componentDefinition, Integer.valueOf(((instanceCount).intValue() + 1))); | ||
18 | String _elvis = null; | ||
19 | String _name = componentDefinition.getName(); | ||
20 | if (_name != null) { | ||
21 | _elvis = _name; | ||
22 | } else { | ||
23 | _elvis = ComponentNameGenerator.DEFAULT_NAME; | ||
24 | } | ||
25 | _xblockexpression = (_elvis + instanceCount); | ||
26 | } | ||
27 | return _xblockexpression; | ||
28 | } | ||
29 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java deleted file mode 100644 index a63c8e78..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/Ecore2CftTransformation.java +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentFaultTree; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingHandler; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries; | ||
10 | import java.util.List; | ||
11 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
12 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
13 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
14 | |||
15 | @SuppressWarnings("all") | ||
16 | public class Ecore2CftTransformation { | ||
17 | private final List<MappingHandler> mappingHandlers; | ||
18 | |||
19 | public Ecore2CftTransformation(final TransformationDefinition transformationDefinition, final ViatraQueryEngine viatraQueryEngine) { | ||
20 | final MappingQueries mappingQueries = new MappingQueries(transformationDefinition, viatraQueryEngine); | ||
21 | final Function1<MappingDefinition, MappingHandler> _function = (MappingDefinition mappingDefinition) -> { | ||
22 | return new MappingHandler(mappingDefinition, mappingQueries); | ||
23 | }; | ||
24 | this.mappingHandlers = ImmutableList.<MappingHandler>copyOf(ListExtensions.<MappingDefinition, MappingHandler>map(transformationDefinition.getMappingDefinitions(), _function)); | ||
25 | } | ||
26 | |||
27 | public ComponentFaultTree createComponentFaultTree() { | ||
28 | ComponentFaultTree _xblockexpression = null; | ||
29 | { | ||
30 | final ComponentFaultTreeTrace trace = new ComponentFaultTreeTrace(); | ||
31 | for (final MappingHandler handler : this.mappingHandlers) { | ||
32 | handler.instantiateComponents(trace); | ||
33 | } | ||
34 | for (final MappingHandler handler_1 : this.mappingHandlers) { | ||
35 | handler_1.instantiateConnections(trace); | ||
36 | } | ||
37 | _xblockexpression = trace.getComponentFaultTree(); | ||
38 | } | ||
39 | return _xblockexpression; | ||
40 | } | ||
41 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java deleted file mode 100644 index 2b30566f..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/InputTrace.java +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.CftFactory; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Component; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Connection; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Input; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.InputEvent; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Modality; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.Output; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.util.CftExtensions; | ||
11 | import java.util.Map; | ||
12 | import org.eclipse.emf.common.util.EList; | ||
13 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
14 | |||
15 | @SuppressWarnings("all") | ||
16 | public class InputTrace { | ||
17 | private final Input input = CftFactory.eINSTANCE.createInput(); | ||
18 | |||
19 | private final Map<Output, Connection> connectionsMap = CollectionLiterals.<Output, Connection>newHashMap(); | ||
20 | |||
21 | protected InputTrace(final Component component, final InputEvent inputEvent) { | ||
22 | this.input.setInputEvent(inputEvent); | ||
23 | EList<Input> _inputs = component.getInputs(); | ||
24 | _inputs.add(this.input); | ||
25 | } | ||
26 | |||
27 | public void assign(final Output output, final Modality exists) { | ||
28 | final Connection connection = this.connectionsMap.get(output); | ||
29 | if ((connection == null)) { | ||
30 | final Connection newConnection = CftFactory.eINSTANCE.createConnection(); | ||
31 | newConnection.setOutput(output); | ||
32 | newConnection.setExists(exists); | ||
33 | EList<Connection> _incomingConnections = this.input.getIncomingConnections(); | ||
34 | _incomingConnections.add(newConnection); | ||
35 | this.connectionsMap.put(output, newConnection); | ||
36 | } else { | ||
37 | boolean _isMoreConcreteThan = CftExtensions.isMoreConcreteThan(exists, connection.getExists()); | ||
38 | if (_isMoreConcreteThan) { | ||
39 | connection.setExists(exists); | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java deleted file mode 100644 index e155aac8..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/LookupHandler.java +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingParameter; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
9 | import org.eclipse.emf.ecore.EObject; | ||
10 | import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern; | ||
11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
12 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
13 | import org.eclipse.xtext.xbase.lib.Conversions; | ||
14 | |||
15 | @SuppressWarnings("all") | ||
16 | public class LookupHandler { | ||
17 | private final int[] argumentIndices; | ||
18 | |||
19 | private final ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher; | ||
20 | |||
21 | public LookupHandler(final MappingDefinition mappingDefinition, final LookupDefinition lookupDefinition, final ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher) { | ||
22 | EObject _eContainer = lookupDefinition.eContainer(); | ||
23 | boolean _notEquals = (!Objects.equal(_eContainer, mappingDefinition)); | ||
24 | if (_notEquals) { | ||
25 | throw new IllegalArgumentException("lookupDefinition must be contained in mappingDefinition"); | ||
26 | } | ||
27 | final int argumentCount = lookupDefinition.getArguments().size(); | ||
28 | int _length = ((Object[])Conversions.unwrapArray(lookedUpMatcher.getParameterNames(), Object.class)).length; | ||
29 | boolean _notEquals_1 = (argumentCount != _length); | ||
30 | if (_notEquals_1) { | ||
31 | MappingDefinition _mapping = lookupDefinition.getMapping(); | ||
32 | Pattern _pattern = null; | ||
33 | if (_mapping!=null) { | ||
34 | _pattern=_mapping.getPattern(); | ||
35 | } | ||
36 | String _name = null; | ||
37 | if (_pattern!=null) { | ||
38 | _name=_pattern.getName(); | ||
39 | } | ||
40 | String _plus = ("lookupDefinition (name: " + _name); | ||
41 | String _plus_1 = (_plus + | ||
42 | ") must have as many arguments as lookedUpMatcher (name: "); | ||
43 | String _patternName = lookedUpMatcher.getPatternName(); | ||
44 | String _plus_2 = (_plus_1 + _patternName); | ||
45 | String _plus_3 = (_plus_2 + ")"); | ||
46 | throw new IllegalArgumentException(_plus_3); | ||
47 | } | ||
48 | this.argumentIndices = new int[argumentCount]; | ||
49 | for (int i = 0; (i < argumentCount); i++) { | ||
50 | { | ||
51 | final MappingParameter argument = lookupDefinition.getArguments().get(i); | ||
52 | final int argumentIndex = mappingDefinition.getParameters().indexOf(argument); | ||
53 | this.argumentIndices[i] = argumentIndex; | ||
54 | } | ||
55 | } | ||
56 | this.lookedUpMatcher = lookedUpMatcher; | ||
57 | } | ||
58 | |||
59 | public ComponentInstanceTrace lookupForMatch(final ComponentFaultTreeTrace faultTreeTrace, final IPatternMatch match) { | ||
60 | ComponentInstanceTrace _xblockexpression = null; | ||
61 | { | ||
62 | final IPatternMatch lookedUpMatch = this.createLookedUpMatch(match); | ||
63 | _xblockexpression = faultTreeTrace.lookup(lookedUpMatch); | ||
64 | } | ||
65 | return _xblockexpression; | ||
66 | } | ||
67 | |||
68 | private IPatternMatch createLookedUpMatch(final IPatternMatch match) { | ||
69 | IPatternMatch _xblockexpression = null; | ||
70 | { | ||
71 | final IPatternMatch lookedUpMatch = this.lookedUpMatcher.newEmptyMatch(); | ||
72 | final int argumentCount = this.argumentIndices.length; | ||
73 | for (int i = 0; (i < argumentCount); i++) { | ||
74 | { | ||
75 | final int argumentIndex = this.argumentIndices[i]; | ||
76 | Object argumentValue = match.get(argumentIndex); | ||
77 | lookedUpMatch.set(i, argumentValue); | ||
78 | } | ||
79 | } | ||
80 | _xblockexpression = lookedUpMatch; | ||
81 | } | ||
82 | return _xblockexpression; | ||
83 | } | ||
84 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java deleted file mode 100644 index 41703289..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingHandler.java +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap; | ||
4 | import com.google.common.collect.Iterables; | ||
5 | import com.google.common.collect.Maps; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Assignment; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentInstance; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventReference; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentFaultTreeTrace; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.ComponentInstanceTrace; | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler; | ||
16 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.MappingQueries; | ||
17 | import java.util.HashMap; | ||
18 | import java.util.HashSet; | ||
19 | import java.util.Map; | ||
20 | import java.util.Set; | ||
21 | import java.util.function.Consumer; | ||
22 | import org.eclipse.emf.common.util.EList; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
25 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
26 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
27 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
28 | |||
29 | @SuppressWarnings("all") | ||
30 | public class MappingHandler { | ||
31 | private final ViatraQueryMatcher<? extends IPatternMatch> matcher; | ||
32 | |||
33 | private final MappingDefinition mappingDefinition; | ||
34 | |||
35 | private final Map<LookupDefinition, LookupHandler> lookupHandlers; | ||
36 | |||
37 | public MappingHandler(final MappingDefinition mappingDefinition, final MappingQueries mappingQueries) { | ||
38 | this.matcher = mappingQueries.getMatcher(mappingDefinition); | ||
39 | this.mappingDefinition = mappingDefinition; | ||
40 | final HashSet<Variable> variables = CollectionLiterals.<Variable>newHashSet(); | ||
41 | EList<Assignment> _assignments = mappingDefinition.getAssignments(); | ||
42 | for (final Assignment assignment : _assignments) { | ||
43 | { | ||
44 | Variable _component = assignment.getInput().getComponent(); | ||
45 | variables.add(_component); | ||
46 | Variable _component_1 = assignment.getOutput().getComponent(); | ||
47 | variables.add(_component_1); | ||
48 | } | ||
49 | } | ||
50 | final Function1<LookupDefinition, LookupDefinition> _function = (LookupDefinition it) -> { | ||
51 | return it; | ||
52 | }; | ||
53 | final Function1<LookupDefinition, LookupHandler> _function_1 = (LookupDefinition lookupDefinition) -> { | ||
54 | return mappingQueries.createLookupHandler(mappingDefinition, lookupDefinition); | ||
55 | }; | ||
56 | this.lookupHandlers = ImmutableMap.<LookupDefinition, LookupHandler>copyOf(IterableExtensions.<LookupDefinition, LookupDefinition, LookupHandler>toMap(Iterables.<LookupDefinition>filter(variables, LookupDefinition.class), _function, _function_1)); | ||
57 | } | ||
58 | |||
59 | public void instantiateComponents(final ComponentFaultTreeTrace faultTreeTrace) { | ||
60 | boolean _hasComponentInstace = this.hasComponentInstace(); | ||
61 | boolean _not = (!_hasComponentInstace); | ||
62 | if (_not) { | ||
63 | return; | ||
64 | } | ||
65 | final Consumer<IPatternMatch> _function = (IPatternMatch match) -> { | ||
66 | final ComponentInstanceTrace componentTrace = faultTreeTrace.instantiateComponent(match, this.getComponentDefinition()); | ||
67 | boolean _isTopLevel = this.isTopLevel(); | ||
68 | if (_isTopLevel) { | ||
69 | faultTreeTrace.setTopLevel(componentTrace); | ||
70 | } | ||
71 | }; | ||
72 | this.matcher.forEachMatch(_function); | ||
73 | } | ||
74 | |||
75 | public void instantiateConnections(final ComponentFaultTreeTrace faultTreeTrace) { | ||
76 | boolean _hasConnections = this.hasConnections(); | ||
77 | boolean _not = (!_hasConnections); | ||
78 | if (_not) { | ||
79 | return; | ||
80 | } | ||
81 | final Consumer<IPatternMatch> _function = (IPatternMatch match) -> { | ||
82 | final Map<Variable, ComponentInstanceTrace> lookedUpComponents = this.lookupComponents(faultTreeTrace, match); | ||
83 | EList<Assignment> _assignments = this.mappingDefinition.getAssignments(); | ||
84 | for (final Assignment assignment : _assignments) { | ||
85 | { | ||
86 | final EventReference input = assignment.getInput(); | ||
87 | final ComponentInstanceTrace inputComponent = lookedUpComponents.get(input.getComponent()); | ||
88 | final EventReference output = assignment.getOutput(); | ||
89 | final ComponentInstanceTrace outputComponent = lookedUpComponents.get(output.getComponent()); | ||
90 | if (((inputComponent != null) && (outputComponent != null))) { | ||
91 | inputComponent.assign(input.getEvent(), outputComponent, output.getEvent()); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | }; | ||
96 | this.matcher.forEachMatch(_function); | ||
97 | } | ||
98 | |||
99 | private Map<Variable, ComponentInstanceTrace> lookupComponents(final ComponentFaultTreeTrace faultTreeTrace, final IPatternMatch match) { | ||
100 | HashMap<Variable, ComponentInstanceTrace> _xblockexpression = null; | ||
101 | { | ||
102 | int _size = this.lookupHandlers.size(); | ||
103 | int _plus = (_size + 1); | ||
104 | final HashMap<Variable, ComponentInstanceTrace> lookedUpComponents = Maps.<Variable, ComponentInstanceTrace>newHashMapWithExpectedSize(_plus); | ||
105 | boolean _hasComponentInstace = this.hasComponentInstace(); | ||
106 | if (_hasComponentInstace) { | ||
107 | final ComponentInstanceTrace componentInstance = faultTreeTrace.lookup(match); | ||
108 | lookedUpComponents.put(this.mappingDefinition.getComponentInstance(), componentInstance); | ||
109 | } | ||
110 | Set<Map.Entry<LookupDefinition, LookupHandler>> _entrySet = this.lookupHandlers.entrySet(); | ||
111 | for (final Map.Entry<LookupDefinition, LookupHandler> pair : _entrySet) { | ||
112 | { | ||
113 | final ComponentInstanceTrace componentInstance_1 = pair.getValue().lookupForMatch(faultTreeTrace, match); | ||
114 | if ((componentInstance_1 != null)) { | ||
115 | lookedUpComponents.put(pair.getKey(), componentInstance_1); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | _xblockexpression = lookedUpComponents; | ||
120 | } | ||
121 | return _xblockexpression; | ||
122 | } | ||
123 | |||
124 | private ComponentDefinition getComponentDefinition() { | ||
125 | ComponentInstance _componentInstance = this.mappingDefinition.getComponentInstance(); | ||
126 | ComponentDefinition _componentType = null; | ||
127 | if (_componentInstance!=null) { | ||
128 | _componentType=_componentInstance.getComponentType(); | ||
129 | } | ||
130 | return _componentType; | ||
131 | } | ||
132 | |||
133 | private boolean hasComponentInstace() { | ||
134 | ComponentDefinition _componentDefinition = this.getComponentDefinition(); | ||
135 | return (_componentDefinition != null); | ||
136 | } | ||
137 | |||
138 | private boolean isTopLevel() { | ||
139 | return this.mappingDefinition.isTopLevel(); | ||
140 | } | ||
141 | |||
142 | private boolean hasConnections() { | ||
143 | boolean _isEmpty = this.mappingDefinition.getAssignments().isEmpty(); | ||
144 | return (!_isEmpty); | ||
145 | } | ||
146 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java deleted file mode 100644 index 6147807e..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ecore2cft/MappingQueries.java +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft; | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ecore2cft.LookupHandler; | ||
8 | import java.util.Map; | ||
9 | import org.eclipse.viatra.query.patternlanguage.emf.specification.SpecificationBuilder; | ||
10 | import org.eclipse.viatra.query.runtime.api.GenericQueryGroup; | ||
11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
12 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
13 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
14 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
15 | import org.eclipse.xtext.xbase.lib.Conversions; | ||
16 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
17 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
18 | import org.eclipse.xtext.xbase.lib.MapExtensions; | ||
19 | |||
20 | @SuppressWarnings("all") | ||
21 | public class MappingQueries { | ||
22 | private final Map<MappingDefinition, ViatraQueryMatcher<? extends IPatternMatch>> matchersMap; | ||
23 | |||
24 | public MappingQueries(final TransformationDefinition transformationDefinition, final ViatraQueryEngine viatraQueryEngine) { | ||
25 | final SpecificationBuilder specificationBuilder = new SpecificationBuilder(); | ||
26 | final Function1<MappingDefinition, MappingDefinition> _function = (MappingDefinition it) -> { | ||
27 | return it; | ||
28 | }; | ||
29 | final Function1<MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> _function_1 = (MappingDefinition it) -> { | ||
30 | return specificationBuilder.getOrCreateSpecification(it.getPattern()); | ||
31 | }; | ||
32 | final Map<MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> querySpecificationsMap = IterableExtensions.<MappingDefinition, MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>>toMap(transformationDefinition.getMappingDefinitions(), _function, _function_1); | ||
33 | GenericQueryGroup.of(((IQuerySpecification<?>[])Conversions.unwrapArray(querySpecificationsMap.values(), IQuerySpecification.class))).prepare(viatraQueryEngine); | ||
34 | final Function1<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>, ViatraQueryMatcher<? extends IPatternMatch>> _function_2 = (IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> it) -> { | ||
35 | return it.getMatcher(viatraQueryEngine); | ||
36 | }; | ||
37 | this.matchersMap = ImmutableMap.<MappingDefinition, ViatraQueryMatcher<? extends IPatternMatch>>copyOf(MapExtensions.<MappingDefinition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>, ViatraQueryMatcher<? extends IPatternMatch>>mapValues(querySpecificationsMap, _function_2)); | ||
38 | } | ||
39 | |||
40 | public ViatraQueryMatcher<? extends IPatternMatch> getMatcher(final MappingDefinition mappingDefinition) { | ||
41 | ViatraQueryMatcher<? extends IPatternMatch> _xblockexpression = null; | ||
42 | { | ||
43 | final ViatraQueryMatcher<? extends IPatternMatch> matcher = this.matchersMap.get(mappingDefinition); | ||
44 | if ((matcher == null)) { | ||
45 | throw new IllegalArgumentException(("Unknown mapping definition: " + mappingDefinition)); | ||
46 | } | ||
47 | _xblockexpression = matcher; | ||
48 | } | ||
49 | return _xblockexpression; | ||
50 | } | ||
51 | |||
52 | public LookupHandler createLookupHandler(final MappingDefinition mappingDefinition, final LookupDefinition lookupDefinition) { | ||
53 | LookupHandler _xblockexpression = null; | ||
54 | { | ||
55 | final ViatraQueryMatcher<? extends IPatternMatch> lookedUpMatcher = this.getMatcher(lookupDefinition.getMapping()); | ||
56 | _xblockexpression = new LookupHandler(mappingDefinition, lookupDefinition, lookedUpMatcher); | ||
57 | } | ||
58 | return _xblockexpression; | ||
59 | } | ||
60 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.Ft2GalileoTransformation.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.Ft2GalileoTransformation.xtendbin deleted file mode 100644 index 0956e6e0..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.Ft2GalileoTransformation.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.gitignore deleted file mode 100644 index f4610b04..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/.gitignore +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | /.Ft2GalileoTransformation.java._trace | ||
2 | /.Ft2GalileoTransformation.xtendbin | ||
3 | /Ft2GalileoTransformation.java | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.java deleted file mode 100644 index 8748825d..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/ft2galileo/Ft2GalileoTransformation.java +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.AndGate; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.BasicEvent; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantDistribution; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Distribution; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ExponentialDistribution; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.Gate; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.KOfMGate; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.OrGate; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.RandomEvent; | ||
13 | import java.util.Arrays; | ||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
16 | import org.eclipse.xtend2.lib.StringConcatenationClient; | ||
17 | |||
18 | @SuppressWarnings("all") | ||
19 | public class Ft2GalileoTransformation { | ||
20 | public CharSequence toGalileo(final FaultTree faultTree) { | ||
21 | StringConcatenation _builder = new StringConcatenation(); | ||
22 | _builder.append("toplevel \""); | ||
23 | String _name = faultTree.getTopEvent().getName(); | ||
24 | _builder.append(_name); | ||
25 | _builder.append("\";"); | ||
26 | _builder.newLineIfNotEmpty(); | ||
27 | { | ||
28 | EList<RandomEvent> _events = faultTree.getEvents(); | ||
29 | for(final RandomEvent event : _events) { | ||
30 | _builder.append("\""); | ||
31 | String _name_1 = event.getName(); | ||
32 | _builder.append(_name_1); | ||
33 | _builder.append("\" "); | ||
34 | Object _defineEvent = this.defineEvent(event); | ||
35 | _builder.append(_defineEvent); | ||
36 | _builder.append(";"); | ||
37 | _builder.newLineIfNotEmpty(); | ||
38 | } | ||
39 | } | ||
40 | return _builder; | ||
41 | } | ||
42 | |||
43 | protected Object _defineEvent(final BasicEvent basicEvent) { | ||
44 | StringConcatenation _builder = new StringConcatenation(); | ||
45 | StringConcatenationClient _defineDistribution = this.defineDistribution(basicEvent.getDistribution()); | ||
46 | _builder.append(_defineDistribution); | ||
47 | _builder.append(" dorm=0.0"); | ||
48 | return _builder; | ||
49 | } | ||
50 | |||
51 | protected StringConcatenationClient _defineDistribution(final ConstantDistribution distribution) { | ||
52 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
53 | @Override | ||
54 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
55 | _builder.append("p="); | ||
56 | double _p = distribution.getP(); | ||
57 | _builder.append(_p); | ||
58 | } | ||
59 | }; | ||
60 | return _client; | ||
61 | } | ||
62 | |||
63 | protected StringConcatenationClient _defineDistribution(final ExponentialDistribution distribution) { | ||
64 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
65 | @Override | ||
66 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
67 | _builder.append("lambda="); | ||
68 | double _lambda = distribution.getLambda(); | ||
69 | _builder.append(_lambda); | ||
70 | } | ||
71 | }; | ||
72 | return _client; | ||
73 | } | ||
74 | |||
75 | protected StringConcatenationClient _defineDistribution(final Distribution distribution) { | ||
76 | throw new IllegalArgumentException(("Unknown distribution: " + distribution)); | ||
77 | } | ||
78 | |||
79 | protected StringConcatenationClient _defineEvent(final Gate gate) { | ||
80 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
81 | @Override | ||
82 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
83 | StringConcatenationClient _defineGate = Ft2GalileoTransformation.this.defineGate(gate); | ||
84 | _builder.append(_defineGate); | ||
85 | _builder.append(" "); | ||
86 | { | ||
87 | EList<RandomEvent> _inputEvents = gate.getInputEvents(); | ||
88 | boolean _hasElements = false; | ||
89 | for(final RandomEvent input : _inputEvents) { | ||
90 | if (!_hasElements) { | ||
91 | _hasElements = true; | ||
92 | } else { | ||
93 | _builder.appendImmediate(" ", ""); | ||
94 | } | ||
95 | _builder.append("\""); | ||
96 | String _name = input.getName(); | ||
97 | _builder.append(_name); | ||
98 | _builder.append("\""); | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | }; | ||
103 | return _client; | ||
104 | } | ||
105 | |||
106 | protected StringConcatenationClient _defineGate(final AndGate gate) { | ||
107 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
108 | @Override | ||
109 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
110 | _builder.append("and"); | ||
111 | } | ||
112 | }; | ||
113 | return _client; | ||
114 | } | ||
115 | |||
116 | protected StringConcatenationClient _defineGate(final OrGate gate) { | ||
117 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
118 | @Override | ||
119 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
120 | _builder.append("or"); | ||
121 | } | ||
122 | }; | ||
123 | return _client; | ||
124 | } | ||
125 | |||
126 | protected StringConcatenationClient _defineGate(final KOfMGate gate) { | ||
127 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
128 | @Override | ||
129 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
130 | int _k = gate.getK(); | ||
131 | _builder.append(_k); | ||
132 | _builder.append("of"); | ||
133 | int _size = gate.getInputEvents().size(); | ||
134 | _builder.append(_size); | ||
135 | } | ||
136 | }; | ||
137 | return _client; | ||
138 | } | ||
139 | |||
140 | protected StringConcatenationClient _defineGate(final Gate gate) { | ||
141 | throw new IllegalArgumentException(("Unknown gate: " + gate)); | ||
142 | } | ||
143 | |||
144 | protected StringConcatenationClient _defineEvent(final RandomEvent randomEvent) { | ||
145 | throw new IllegalArgumentException(("Unknown random even: " + randomEvent)); | ||
146 | } | ||
147 | |||
148 | protected Object defineEvent(final RandomEvent basicEvent) { | ||
149 | if (basicEvent instanceof BasicEvent) { | ||
150 | return _defineEvent((BasicEvent)basicEvent); | ||
151 | } else if (basicEvent instanceof Gate) { | ||
152 | return _defineEvent((Gate)basicEvent); | ||
153 | } else if (basicEvent != null) { | ||
154 | return _defineEvent(basicEvent); | ||
155 | } else { | ||
156 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
157 | Arrays.<Object>asList(basicEvent).toString()); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | protected StringConcatenationClient defineDistribution(final Distribution distribution) { | ||
162 | if (distribution instanceof ConstantDistribution) { | ||
163 | return _defineDistribution((ConstantDistribution)distribution); | ||
164 | } else if (distribution instanceof ExponentialDistribution) { | ||
165 | return _defineDistribution((ExponentialDistribution)distribution); | ||
166 | } else if (distribution != null) { | ||
167 | return _defineDistribution(distribution); | ||
168 | } else { | ||
169 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
170 | Arrays.<Object>asList(distribution).toString()); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | protected StringConcatenationClient defineGate(final Gate gate) { | ||
175 | if (gate instanceof AndGate) { | ||
176 | return _defineGate((AndGate)gate); | ||
177 | } else if (gate instanceof KOfMGate) { | ||
178 | return _defineGate((KOfMGate)gate); | ||
179 | } else if (gate instanceof OrGate) { | ||
180 | return _defineGate((OrGate)gate); | ||
181 | } else if (gate != null) { | ||
182 | return _defineGate(gate); | ||
183 | } else { | ||
184 | throw new IllegalArgumentException("Unhandled parameter types: " + | ||
185 | Arrays.<Object>asList(gate).toString()); | ||
186 | } | ||
187 | } | ||
188 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.ReliabilityResult.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.ReliabilityResult.xtendbin deleted file mode 100644 index cdaacb58..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.ReliabilityResult.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftConfiguration.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftConfiguration.xtendbin deleted file mode 100644 index 6e1908aa..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftConfiguration.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftHandler.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftHandler.xtendbin deleted file mode 100644 index 5772b0e7..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftHandler.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftSolver.xtendbin b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftSolver.xtendbin deleted file mode 100644 index e1c1a8c7..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.StormDftSolver.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.gitignore b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.gitignore deleted file mode 100644 index 8a74c101..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/.gitignore +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | /.StormDftSolver.java._trace | ||
2 | /.StormDftConfiguration.java._trace | ||
3 | /.StormDftMttfConfiguration.java._trace | ||
4 | /.FtAnalysisObjective.java._trace | ||
5 | /.ApproximationHeuristic.java._trace | ||
6 | /.StormDftHandler.java._trace | ||
7 | /.StormDftException.java._trace | ||
8 | /.ReliabilityModelSolution.java._trace | ||
9 | /.ReliabilityResult.java._trace | ||
10 | /.ReliabilityResult.xtendbin | ||
11 | /.StormDftConfiguration.xtendbin | ||
12 | /.StormDftHandler.xtendbin | ||
13 | /.StormDftSolver.xtendbin | ||
14 | /ApproximationHeuristic.java | ||
15 | /FtAnalysisObjective.java | ||
16 | /ReliabilityResult.java | ||
17 | /StormDftConfiguration.java | ||
18 | /StormDftException.java | ||
19 | /StormDftHandler.java | ||
20 | /StormDftSolver.java | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ApproximationHeuristic.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ApproximationHeuristic.java deleted file mode 100644 index 822d4f36..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ApproximationHeuristic.java +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | @SuppressWarnings("all") | ||
4 | public enum ApproximationHeuristic { | ||
5 | NONE, | ||
6 | |||
7 | DEPTH; | ||
8 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/FtAnalysisObjective.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/FtAnalysisObjective.java deleted file mode 100644 index 528ada42..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/FtAnalysisObjective.java +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | @SuppressWarnings("all") | ||
4 | public abstract class FtAnalysisObjective { | ||
5 | public static final class TimeBound extends FtAnalysisObjective { | ||
6 | public double timeBound = 0; | ||
7 | } | ||
8 | |||
9 | public static final FtAnalysisObjective MTTF = new FtAnalysisObjective() { | ||
10 | }; | ||
11 | |||
12 | private FtAnalysisObjective() { | ||
13 | } | ||
14 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ReliabilityResult.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ReliabilityResult.java deleted file mode 100644 index c8c8b000..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/ReliabilityResult.java +++ /dev/null | |||
@@ -1,156 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | import org.eclipse.xtend.lib.annotations.Data; | ||
4 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; | ||
5 | import org.eclipse.xtext.xbase.lib.Pure; | ||
6 | import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; | ||
7 | |||
8 | @SuppressWarnings("all") | ||
9 | public abstract class ReliabilityResult { | ||
10 | @Data | ||
11 | public static final class Solution extends ReliabilityResult { | ||
12 | private final double lowerBound; | ||
13 | |||
14 | private final double upperBound; | ||
15 | |||
16 | public Solution(final double value) { | ||
17 | this(value, value); | ||
18 | } | ||
19 | |||
20 | public Solution(final double lowerBound, final double upperBound) { | ||
21 | if ((lowerBound > upperBound)) { | ||
22 | throw new IllegalArgumentException("lowerBound must not be larger than upperBound"); | ||
23 | } | ||
24 | this.lowerBound = lowerBound; | ||
25 | this.upperBound = upperBound; | ||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public ReliabilityResult.Solution getOrThrow() { | ||
30 | return this; | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | @Pure | ||
35 | public int hashCode() { | ||
36 | final int prime = 31; | ||
37 | int result = 1; | ||
38 | result = prime * result + (int) (Double.doubleToLongBits(this.lowerBound) ^ (Double.doubleToLongBits(this.lowerBound) >>> 32)); | ||
39 | return prime * result + (int) (Double.doubleToLongBits(this.upperBound) ^ (Double.doubleToLongBits(this.upperBound) >>> 32)); | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | @Pure | ||
44 | public boolean equals(final Object obj) { | ||
45 | if (this == obj) | ||
46 | return true; | ||
47 | if (obj == null) | ||
48 | return false; | ||
49 | if (getClass() != obj.getClass()) | ||
50 | return false; | ||
51 | ReliabilityResult.Solution other = (ReliabilityResult.Solution) obj; | ||
52 | if (Double.doubleToLongBits(other.lowerBound) != Double.doubleToLongBits(this.lowerBound)) | ||
53 | return false; | ||
54 | if (Double.doubleToLongBits(other.upperBound) != Double.doubleToLongBits(this.upperBound)) | ||
55 | return false; | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | @Override | ||
60 | @Pure | ||
61 | public String toString() { | ||
62 | return new ToStringBuilder(this) | ||
63 | .addAllFields() | ||
64 | .toString(); | ||
65 | } | ||
66 | |||
67 | @Pure | ||
68 | public double getLowerBound() { | ||
69 | return this.lowerBound; | ||
70 | } | ||
71 | |||
72 | @Pure | ||
73 | public double getUpperBound() { | ||
74 | return this.upperBound; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | @Data | ||
79 | public static final class Unknown extends ReliabilityResult { | ||
80 | private final String message; | ||
81 | |||
82 | private final Throwable cause; | ||
83 | |||
84 | @FinalFieldsConstructor | ||
85 | public Unknown(final String message, final Throwable cause) { | ||
86 | super(); | ||
87 | this.message = message; | ||
88 | this.cause = cause; | ||
89 | } | ||
90 | |||
91 | public Unknown(final String message) { | ||
92 | this(message, null); | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public ReliabilityResult.Solution getOrThrow() { | ||
97 | throw new RuntimeException(this.message, this.cause); | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | @Pure | ||
102 | public int hashCode() { | ||
103 | final int prime = 31; | ||
104 | int result = 1; | ||
105 | result = prime * result + ((this.message== null) ? 0 : this.message.hashCode()); | ||
106 | return prime * result + ((this.cause== null) ? 0 : this.cause.hashCode()); | ||
107 | } | ||
108 | |||
109 | @Override | ||
110 | @Pure | ||
111 | public boolean equals(final Object obj) { | ||
112 | if (this == obj) | ||
113 | return true; | ||
114 | if (obj == null) | ||
115 | return false; | ||
116 | if (getClass() != obj.getClass()) | ||
117 | return false; | ||
118 | ReliabilityResult.Unknown other = (ReliabilityResult.Unknown) obj; | ||
119 | if (this.message == null) { | ||
120 | if (other.message != null) | ||
121 | return false; | ||
122 | } else if (!this.message.equals(other.message)) | ||
123 | return false; | ||
124 | if (this.cause == null) { | ||
125 | if (other.cause != null) | ||
126 | return false; | ||
127 | } else if (!this.cause.equals(other.cause)) | ||
128 | return false; | ||
129 | return true; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | @Pure | ||
134 | public String toString() { | ||
135 | return new ToStringBuilder(this) | ||
136 | .addAllFields() | ||
137 | .toString(); | ||
138 | } | ||
139 | |||
140 | @Pure | ||
141 | public String getMessage() { | ||
142 | return this.message; | ||
143 | } | ||
144 | |||
145 | @Pure | ||
146 | public Throwable getCause() { | ||
147 | return this.cause; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | public static final ReliabilityResult.Unknown TIMEOUT = new ReliabilityResult.Unknown("Solver timed out"); | ||
152 | |||
153 | public static final ReliabilityResult.Unknown MEMOUT = new ReliabilityResult.Unknown("Solver out of memory"); | ||
154 | |||
155 | public abstract ReliabilityResult.Solution getOrThrow(); | ||
156 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftConfiguration.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftConfiguration.java deleted file mode 100644 index e1bb3625..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftConfiguration.java +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.ApproximationHeuristic; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.FtAnalysisObjective; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolverConfiguration; | ||
7 | |||
8 | @SuppressWarnings("all") | ||
9 | public final class StormDftConfiguration extends SolverConfiguration { | ||
10 | public static final String DEFAULT_SOLVER_PATH = "storm-dft"; | ||
11 | |||
12 | public double precision = 1e-6; | ||
13 | |||
14 | public boolean bisimulation = true; | ||
15 | |||
16 | public boolean symmetryReduction = true; | ||
17 | |||
18 | public boolean modularization = true; | ||
19 | |||
20 | public boolean dontCarePropagation = true; | ||
21 | |||
22 | public double approximation = 0; | ||
23 | |||
24 | public ApproximationHeuristic approximationHeuristic = ApproximationHeuristic.NONE; | ||
25 | |||
26 | public FtAnalysisObjective objective; | ||
27 | |||
28 | public boolean isApproximationInUse() { | ||
29 | return (!Objects.equal(this.approximationHeuristic, ApproximationHeuristic.NONE)); | ||
30 | } | ||
31 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftException.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftException.java deleted file mode 100644 index 955c9ed1..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftException.java +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | @SuppressWarnings("all") | ||
4 | public class StormDftException extends RuntimeException { | ||
5 | public StormDftException(final String s) { | ||
6 | super(s); | ||
7 | } | ||
8 | |||
9 | public StormDftException(final String s, final Exception e) { | ||
10 | super(s, e); | ||
11 | } | ||
12 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.java deleted file mode 100644 index 46127425..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftHandler.java +++ /dev/null | |||
@@ -1,330 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.ApproximationHeuristic; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.FtAnalysisObjective; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.ReliabilityResult; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.StormDftConfiguration; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.StormDftException; | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | ||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolverConfiguration; | ||
12 | import java.io.BufferedReader; | ||
13 | import java.io.IOException; | ||
14 | import java.io.InputStream; | ||
15 | import java.io.InputStreamReader; | ||
16 | import java.util.ArrayList; | ||
17 | import java.util.regex.Matcher; | ||
18 | import java.util.regex.Pattern; | ||
19 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
20 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
21 | import org.eclipse.xtext.xbase.lib.Exceptions; | ||
22 | import org.eclipse.xtext.xbase.lib.Extension; | ||
23 | import org.eclipse.xtext.xbase.lib.Functions.Function0; | ||
24 | import org.eclipse.xtext.xbase.lib.InputOutput; | ||
25 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
26 | |||
27 | @SuppressWarnings("all") | ||
28 | public class StormDftHandler { | ||
29 | private static final String DOUBLE_REGEX = "[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"; | ||
30 | |||
31 | private static final String SINGLE_RESULT_GROUP = "single"; | ||
32 | |||
33 | private static final String LOWER_BOUND_GROUP = "lower"; | ||
34 | |||
35 | private static final String UPPER_BOUND_GROUP = "upper"; | ||
36 | |||
37 | private static final String RESULT_REGEX = new Function0<String>() { | ||
38 | public String apply() { | ||
39 | StringConcatenation _builder = new StringConcatenation(); | ||
40 | _builder.append("^Result:\\s*\\[(?:(?<"); | ||
41 | _builder.append(StormDftHandler.SINGLE_RESULT_GROUP); | ||
42 | _builder.append(">"); | ||
43 | _builder.append(StormDftHandler.DOUBLE_REGEX); | ||
44 | _builder.append(")|\\((?<"); | ||
45 | _builder.append(StormDftHandler.LOWER_BOUND_GROUP); | ||
46 | _builder.append(">"); | ||
47 | _builder.append(StormDftHandler.DOUBLE_REGEX); | ||
48 | _builder.append("),\\s*(?<"); | ||
49 | _builder.append(StormDftHandler.UPPER_BOUND_GROUP); | ||
50 | _builder.append(">"); | ||
51 | _builder.append(StormDftHandler.DOUBLE_REGEX); | ||
52 | _builder.append(")\\))\\]"); | ||
53 | return _builder.toString(); | ||
54 | } | ||
55 | }.apply(); | ||
56 | |||
57 | private static final Pattern RESULT_PATTERN = Pattern.compile(StormDftHandler.RESULT_REGEX); | ||
58 | |||
59 | private static final int SIGNAL_EXIT_VALUE_OFFSET = 0x80; | ||
60 | |||
61 | private static final int SIGXCPU = 24; | ||
62 | |||
63 | private static final int SIGXFSZ = 25; | ||
64 | |||
65 | private static final int STORM_GENERAL_ERROR = ((-1) & 0xff); | ||
66 | |||
67 | private static final int STORM_TIMEOUT = ((-2) & 0xff); | ||
68 | |||
69 | private static final int STORM_MEMOUT = ((-3) & 0xff); | ||
70 | |||
71 | public ReliabilityResult callSolver(final String dftFilePath, final StormDftConfiguration configuration) { | ||
72 | try { | ||
73 | ReliabilityResult _xblockexpression = null; | ||
74 | { | ||
75 | final ImmutableList<String> commandLine = this.toCommandLine(configuration, dftFilePath); | ||
76 | final DocumentationLevel documentationLevel = configuration.documentationLevel; | ||
77 | final boolean printOutput = (Objects.equal(documentationLevel, DocumentationLevel.NORMAL) || | ||
78 | Objects.equal(documentationLevel, DocumentationLevel.FULL)); | ||
79 | final ProcessBuilder processBuilder = new ProcessBuilder().command(commandLine); | ||
80 | Process process = null; | ||
81 | ReliabilityResult _xtrycatchfinallyexpression = null; | ||
82 | try { | ||
83 | ReliabilityResult _xtrycatchfinallyexpression_1 = null; | ||
84 | try { | ||
85 | ReliabilityResult _xblockexpression_1 = null; | ||
86 | { | ||
87 | process = processBuilder.start(); | ||
88 | process.getOutputStream().close(); | ||
89 | final ReliabilityResult.Solution result = this.readOutput(process.getInputStream(), printOutput); | ||
90 | final String error = this.readError(process.getErrorStream(), printOutput); | ||
91 | final int exitValue = process.waitFor(); | ||
92 | ReliabilityResult _xifexpression = null; | ||
93 | if ((result == null)) { | ||
94 | _xifexpression = this.interpretExitStatus(exitValue, error); | ||
95 | } else { | ||
96 | _xifexpression = result; | ||
97 | } | ||
98 | _xblockexpression_1 = _xifexpression; | ||
99 | } | ||
100 | _xtrycatchfinallyexpression_1 = _xblockexpression_1; | ||
101 | } catch (final Throwable _t) { | ||
102 | if (_t instanceof IOException) { | ||
103 | final IOException e = (IOException)_t; | ||
104 | throw new StormDftException("Error during input/output handling of the stochastic solver.", e); | ||
105 | } else { | ||
106 | throw Exceptions.sneakyThrow(_t); | ||
107 | } | ||
108 | } | ||
109 | _xtrycatchfinallyexpression = _xtrycatchfinallyexpression_1; | ||
110 | } catch (final Throwable _t_1) { | ||
111 | if (_t_1 instanceof Exception) { | ||
112 | final Exception e_1 = (Exception)_t_1; | ||
113 | if ((process != null)) { | ||
114 | process.destroyForcibly().waitFor(); | ||
115 | } | ||
116 | throw e_1; | ||
117 | } else { | ||
118 | throw Exceptions.sneakyThrow(_t_1); | ||
119 | } | ||
120 | } | ||
121 | _xblockexpression = _xtrycatchfinallyexpression; | ||
122 | } | ||
123 | return _xblockexpression; | ||
124 | } catch (Throwable _e) { | ||
125 | throw Exceptions.sneakyThrow(_e); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | private ImmutableList<String> toCommandLine(@Extension final StormDftConfiguration configuration, final String dftFilePath) { | ||
130 | ImmutableList<String> _xblockexpression = null; | ||
131 | { | ||
132 | @Extension | ||
133 | final ImmutableList.Builder<String> optionsBuilder = ImmutableList.<String>builder(); | ||
134 | String _elvis = null; | ||
135 | if (configuration.solverPath != null) { | ||
136 | _elvis = configuration.solverPath; | ||
137 | } else { | ||
138 | _elvis = StormDftConfiguration.DEFAULT_SOLVER_PATH; | ||
139 | } | ||
140 | optionsBuilder.add(_elvis); | ||
141 | if ((configuration.runtimeLimit != SolverConfiguration.Unlimited)) { | ||
142 | optionsBuilder.add("--timeout", Integer.valueOf(configuration.runtimeLimit).toString()); | ||
143 | } | ||
144 | optionsBuilder.add("--precision", Double.valueOf(configuration.precision).toString()); | ||
145 | if (configuration.bisimulation) { | ||
146 | optionsBuilder.add("--bisimulation"); | ||
147 | } | ||
148 | if (configuration.symmetryReduction) { | ||
149 | optionsBuilder.add("--symmetryreduction"); | ||
150 | } | ||
151 | if (configuration.modularization) { | ||
152 | optionsBuilder.add("--modularisation"); | ||
153 | } | ||
154 | if ((!configuration.dontCarePropagation)) { | ||
155 | optionsBuilder.add("--disabledc"); | ||
156 | } | ||
157 | boolean _isApproximationInUse = configuration.isApproximationInUse(); | ||
158 | if (_isApproximationInUse) { | ||
159 | String _switchResult = null; | ||
160 | final ApproximationHeuristic approximationHeuristic = configuration.approximationHeuristic; | ||
161 | if (approximationHeuristic != null) { | ||
162 | switch (approximationHeuristic) { | ||
163 | case DEPTH: | ||
164 | _switchResult = "depth"; | ||
165 | break; | ||
166 | default: | ||
167 | throw new IllegalArgumentException(("Unknown approximation heuristic: " + configuration.approximationHeuristic)); | ||
168 | } | ||
169 | } else { | ||
170 | throw new IllegalArgumentException(("Unknown approximation heuristic: " + configuration.approximationHeuristic)); | ||
171 | } | ||
172 | final String heuristicName = _switchResult; | ||
173 | optionsBuilder.add("--approximation", Double.valueOf(configuration.approximation).toString(), "--approximationheuristic", heuristicName); | ||
174 | } | ||
175 | optionsBuilder.add("--dftfile", dftFilePath); | ||
176 | final FtAnalysisObjective objective = configuration.objective; | ||
177 | boolean _matched = false; | ||
178 | if (Objects.equal(objective, FtAnalysisObjective.MTTF)) { | ||
179 | _matched=true; | ||
180 | optionsBuilder.add("--expectedtime"); | ||
181 | } | ||
182 | if (!_matched) { | ||
183 | if (objective instanceof FtAnalysisObjective.TimeBound) { | ||
184 | _matched=true; | ||
185 | optionsBuilder.add("--timebound"); | ||
186 | } | ||
187 | } | ||
188 | if (!_matched) { | ||
189 | throw new IllegalArgumentException(("Unknown analysis objective: " + configuration.objective)); | ||
190 | } | ||
191 | boolean _equals = Objects.equal(configuration.documentationLevel, DocumentationLevel.FULL); | ||
192 | if (_equals) { | ||
193 | optionsBuilder.add("--verbose"); | ||
194 | } | ||
195 | _xblockexpression = optionsBuilder.build(); | ||
196 | } | ||
197 | return _xblockexpression; | ||
198 | } | ||
199 | |||
200 | private ReliabilityResult.Solution readOutput(final InputStream inputStream, final boolean printOutput) { | ||
201 | try { | ||
202 | Object _xblockexpression = null; | ||
203 | { | ||
204 | InputStreamReader _inputStreamReader = new InputStreamReader(inputStream); | ||
205 | final BufferedReader bufferedReader = new BufferedReader(_inputStreamReader); | ||
206 | try { | ||
207 | String line = null; | ||
208 | while (((line = bufferedReader.readLine()) != null)) { | ||
209 | { | ||
210 | if (printOutput) { | ||
211 | InputOutput.<String>println(line); | ||
212 | } | ||
213 | final Matcher matcher = StormDftHandler.RESULT_PATTERN.matcher(line); | ||
214 | boolean _find = matcher.find(); | ||
215 | if (_find) { | ||
216 | try { | ||
217 | final String single = matcher.group(StormDftHandler.SINGLE_RESULT_GROUP); | ||
218 | if ((single != null)) { | ||
219 | final double singleValue = Double.parseDouble(single); | ||
220 | return new ReliabilityResult.Solution(singleValue); | ||
221 | } | ||
222 | final String lower = matcher.group(StormDftHandler.LOWER_BOUND_GROUP); | ||
223 | final String upper = matcher.group(StormDftHandler.UPPER_BOUND_GROUP); | ||
224 | if (((lower != null) && (upper != null))) { | ||
225 | final double lowerValue = Double.parseDouble(lower); | ||
226 | final double upperValue = Double.parseDouble(upper); | ||
227 | return new ReliabilityResult.Solution(lowerValue, upperValue); | ||
228 | } | ||
229 | throw new StormDftException(("Inconsistent stochastic solver output: " + line)); | ||
230 | } catch (final Throwable _t) { | ||
231 | if (_t instanceof NumberFormatException) { | ||
232 | final NumberFormatException e = (NumberFormatException)_t; | ||
233 | throw new StormDftException("Malformatted number from stochastic solver.", e); | ||
234 | } else { | ||
235 | throw Exceptions.sneakyThrow(_t); | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | } finally { | ||
242 | bufferedReader.close(); | ||
243 | } | ||
244 | _xblockexpression = null; | ||
245 | } | ||
246 | return ((ReliabilityResult.Solution)_xblockexpression); | ||
247 | } catch (Throwable _e) { | ||
248 | throw Exceptions.sneakyThrow(_e); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | private String readError(final InputStream inputStream, final boolean printOutput) { | ||
253 | try { | ||
254 | String _xblockexpression = null; | ||
255 | { | ||
256 | InputStreamReader _inputStreamReader = new InputStreamReader(inputStream); | ||
257 | final BufferedReader bufferedReader = new BufferedReader(_inputStreamReader); | ||
258 | String _xtrycatchfinallyexpression = null; | ||
259 | try { | ||
260 | String _xblockexpression_1 = null; | ||
261 | { | ||
262 | final ArrayList<String> lines = CollectionLiterals.<String>newArrayList(); | ||
263 | String line = null; | ||
264 | while (((line = bufferedReader.readLine()) != null)) { | ||
265 | { | ||
266 | if (printOutput) { | ||
267 | System.err.println(line); | ||
268 | } | ||
269 | lines.add(line); | ||
270 | } | ||
271 | } | ||
272 | _xblockexpression_1 = IterableExtensions.join(lines, "\n"); | ||
273 | } | ||
274 | _xtrycatchfinallyexpression = _xblockexpression_1; | ||
275 | } finally { | ||
276 | bufferedReader.close(); | ||
277 | } | ||
278 | _xblockexpression = _xtrycatchfinallyexpression; | ||
279 | } | ||
280 | return _xblockexpression; | ||
281 | } catch (Throwable _e) { | ||
282 | throw Exceptions.sneakyThrow(_e); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | private ReliabilityResult.Unknown interpretExitStatus(final int exitValue, final String error) { | ||
287 | ReliabilityResult.Unknown _switchResult = null; | ||
288 | boolean _matched = false; | ||
289 | if (Objects.equal(exitValue, StormDftHandler.STORM_GENERAL_ERROR)) { | ||
290 | _matched=true; | ||
291 | throw new StormDftException(("Storm error: " + error)); | ||
292 | } | ||
293 | if (!_matched) { | ||
294 | if (Objects.equal(exitValue, StormDftHandler.STORM_TIMEOUT)) { | ||
295 | _matched=true; | ||
296 | } | ||
297 | if (!_matched) { | ||
298 | if (Objects.equal(exitValue, (StormDftHandler.SIGNAL_EXIT_VALUE_OFFSET + StormDftHandler.SIGXCPU))) { | ||
299 | _matched=true; | ||
300 | } | ||
301 | } | ||
302 | if (_matched) { | ||
303 | _switchResult = ReliabilityResult.TIMEOUT; | ||
304 | } | ||
305 | } | ||
306 | if (!_matched) { | ||
307 | if (Objects.equal(exitValue, StormDftHandler.STORM_MEMOUT)) { | ||
308 | _matched=true; | ||
309 | } | ||
310 | if (!_matched) { | ||
311 | if (Objects.equal(exitValue, (StormDftHandler.SIGNAL_EXIT_VALUE_OFFSET + StormDftHandler.SIGXFSZ))) { | ||
312 | _matched=true; | ||
313 | } | ||
314 | } | ||
315 | if (_matched) { | ||
316 | _switchResult = ReliabilityResult.MEMOUT; | ||
317 | } | ||
318 | } | ||
319 | if (!_matched) { | ||
320 | { | ||
321 | if ((exitValue > StormDftHandler.SIGNAL_EXIT_VALUE_OFFSET)) { | ||
322 | final int signalNumber = (exitValue - StormDftHandler.SIGNAL_EXIT_VALUE_OFFSET); | ||
323 | throw new StormDftException(((("Storm unexpectedly killed by signal " + Integer.valueOf(signalNumber)) + ": ") + error)); | ||
324 | } | ||
325 | throw new StormDftException(((("Storm unexpectedly exit with status " + Integer.valueOf(exitValue)) + ": ") + error)); | ||
326 | } | ||
327 | } | ||
328 | return _switchResult; | ||
329 | } | ||
330 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftSolver.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftSolver.java deleted file mode 100644 index 491e7fc1..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/transformation/solver/StormDftSolver.java +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ConstantModel; | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.FaultTree; | ||
6 | import hu.bme.mit.inf.dslreasoner.faulttree.model.ft.ReliabilityModel; | ||
7 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.ft2galileo.Ft2GalileoTransformation; | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.FtAnalysisObjective; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.ReliabilityResult; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.StormDftConfiguration; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver.StormDftHandler; | ||
12 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | ||
13 | |||
14 | @SuppressWarnings("all") | ||
15 | public class StormDftSolver { | ||
16 | private static final String DFT_FILE_NAME = "ft.dft"; | ||
17 | |||
18 | private final Ft2GalileoTransformation ft2Galileo = new Ft2GalileoTransformation(); | ||
19 | |||
20 | private final StormDftHandler handler = new StormDftHandler(); | ||
21 | |||
22 | public ReliabilityResult solve(final ReliabilityModel reliabilityModel, final StormDftConfiguration configuration, final ReasonerWorkspace reasonerWorkspace) { | ||
23 | ReliabilityResult _switchResult = null; | ||
24 | boolean _matched = false; | ||
25 | if (reliabilityModel instanceof FaultTree) { | ||
26 | _matched=true; | ||
27 | _switchResult = this.solve(((FaultTree)reliabilityModel), configuration, reasonerWorkspace); | ||
28 | } | ||
29 | if (!_matched) { | ||
30 | if (reliabilityModel instanceof ConstantModel) { | ||
31 | _matched=true; | ||
32 | ReliabilityResult.Solution _xblockexpression = null; | ||
33 | { | ||
34 | double _xifexpression = (double) 0; | ||
35 | boolean _isFailed = ((ConstantModel)reliabilityModel).isFailed(); | ||
36 | if (_isFailed) { | ||
37 | _xifexpression = 0; | ||
38 | } else { | ||
39 | double _switchResult_1 = (double) 0; | ||
40 | final FtAnalysisObjective objective = configuration.objective; | ||
41 | boolean _matched_1 = false; | ||
42 | if (Objects.equal(objective, FtAnalysisObjective.MTTF)) { | ||
43 | _matched_1=true; | ||
44 | _switchResult_1 = Double.POSITIVE_INFINITY; | ||
45 | } | ||
46 | if (!_matched_1) { | ||
47 | if (objective instanceof FtAnalysisObjective.TimeBound) { | ||
48 | _matched_1=true; | ||
49 | _switchResult_1 = 1; | ||
50 | } | ||
51 | } | ||
52 | if (!_matched_1) { | ||
53 | throw new IllegalArgumentException(("Unknown objective: " + objective)); | ||
54 | } | ||
55 | _xifexpression = _switchResult_1; | ||
56 | } | ||
57 | final double result = _xifexpression; | ||
58 | _xblockexpression = new ReliabilityResult.Solution(result); | ||
59 | } | ||
60 | _switchResult = _xblockexpression; | ||
61 | } | ||
62 | } | ||
63 | if (!_matched) { | ||
64 | throw new IllegalArgumentException(("Unknown reliability model: " + reliabilityModel)); | ||
65 | } | ||
66 | return _switchResult; | ||
67 | } | ||
68 | |||
69 | public ReliabilityResult solve(final FaultTree faultTree, final StormDftConfiguration configuration, final ReasonerWorkspace reasonerWorkspace) { | ||
70 | ReliabilityResult _xblockexpression = null; | ||
71 | { | ||
72 | final CharSequence galileo = this.ft2Galileo.toGalileo(faultTree); | ||
73 | reasonerWorkspace.writeText(StormDftSolver.DFT_FILE_NAME, galileo); | ||
74 | final String dftFilePath = reasonerWorkspace.getFile(StormDftSolver.DFT_FILE_NAME).getAbsolutePath(); | ||
75 | _xblockexpression = this.handler.callSolver(dftFilePath, configuration); | ||
76 | } | ||
77 | return _xblockexpression; | ||
78 | } | ||
79 | } | ||