|
|
|
@@ -74,11 +74,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
* Fuer die Threads
|
|
|
|
|
*/
|
|
|
|
|
UnifyResultModel urm;
|
|
|
|
|
protected static int noOfThread = 0;
|
|
|
|
|
private static int totalnoOfThread = 0;
|
|
|
|
|
int thNo;
|
|
|
|
|
protected boolean one = false;
|
|
|
|
|
Integer MaxNoOfThreads = 128;
|
|
|
|
|
|
|
|
|
|
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
|
|
|
|
Writer logFile;
|
|
|
|
@@ -132,6 +130,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
volatile UnifyTaskModel usedTasks;
|
|
|
|
|
|
|
|
|
|
static Writer statistics;
|
|
|
|
|
protected volatile ConstraintSetRepository constraintSetRepository;
|
|
|
|
|
|
|
|
|
|
public TypeUnifyTask() {
|
|
|
|
|
rules = new RuleSet();
|
|
|
|
@@ -152,11 +151,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//statistics
|
|
|
|
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, Writer statistics) {
|
|
|
|
|
this(eq,oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
|
|
|
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, ConstraintSetRepository constraintSetRepository, Writer statistics) {
|
|
|
|
|
this(eq,oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, constraintSetRepository);
|
|
|
|
|
this.statistics = statistics;
|
|
|
|
|
}
|
|
|
|
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
|
|
|
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, ConstraintSetRepository constraintSetRepository) {
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
if(statistics==null){
|
|
|
|
|
statistics = new NullWriter();
|
|
|
|
@@ -179,8 +178,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
this.parallel = parallel;
|
|
|
|
|
this.logFile = logFile;
|
|
|
|
|
this.log = log;
|
|
|
|
|
|
|
|
|
|
noOfThread++;
|
|
|
|
|
|
|
|
|
|
totalnoOfThread++;
|
|
|
|
|
//writeLog("thNo1 " + thNo);
|
|
|
|
|
thNo = totalnoOfThread;
|
|
|
|
@@ -212,6 +210,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
this.urm = urm;
|
|
|
|
|
this.usedTasks = usedTasks;
|
|
|
|
|
this.usedTasks.add(this);
|
|
|
|
|
this.constraintSetRepository = constraintSetRepository;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -269,7 +268,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
.filter(x -> x.size()>1)
|
|
|
|
|
.collect(Collectors.toCollection(ArrayList::new));
|
|
|
|
|
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
|
|
|
|
noOfThread--;
|
|
|
|
|
try {
|
|
|
|
|
logFile.close();
|
|
|
|
|
}
|
|
|
|
@@ -689,15 +687,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
System.out.print("");
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
|
|
|
|
int variance = 0;
|
|
|
|
|
|
|
|
|
|
/* Varianzbestimmung Anfang
|
|
|
|
|
* Oderconstraint, wenn entweder kein Basepair oder unterschiedliche Basepairs => oderConstraint = true;
|
|
|
|
|
* Varianz = 1 => Argumentvariable
|
|
|
|
|
* Varianz = -1 => Rückgabevariable
|
|
|
|
|
* Varianz = 0 => unklar
|
|
|
|
|
* Varianz = 2 => Operatoren oderConstraints */
|
|
|
|
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
ArrayList<UnifyPair> zeroNextElem = new ArrayList<>(nextSetasList.get(0));
|
|
|
|
|
UnifyPair fstBasePair = zeroNextElem.remove(0).getBasePair();
|
|
|
|
|
Boolean oderConstraint = false;
|
|
|
|
@@ -715,9 +706,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
.filter(d -> d.isPresent())
|
|
|
|
|
.map(e -> e.get())
|
|
|
|
|
.findAny();
|
|
|
|
|
if (xi.isPresent()) {
|
|
|
|
|
variance = xi.get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
oderConstraint = true;
|
|
|
|
@@ -726,29 +714,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
else {
|
|
|
|
|
oderConstraint = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Varianz-Bestimmung Oder-Constraints
|
|
|
|
|
if (oderConstraint) {
|
|
|
|
|
if (printtag) System.out.println("nextSetasList " + nextSetasList);
|
|
|
|
|
Optional<Integer> optVariance =
|
|
|
|
|
nextSetasList.iterator()
|
|
|
|
|
.next()
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(x -> x.getGroundBasePair().getLhsType() instanceof PlaceholderType &&
|
|
|
|
|
! (x.getRhsType() instanceof PlaceholderType) &&
|
|
|
|
|
x.getPairOp() == PairOperator.EQUALSDOT)
|
|
|
|
|
.map(x ->
|
|
|
|
|
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
|
|
|
|
|
.reduce((n,m) -> { if ((n == 0) && (m==0)) return 0;
|
|
|
|
|
else if (n !=0) return n; //es muss mindestens eine Variance != 0 sein
|
|
|
|
|
else return m;
|
|
|
|
|
});
|
|
|
|
|
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt.
|
|
|
|
|
//da kein Receiver existiert also kein x.getGroundBasePair().getLhsType() instanceof PlaceholderType
|
|
|
|
|
//Bei Varianz = 2 werden alle Elemente des Kartesischen Produkts abgearbeitet
|
|
|
|
|
variance = optVariance.isPresent() ? optVariance.get() : 2;
|
|
|
|
|
}
|
|
|
|
|
/* Varianzbestimmung Ende */
|
|
|
|
|
|
|
|
|
|
//writeLog("nextSetasList: " + nextSetasList.toString());
|
|
|
|
|
Set<UnifyPair> nextSetElem = nextSetasList.get(0);
|
|
|
|
@@ -815,80 +780,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
|
|
|
|
|
writeLog("nextSet: " + nextSet.toString());
|
|
|
|
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
|
|
|
|
|
|
|
|
|
/* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang
|
|
|
|
|
if (variance == 1) {
|
|
|
|
|
a = oup.max(nextSetasList.iterator());
|
|
|
|
|
nextSetasList.remove(a);
|
|
|
|
|
if (oderConstraint) {
|
|
|
|
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)a).getExtendConstraint());
|
|
|
|
|
}
|
|
|
|
|
writeLog("nextSetasListOderConstraints 1: " + nextSetasListOderConstraints);
|
|
|
|
|
nextSetasListRest = new ArrayList<>(nextSetasList);
|
|
|
|
|
Iterator<Set<UnifyPair>> nextSetasListItRest = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
|
|
|
|
|
while (nextSetasListItRest.hasNext()) {
|
|
|
|
|
Set<UnifyPair> a_next = nextSetasListItRest.next();
|
|
|
|
|
if (//a.equals(a_next) ||
|
|
|
|
|
(oup.compare(a, a_next) == 1)) {
|
|
|
|
|
nextSetasListRest.remove(a_next);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Alle maximale Elemente in nextSetasListRest bestimmen
|
|
|
|
|
//nur für diese wird parallele Berechnung angestossen.
|
|
|
|
|
nextSetasListRest = oup.maxElements(nextSetasListRest);
|
|
|
|
|
}
|
|
|
|
|
else if (variance == -1) {
|
|
|
|
|
a = oup.min(nextSetasList.iterator());
|
|
|
|
|
writeLog("Min: a in " + variance + " "+ a);
|
|
|
|
|
if (oderConstraint) {
|
|
|
|
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)a).getExtendConstraint());
|
|
|
|
|
}
|
|
|
|
|
writeLog("nextSetasListOderConstraints -1: " + nextSetasListOderConstraints);
|
|
|
|
|
nextSetasList.remove(a);
|
|
|
|
|
nextSetasListRest = new ArrayList<>(nextSetasList);
|
|
|
|
|
Iterator<Set<UnifyPair>> nextSetasListItRest = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
|
|
|
|
|
while (nextSetasListItRest.hasNext()) {
|
|
|
|
|
Set<UnifyPair> a_next = nextSetasListItRest.next();
|
|
|
|
|
if (//a.equals(a_next) ||
|
|
|
|
|
(oup.compare(a, a_next) == -1)) {
|
|
|
|
|
nextSetasListRest.remove(a_next);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Alle minimalen Elemente in nextSetasListRest bestimmen
|
|
|
|
|
//nur für diese wird parallele Berechnung angestossen.
|
|
|
|
|
nextSetasListRest = oup.minElements(nextSetasListRest);
|
|
|
|
|
}
|
|
|
|
|
else if (variance == 2) {
|
|
|
|
|
a = nextSetasList.remove(0);
|
|
|
|
|
|
|
|
|
|
//Fuer alle Elemente wird parallele Berechnung angestossen.
|
|
|
|
|
nextSetasListRest = new ArrayList<>(nextSetasList);
|
|
|
|
|
}
|
|
|
|
|
else if (variance == 0) {
|
|
|
|
|
//wenn a <. theta dann ist ein maximales Element sehr wahrscheinlich
|
|
|
|
|
//wenn theta <. a dann ist ein minimales Element sehr wahrscheinlich
|
|
|
|
|
if (!oderConstraint && optOrigPair != null && optOrigPair.isPresent()) {
|
|
|
|
|
if (optOrigPair.get().getBasePair().getLhsType() instanceof PlaceholderType) {
|
|
|
|
|
a = oup.max(nextSetasList.iterator());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a = oup.min(nextSetasList.iterator());
|
|
|
|
|
}
|
|
|
|
|
nextSetasList.remove(a);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (oderConstraint) {
|
|
|
|
|
a = oup.max(nextSetasList.iterator());
|
|
|
|
|
nextSetasList.remove(a);
|
|
|
|
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)a).getExtendConstraint());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a = nextSetasList.remove(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Nextvar an Hand Varianzbestimmung auskommentieren Ende */
|
|
|
|
|
|
|
|
|
|
a = nextSetasList.remove(0); //statisticsList
|
|
|
|
|
|
|
|
|
|
//writeStatistics(a.toString());
|
|
|
|
@@ -899,7 +791,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(oneElems);
|
|
|
|
|
writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n");
|
|
|
|
|
|
|
|
|
|
//Ergebnisvariable für den aktuelle Thread
|
|
|
|
|
Set<Set<UnifyPair>> res = new HashSet<>();
|
|
|
|
@@ -924,292 +815,49 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
/* Wenn parallel gearbeitet wird, wird je nach Varianz ein neuer Thread
|
|
|
|
|
* gestartet, der parallel weiterarbeitet.
|
|
|
|
|
*/
|
|
|
|
|
if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) {
|
|
|
|
|
if(parallel){
|
|
|
|
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
|
|
|
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
|
|
|
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
|
|
|
|
List<Set<Constraint<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
|
|
|
|
newElemsOrig.add(a);
|
|
|
|
|
|
|
|
|
|
/* FORK ANFANG */
|
|
|
|
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, methodSignatureConstraint);
|
|
|
|
|
//forks.add(forkOrig);
|
|
|
|
|
synchronized(usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
forkOrig.fork();
|
|
|
|
|
}
|
|
|
|
|
/* FORK ENDE */
|
|
|
|
|
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
writeLog("a in " + variance + " "+ a);
|
|
|
|
|
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
|
|
|
|
}
|
|
|
|
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, methodSignatureConstraint, constraintSetRepository);
|
|
|
|
|
forkOrig.fork();
|
|
|
|
|
|
|
|
|
|
while (!nextSetasList.isEmpty()) {
|
|
|
|
|
Set<UnifyPair> nSaL = nextSetasList.remove(0);
|
|
|
|
|
synchronized (this) { //nextSetasList.remove(nSaL);
|
|
|
|
|
writeLog("1 RM" + nSaL.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!oderConstraint) {
|
|
|
|
|
|
|
|
|
|
/* statistics sameEq wird nicht betrachtet ANGFANG
|
|
|
|
|
//ueberpruefung ob zu a =. ty \in nSaL in sameEqSet ein Widerspruch besteht
|
|
|
|
|
if (!sameEqSet.isEmpty() && !checkNoContradiction(nSaL, sameEqSet, result)) {
|
|
|
|
|
nSaL = null;
|
|
|
|
|
noShortendElements++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
statistics sameEq wird nicht betrachtet ENDE */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)nSaL).getExtendConstraint());
|
|
|
|
|
Set<UnifyPair> nSaL = nextSetasList.removeFirst();
|
|
|
|
|
|
|
|
|
|
if (oderConstraint) {
|
|
|
|
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>) nSaL).getExtendConstraint());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
|
|
|
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
|
|
|
|
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
|
|
|
|
newElems.add(nSaL);
|
|
|
|
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, new HashSet<>(methodSignatureConstraint));
|
|
|
|
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, new HashSet<>(methodSignatureConstraint), constraintSetRepository);
|
|
|
|
|
forks.add(fork);
|
|
|
|
|
synchronized(usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
fork.fork();
|
|
|
|
|
}
|
|
|
|
|
fork.fork();
|
|
|
|
|
}
|
|
|
|
|
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
|
|
|
|
|
|
|
|
|
|
/* FORK ANFANG */
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
writeLog("wait "+ forkOrig.thNo);
|
|
|
|
|
noOfThread--;
|
|
|
|
|
res = forkOrig.join();
|
|
|
|
|
synchronized (usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
forkOrig.writeLog("final Orig 1");
|
|
|
|
|
forkOrig.closeLogFile();
|
|
|
|
|
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
|
|
|
|
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
|
|
|
|
|
//noOfThread--; an das Ende von compute verschoben
|
|
|
|
|
//add_res.add(fork_res);
|
|
|
|
|
};
|
|
|
|
|
/* FORK ENDE */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = forkOrig.join();
|
|
|
|
|
|
|
|
|
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
|
|
|
|
for(TypeUnify2Task fork : forks) {
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
noOfThread--;
|
|
|
|
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
|
|
|
|
synchronized (usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
|
|
|
|
//noOfThread--; an das Ende von compute verschoben
|
|
|
|
|
writeLog("fork_res: " + fork_res.toString());
|
|
|
|
|
writeLog(new Boolean((isUndefinedPairSetSet(fork_res))).toString());
|
|
|
|
|
add_res.add(fork_res);
|
|
|
|
|
if (!isUndefinedPairSetSet(fork_res)) {
|
|
|
|
|
aParDef.add(fork.getNextSetElement());
|
|
|
|
|
}
|
|
|
|
|
fork.writeLog("final 1");
|
|
|
|
|
fork.closeLogFile();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
} else {
|
|
|
|
|
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
|
|
|
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
|
|
|
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
|
|
|
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
|
|
|
|
List<Set<Constraint<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
|
|
|
|
newElemsOrig.add(a);
|
|
|
|
|
|
|
|
|
|
/* FORK ANFANG */
|
|
|
|
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, new HashSet<>(methodSignatureConstraint));
|
|
|
|
|
//forks.add(forkOrig);
|
|
|
|
|
synchronized(usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
forkOrig.fork();
|
|
|
|
|
}
|
|
|
|
|
/* FORK ENDE */
|
|
|
|
|
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
writeLog("a in " + variance + " "+ a);
|
|
|
|
|
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
|
|
|
|
}
|
|
|
|
|
while (!nextSetasList.isEmpty()) {
|
|
|
|
|
Set<UnifyPair> nSaL = nextSetasList.remove(0);
|
|
|
|
|
synchronized (this) { //nextSetasList.remove(nSaL);
|
|
|
|
|
writeLog("-1 RM" + nSaL.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!oderConstraint) {
|
|
|
|
|
/* statistics sameEq wird nicht betrachtet ANGFANG
|
|
|
|
|
//ueberpruefung ob zu a =. ty \in nSaL in sameEqSet ein Widerspruch besteht
|
|
|
|
|
if (!sameEqSet.isEmpty() && !checkNoContradiction(nSaL, sameEqSet, result)) {
|
|
|
|
|
nSaL = null;
|
|
|
|
|
noShortendElements++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
statistics sameEq wird nicht betrachtet ENDE */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)nSaL).getExtendConstraint());
|
|
|
|
|
}
|
|
|
|
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
|
|
|
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
|
|
|
|
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
|
|
|
|
newElems.add(nSaL);
|
|
|
|
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, new HashSet<>(methodSignatureConstraint));
|
|
|
|
|
forks.add(fork);
|
|
|
|
|
synchronized(usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
fork.fork();
|
|
|
|
|
for (TypeUnify2Task fork : forks) {
|
|
|
|
|
Set<Set<UnifyPair>> fork_res = new HashSet<>();
|
|
|
|
|
fork_res = fork.join();
|
|
|
|
|
add_res.add(fork_res);
|
|
|
|
|
if (!isUndefinedPairSetSet(fork_res)) {
|
|
|
|
|
aParDef.add(fork.getNextSetElement());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
|
|
|
|
|
|
|
|
|
|
/* FORK ANFANG */
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
writeLog("wait "+ forkOrig.thNo);
|
|
|
|
|
noOfThread--;
|
|
|
|
|
res = forkOrig.join();
|
|
|
|
|
synchronized (usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
forkOrig.writeLog("final Orig -1");
|
|
|
|
|
forkOrig.closeLogFile();
|
|
|
|
|
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
|
|
|
|
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
|
|
|
|
|
//noOfThread--; an das Ende von compute verschoben
|
|
|
|
|
//add_res.add(fork_res);
|
|
|
|
|
};
|
|
|
|
|
/* FORK ENDE */
|
|
|
|
|
|
|
|
|
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
|
|
|
|
for(TypeUnify2Task fork : forks) {
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
noOfThread--;
|
|
|
|
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
|
|
|
|
synchronized (usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
|
|
|
|
//noOfThread--; an das Ende von compute verschoben
|
|
|
|
|
writeLog("fork_res: " + fork_res.toString());
|
|
|
|
|
writeLog(new Boolean((isUndefinedPairSetSet(fork_res))).toString());
|
|
|
|
|
add_res.add(fork_res);
|
|
|
|
|
if (!isUndefinedPairSetSet(fork_res)) {
|
|
|
|
|
aParDef.add(fork.getNextSetElement());
|
|
|
|
|
}
|
|
|
|
|
fork.writeLog("final -1");
|
|
|
|
|
fork.closeLogFile();
|
|
|
|
|
};
|
|
|
|
|
}else{
|
|
|
|
|
elems.add(a);
|
|
|
|
|
//Überprüfen ob das Set bereits berechnet wurde
|
|
|
|
|
if(!constraintSetRepository.containsSet(elems)){
|
|
|
|
|
res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe, new HashSet<>(methodSignatureConstraint));
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
} else {
|
|
|
|
|
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
|
|
|
|
|
writeLog("var2einstieg");
|
|
|
|
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
|
|
|
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
|
|
|
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
|
|
|
|
List<Set<Constraint<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
|
|
|
|
newElemsOrig.add(a);
|
|
|
|
|
|
|
|
|
|
/* FORK ANFANG */
|
|
|
|
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, new HashSet<>(methodSignatureConstraint));
|
|
|
|
|
//forks.add(forkOrig);
|
|
|
|
|
synchronized(usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
forkOrig.fork();
|
|
|
|
|
}
|
|
|
|
|
/* FORK ENDE */
|
|
|
|
|
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
writeLog("a in " + variance + " "+ a);
|
|
|
|
|
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
|
|
|
|
}
|
|
|
|
|
while (!nextSetasList.isEmpty()) {
|
|
|
|
|
Set<UnifyPair> nSaL = nextSetasList.remove(0);
|
|
|
|
|
//nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03
|
|
|
|
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
|
|
|
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
|
|
|
|
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
|
|
|
|
newElems.add(nSaL);
|
|
|
|
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, methodSignatureConstraint);
|
|
|
|
|
forks.add(fork);
|
|
|
|
|
synchronized(usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
fork.fork();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
|
|
|
|
|
|
|
|
|
|
/* FORK ANFANG */
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
writeLog("wait "+ forkOrig.thNo);
|
|
|
|
|
noOfThread--;
|
|
|
|
|
res = forkOrig.join();
|
|
|
|
|
synchronized (usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
forkOrig.writeLog("final Orig 2");
|
|
|
|
|
forkOrig.closeLogFile();
|
|
|
|
|
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
|
|
|
|
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
|
|
|
|
|
//noOfThread--; an das Ende von compute verschoben
|
|
|
|
|
//add_res.add(fork_res); //vermutlich falsch
|
|
|
|
|
};
|
|
|
|
|
/* FORK ENDE */
|
|
|
|
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
|
|
|
|
for(TypeUnify2Task fork : forks) {
|
|
|
|
|
synchronized (this) {
|
|
|
|
|
noOfThread--;
|
|
|
|
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
|
|
|
|
synchronized (usedTasks) {
|
|
|
|
|
if (this.myIsCancelled()) {
|
|
|
|
|
return new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
|
|
|
|
//noOfThread--; an das Ende von compute verschoben
|
|
|
|
|
add_res.add(fork_res);
|
|
|
|
|
fork.writeLog("final 2");
|
|
|
|
|
fork.closeLogFile();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//noOfThread++;
|
|
|
|
|
} else {//parallel = false oder MaxNoOfThreads ist erreicht, sequentiell weiterarbeiten
|
|
|
|
|
elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859
|
|
|
|
|
res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe, new HashSet<>(methodSignatureConstraint));
|
|
|
|
|
}}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ab hier alle parallele Berechnungen wieder zusammengeführt.
|
|
|
|
|
//if (hilf == 1)
|
|
|
|
@@ -2612,7 +2260,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|
|
|
|
if (log && finalresult) {
|
|
|
|
|
try {
|
|
|
|
|
logFile.write("Thread no.:" + thNo + "\n");
|
|
|
|
|
logFile.write("noOfThread:" + noOfThread + "\n");
|
|
|
|
|
logFile.write("parallel:" + parallel + "\n");
|
|
|
|
|
logFile.write(str+"\n\n");
|
|
|
|
|
logFile.flush();
|
|
|
|
|