Commit 20742466 authored by Klaus Hamberger's avatar Klaus Hamberger
Browse files

Debugged circuit search by formula (with upper limit).

git-svn-id: svn+ssh://svn.code.sf.net/p/tip-puck/code/trunk@2320 fbf60bc9-78ff-467a-80f5-d9f1d8e511fc
parent 8badec00
......@@ -670,6 +670,42 @@ public class CircuitFinder {
return result;
}*/
private static ArrayList<String> formulae(String str) {
ArrayList<String> result;
result = new ArrayList<String>();
String[] strs = str.split("\\.");
ArrayList<String>[] consanguineFormulae = new ArrayList[strs.length];
for (int i=0;i<strs.length;i++){
consanguineFormulae[i] = consanguineFormulae(strs[i]);
}
result.addAll(consanguineFormulae[0]);
for (int i=1;i<strs.length;i++){
ArrayList<String> truncateResult = result;
result = new ArrayList<String>();
for (String trunk : truncateResult){
for (String tip : consanguineFormulae[i]){
result.add(trunk+"."+tip);
}
}
}
//
return result;
}
/**
* gets the list of all formulae for chains whose formula are contained in a
* given formula
......@@ -681,22 +717,63 @@ public class CircuitFinder {
* @return the list of included formulae
* @see groups.RingGroup#RingGroup(boolean, String, int, int, int)
*/
private static ArrayList<String> formulae(String str) {
ArrayList<String> formulae = new ArrayList<String>();
private static ArrayList<String> consanguineFormulae(String str) {
ArrayList<String> result;
int left = 0;
int right = 0;
if (str.indexOf("(")>-1){
left = str.indexOf("(");
}
if (str.indexOf(")")>-1){
right = str.length()-1-str.indexOf(")");
}
result = new ArrayList<String>();
str = str.replaceAll("\\(\\)", "\\(X\\)");
String strinv = inverse(str);
String s = "(X)X";
int i = 0;
while (!s.equals(str) && !s.equals(strinv)) {
if (i % 2 == 0) {
s = "X" + s;
} else {
s = s + "X";
ArrayList<String> leftStrings = new ArrayList<String>();
ArrayList<String> rightStrings = new ArrayList<String>();
String leftString = "";
String rightString = "";
leftStrings.add(leftString);
rightStrings.add(rightString);
for (int i=0;i<left;i++){
leftString += "X";
leftStrings.add(leftString);
}
for (int i=0;i<right;i++){
rightString += "X";
rightStrings.add(rightString);
}
for (String leftStr : leftStrings){
for (String rightStr : rightStrings){
String totalStr = leftStr+"(X)"+rightStr;
if (!result.contains(totalStr) && !result.contains(inverse(totalStr))){
result.add(totalStr);
}
}
i++;
formulae.add(s);
}
return formulae;
//
return result;
}
/**
......@@ -1227,7 +1304,7 @@ public class CircuitFinder {
break;
case LASTMARRIED:
// result = !targetDomain.contains(chain.getLastMarried());
result = (!familyDomain.contains(chain.getLastMarriage(familyCompareDomain)));
result = (familyDomain!=familyCompareDomain && !familyDomain.contains(chain.getLastMarriage(familyCompareDomain)));
break;
/* case EGO:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment