Skip to content

Commit

Permalink
Merge pull request #74 from Brandhoej/fix/quotient
Browse files Browse the repository at this point in the history
Fix/quotient
  • Loading branch information
Brandhoej authored Oct 29, 2022
2 parents 9844195 + 9976b64 commit f349343
Show file tree
Hide file tree
Showing 48 changed files with 1,457 additions and 1,507 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
25 changes: 25 additions & 0 deletions samples/xml/selfloopNonZeno.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<nta>
<declaration>chan o;</declaration>
<template>
<name>SelfloopNonZenoCopy</name>
<declaration>clock xCopy; clock yCopy;</declaration>
<location id="id6" x="-85" y="51" color="#A66C0F">
<name>id6</name>
<label kind="invariant">(xCopy&lt;3 &amp;&amp; xCopy-yCopy&lt;3)</label>
</location>
<location id="id7" x="119" y="51" color="#A66C0F">
<name>id7</name>
<label kind="invariant">false</label>
</location>
<init ref="id6" />
<transition controllable="false">
<source ref="id6" />
<target ref="id6" />
<label kind="synchronisation">o!</label>
<label kind="guard">(xCopy&lt;3 &amp;&amp; xCopy-yCopy&lt;3)</label>
<label kind="assignment">xCopy = 0</label>
</transition>
</template>
<system>system SelfloopNonZenoCopy;</system>
</nta>
2 changes: 1 addition & 1 deletion src/connection/GrpcServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public GrpcServer(String address) {
}

private SocketAddress getSocketAddressFromString(String address) {
int port = 80;
int port = 9000;
String host = null;
if (address.indexOf(':') != -1) {
String[] arr = address.split(":");
Expand Down
12 changes: 8 additions & 4 deletions src/connection/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package connection;

import log.Log;
import log.Urgency;
import logic.*;
import logic.query.Query;
import models.Automaton;
Expand Down Expand Up @@ -45,6 +47,8 @@ public class Main {


public static void main(String[] args) {
Log.setUrgency(Urgency.Info);

options.addOption(proto);
options.addOption(outputFolder);
options.addOption(inputFolder);
Expand Down Expand Up @@ -93,12 +97,12 @@ public static void main(String[] args) {
queries = Controller.handleRequest("-json " + inputFolderPath, queryString, false);
}
for (Query query: queries) {
System.out.println(query.getResult());
System.out.println(query.getResultStrings());
Log.info(query.getResult());
Log.info(query.getResultStrings());
}

} catch (Exception e) {
System.out.println(e.getMessage());
Log.error(e.getMessage());
throw new RuntimeException(e);
}

Expand All @@ -108,7 +112,7 @@ public static void main(String[] args) {
}

} catch (ParseException e) {
System.out.println(e.getMessage());
Log.fatal(e.getMessage());
printHelp(formatter,options);
}

Expand Down
26 changes: 14 additions & 12 deletions src/logic/AggregatedTransitionSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<SimpleTransitionSystem> getSystems() {
}

@Override
public SymbolicLocation getInitialLocation() {
public Location getInitialLocation() {
return getInitialLocation(systems);
}

Expand Down Expand Up @@ -84,20 +84,19 @@ currentState, getNextMoves(currentState.getLocation(), channel), allClocks
}

@Override
public List<Move> getNextMoves(SymbolicLocation location, Channel channel) {
public List<Move> getNextMoves(Location location, Channel channel) {
// Check if action belongs to this transition system at all before proceeding
if (!getOutputs().contains(channel) && !getInputs().contains(channel)) {
return new ArrayList<>();
}

// Check that the location is ComplexLocation
if (!(location instanceof ComplexLocation)) {
if (!location.isComposed()) {
throw new IllegalArgumentException(
"The location type must be ComplexLocation as aggregated transition systems requires multiple locations"
);
}
ComplexLocation complexLocation = (ComplexLocation) location;
List<SymbolicLocation> locations = complexLocation.getLocations();
List<Location> locations = location.getChildren();

/* Check that the complex locations size is the same as the systems
* This is because the index of the system,
Expand All @@ -112,12 +111,18 @@ public List<Move> getNextMoves(SymbolicLocation location, Channel channel) {
return computeResultMoves(locations, channel);
}

protected abstract List<Move> computeResultMoves(List<SymbolicLocation> locations, Channel channel);
protected List<Move> computeResultMoves(List<Location> locations, Channel channel) {
return new ArrayList<>();
}

protected List<TransitionSystem> getRootSystems() {
return Arrays.asList(systems);
}

protected boolean in(Channel element, Set<Channel> set) {
return set.contains(element);
}

protected Set<Channel> intersect(Set<Channel> set1, Set<Channel> set2) {
Set<Channel> intersection = new HashSet<>(set1);
intersection.retainAll(set2);
Expand Down Expand Up @@ -145,11 +150,8 @@ private Automaton aggregate(Automaton[] automata) {
Set<Location> locations = new HashSet<>();
Map<String, Location> locationMap = new HashMap<>();

List<Location> initials = new ArrayList<>();
for (Automaton aut : automata) {
initials.add(aut.getInitial());
}
Location initial = new Location(initials);
State initialState = getInitialState();
Location initial = initialState.getLocation();
locations.add(initial);
locationMap.put(initial.getName(), initial);

Expand Down Expand Up @@ -183,7 +185,7 @@ private Automaton aggregate(Automaton[] automata) {
String targetName = targetState.getLocation().getName();
locationMap.computeIfAbsent(
targetName, key -> {
Location newLocation = new Location(targetState, clocks.getItems());
Location newLocation = Location.createFromState(targetState, clocks.getItems());
locations.add(newLocation);
return newLocation;
}
Expand Down
8 changes: 4 additions & 4 deletions src/logic/Bisimilarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static Automaton checkBisimilarity(Automaton aut1) {
List<Update> updates = edgeList.get(0).getUpdates();
CDD allCDDs = CDD.cddFalse();
for (Edge e : edgeList) {
CDD targetFedAfterReset = e.getTarget().getInvariantCDD();
CDD targetFedAfterReset = e.getTarget().getInvariantCdd();
targetFedAfterReset = targetFedAfterReset.applyReset(e.getUpdates());
allCDDs = allCDDs.disjunction(e.getGuardCDD().conjunction(targetFedAfterReset));

Expand Down Expand Up @@ -157,7 +157,7 @@ private static int getIndexOfClock(Clock clock, List<Clock> clocks) {

public static boolean hasDifferentZone(Location l1, Location l2, List<Clock> clocks)
{
if (l1.getInvariantCDD().equiv(l2.getInvariantCDD())) {
if (l1.getInvariantCdd().equiv(l2.getInvariantCdd())) {
return false;
}
return true;
Expand All @@ -176,8 +176,8 @@ public static boolean hasDifferentOutgoings(Location l1, Location l2, List<Clock
edgesL2.add(e);
}

CDD s1 = l1.getInvariantCDD();
CDD s2 = l2.getInvariantCDD();
CDD s1 = l1.getInvariantCdd();
CDD s2 = l2.getInvariantCdd();

for (Edge e1 : edgesL1)
{
Expand Down
4 changes: 2 additions & 2 deletions src/logic/Composition.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String getName() {
}

@Override
protected List<Move> computeResultMoves(List<SymbolicLocation> locations, Channel channel) {
protected List<Move> computeResultMoves(List<Location> locations, Channel channel) {
if (locations.size() != getRootSystems().size()) {
throw new IllegalArgumentException("There must be exactly the same amount of locations as systems");
}
Expand All @@ -93,7 +93,7 @@ protected List<Move> computeResultMoves(List<SymbolicLocation> locations, Channe
* the one of the composition meaning that the i'th
* location is also for the i'th system. */
TransitionSystem system = getRootSystems().get(i);
SymbolicLocation location = locations.get(i);
Location location = locations.get(i);

/* By iterating through all systems and then getting the next moves
* for each system we get a set of all next moves for all systems. */
Expand Down
4 changes: 2 additions & 2 deletions src/logic/Conjunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String getName() {
}

@Override
protected List<Move> computeResultMoves(List<SymbolicLocation> locations, Channel channel) {
protected List<Move> computeResultMoves(List<Location> locations, Channel channel) {
if (locations.size() != getRootSystems().size()) {
throw new IllegalArgumentException("There must be exactly the same amount of locations as systems");
}
Expand All @@ -52,7 +52,7 @@ protected List<Move> computeResultMoves(List<SymbolicLocation> locations, Channe
* the one of the composition meaning that the i'th
* location is also for the i'th system. */
TransitionSystem system = getRootSystems().get(i);
SymbolicLocation location = locations.get(i);
Location location = locations.get(i);

List<Move> moves = system.getNextMoves(location, channel);

Expand Down
2 changes: 1 addition & 1 deletion src/logic/JsonAutomatonEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static JSONObject automatonToJson(Automaton aut){
locationJson.put("y", l.getY());


String guardString =l.getInvariant().toString();
String guardString =l.getInvariantGuard().toString();
/*int i= 0; int j=0;
for (List<Guard> disjunction: l.getInvariant())
{
Expand Down
Loading

0 comments on commit f349343

Please sign in to comment.