]> uap-core.de Git - petrinet.git/commitdiff
fixes non-deterministic selection of enabled transitions master
authorMike Becker <universe@uap-core.de>
Sun, 8 Dec 2019 10:10:46 +0000 (11:10 +0100)
committerMike Becker <universe@uap-core.de>
Sun, 8 Dec 2019 10:10:46 +0000 (11:10 +0100)
pom.xml
src/main/java/de/yasc/example/petrinet/Petrinet.java

diff --git a/pom.xml b/pom.xml
index 4c2b205464222c6de3475ea97c076335bd6c64e9..e4b00f0ff60a3417606116dbe4e4969b97b49dc7 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <groupId>de.yasc.example</groupId>
     <artifactId>petrinet</artifactId>
         <maven.compiler.source>11</maven.compiler.source>
         <maven.compiler.target>11</maven.compiler.target>
     </properties>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.6.0</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>java</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <mainClass>de.yasc.example.petrinet.Main</mainClass>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
\ No newline at end of file
index f8882f247685d2347a25020d72147370a7895520..994a037200c9bd7d5e30339b350c20617e585a72 100644 (file)
@@ -74,7 +74,7 @@ public final class Petrinet {
         if (enabledTransitions.isEmpty()) {
             return false;
         } else {
-            transitions.get(prng.nextInt(enabledTransitions.size())).fire();
+            enabledTransitions.get(prng.nextInt(enabledTransitions.size())).fire();
             return true;
         }
     }
@@ -92,7 +92,7 @@ public final class Petrinet {
     public Integer[] getMarking() {
         final var marking = new ArrayList<Integer>();
         for (int p = 0 ; p < places.length ; p++) {
-            Collections.nCopies(places[p].tokens, p).forEach(marking::add);
+            marking.addAll(Collections.nCopies(places[p].tokens, p));
         }
         return marking.toArray(new Integer[0]);
     }