Skip to content

Commit d559b1f

Browse files
authored
Merge pull request #3 from lip6/master
merging main code
2 parents d84e0f9 + 6e98581 commit d559b1f

File tree

33 files changed

+1607
-359
lines changed

33 files changed

+1607
-359
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ jobs:
3939
# You should create a personal access token and store it in your repository
4040
token: ${{ secrets.NOTIF_PAT }}
4141
repo: ITS-commandline
42-
owner: bnslmn
43-
event_type: rebuild
42+
owner: yanntm
43+
event_type: rebuild
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package fr.lip6.move.gal.mcc.properties;
2+
3+
import java.util.Map;
4+
import java.util.Map.Entry;
5+
import java.util.Set;
6+
import java.util.concurrent.ConcurrentHashMap;
7+
8+
public class ConcurrentHashDoneProperties implements DoneProperties {
9+
private Map<String,Boolean> map = new ConcurrentHashMap<>();
10+
11+
@Override
12+
public boolean containsKey(Object arg0) {
13+
return map.containsKey(arg0);
14+
}
15+
16+
@Override
17+
public Set<Entry<String, Boolean>> entrySet() {
18+
return map.entrySet();
19+
}
20+
21+
@Override
22+
public Boolean put(String prop, Boolean value, String techniques) {
23+
return map.put(prop, value);
24+
}
25+
26+
@Override
27+
public Boolean put(String prop, Integer value, String techniques) {
28+
return map.put(prop, true);
29+
}
30+
31+
@Override
32+
public Set<String> keySet() {
33+
return map.keySet();
34+
}
35+
36+
@Override
37+
public int size() {
38+
return map.size();
39+
}
40+
41+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package fr.lip6.move.gal.mcc.properties;
2+
3+
import java.util.Map.Entry;
4+
import java.util.Set;
5+
6+
public interface DoneProperties {
7+
8+
int size();
9+
10+
// A boolean result
11+
Boolean put(String prop, Boolean value, String techniques);
12+
// A numeric result
13+
Boolean put(String prop, Integer value, String techniques);
14+
15+
16+
Set<Entry<String, Boolean>> entrySet();
17+
18+
boolean containsKey(Object arg0);
19+
20+
Set<String> keySet();
21+
22+
}

fr.lip6.move.gal.structural/src/fr/lip6/move/gal/mcc/properties/PropertiesToPNML.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ private static Logger getLog() {
3737
* @return true if we had to introduce a special "one" place to represent constants.
3838
* @throws IOException
3939
*/
40-
public static boolean transform(SparsePetriNet spn, String path, Map<String, Boolean> doneProps) throws IOException {
40+
public static boolean transform(SparsePetriNet spn, String path, DoneProperties doneProps) throws IOException {
4141
long time = System.currentTimeMillis();
4242
PrintWriter pw = new PrintWriter(new File(path));
4343
pw.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
4444

4545
pw.append("<property-set xmlns=\"http://mcc.lip6.fr/\">\n");
4646
boolean usesConstants = false;
4747
for (Property prop : spn.getProperties()) {
48-
Boolean res = doneProps.get(prop.getName());
49-
if (res == null) {
48+
if (! doneProps.containsKey(prop.getName())) {
5049
pw.append(" <property>\n" +
5150
" <id>"+ prop.getName() +"</id>\n" +
5251
" <description>Automatically generated</description>\n" +

fr.lip6.move.gal.structural/src/fr/lip6/move/gal/structural/HLPlace.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ public class HLPlace {
77
int startIndex;
88
private int [] initial;
99
private boolean isConstant = false;
10-
public HLPlace(String name, int start, int [] initial) {
10+
private String sort;
11+
public HLPlace(String name, int start, int [] initial, String sname) {
1112
this.name = name;
1213
this.startIndex = start;
1314
this.initial = initial;
15+
this.sort = sname;
1416
}
1517
public String getName() {
1618
return name;
@@ -28,4 +30,7 @@ public boolean isConstant() {
2830
public int[] getInitial() {
2931
return initial;
3032
}
33+
public String getSort() {
34+
return sort;
35+
}
3136
}

fr.lip6.move.gal.structural/src/fr/lip6/move/gal/structural/RandomExplorer.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void updateEnabled (SparseIntArray state, int [] enabled, int tfired) {
123123
}
124124
}
125125
}
126-
public int[] runGuidedReachabilityDetection (long nbSteps, SparseIntArray parikhori, List<Expression> exprs, List<Integer> repr, int timeout) {
126+
public int[] runGuidedReachabilityDetection (long nbSteps, SparseIntArray parikhori, List<Expression> exprs, List<Integer> repr, int timeout, boolean max) {
127127
ThreadLocalRandom rand = ThreadLocalRandom.current();
128128

129129
Map<Integer, List<Integer>> repSet = computeMap(repr);
@@ -155,11 +155,15 @@ public int[] runGuidedReachabilityDetection (long nbSteps, SparseIntArray parikh
155155
System.out.println("Interrupted Parikh walk after "+ i + " steps, including "+nbresets+ " resets, run timeout after "+ dur +" ms. (steps per millisecond="+ (i/dur) +" )"+ " properties seen :" + Arrays.toString(verdicts) +(DEBUG >=1 ? (" reached state " + state):"") );
156156
return verdicts;
157157
}
158-
159-
if (! updateVerdicts(exprs, state, verdicts)) {
160-
System.out.println("Finished Parikh walk after "+ i + " steps, including "+nbresets+ " resets, run visited all " +exprs.size()+ " properties in "+ dur +" ms. (steps per millisecond="+ (i/dur) +" )"+ (DEBUG >=1 ? (" reached state " + state):"") );
161-
return verdicts;
158+
if (!max) {
159+
if (! updateVerdicts(exprs, state, verdicts)) {
160+
System.out.println("Finished Parikh walk after "+ i + " steps, including "+nbresets+ " resets, run visited all " +exprs.size()+ " properties in "+ dur +" ms. (steps per millisecond="+ (i/dur) +" )"+ (DEBUG >=1 ? (" reached state " + state):"") );
161+
return verdicts;
162+
}
163+
} else {
164+
updateMaxVerdicts(exprs, state, verdicts);
162165
}
166+
163167
if (list[0] == 0){
164168
//System.out.println("Dead end with self loop(s) found at step " + i);
165169
nbresets ++;
@@ -407,18 +411,18 @@ public int[] runRandomReachabilityDetection (long nbSteps, List<Expression> expr
407411
}
408412
} else {
409413
// heuristically follow a successor with "Best-first search"
410-
int minDist = Integer.MAX_VALUE;
414+
int minDist = max ? 0 :Integer.MAX_VALUE;
411415
List<Integer> mini = new ArrayList<>();
412416
List<SparseIntArray> bestSucc = new ArrayList<>();
413417
for (int ti = 1 ; ti-1 < list[0] && i < nbSteps; ti++) {
414418
SparseIntArray succ = fire(list[ti],state);
415-
int distance = exprs.get(bestFirst).evalDistance(succ, false);
416-
if (distance < minDist) {
419+
int distance = exprs.get(bestFirst).evalDistance(succ, false);
420+
if ( (!max && distance < minDist) || (max && distance > minDist)) {
417421
mini.clear();
418422
bestSucc.clear();
419423
minDist = distance;
420424
}
421-
if (distance <= minDist) {
425+
if ((!max && distance <= minDist) || (max && distance >= minDist)) {
422426
mini.add(list[ti]);
423427
bestSucc.add(succ);
424428
}

0 commit comments

Comments
 (0)