Commit 42d1e639 authored by Daniel Le Berre's avatar Daniel Le Berre

StringBuffer -> StringBuilder.

parent 9aed674b
Pipeline #83 passed with stage
in 11 minutes and 40 seconds
......@@ -63,7 +63,7 @@ public class AraliaParser {
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(this.nodeType.getPrefix());
if (this.nodeType == LogicFormulaNodeType.TERM) {
sb.append(this.label);
......@@ -177,7 +177,7 @@ public class AraliaParser {
private LogicFormulaNode readTerm(String s) {
LogicFormulaNode node = new LogicFormulaNode(LogicFormulaNodeType.TERM);
StringBuffer label = new StringBuffer();
StringBuilder label = new StringBuilder();
for (char c : s.toCharArray()) {
if ((c != '(') && (c != ')')) {
label.append(c);
......
......@@ -200,7 +200,7 @@ public class Br4cpAraliaReader {
private String removeSpaces(String line) {
char[] chars = line.toCharArray();
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < chars.length; ++i) {
if (chars[i] != ' ') {
sb.append(chars[i]);
......
......@@ -32,7 +32,7 @@ public class Options {
}
public void parseCommandLine(String args[]) {
StringBuffer errBuff = new StringBuffer();
StringBuilder errBuff = new StringBuilder();
for (String arg : args) {
if (arg.startsWith("-")) {
try {
......
......@@ -82,7 +82,7 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
protected transient PrintWriter out = new PrintWriter(System.out, true);
private StringBuffer logBuffer;
private StringBuilder logBuffer;
private boolean displaySolutionLine = true;
......@@ -429,7 +429,7 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
}
protected void bufferizeLog() {
this.logBuffer = new StringBuffer();
this.logBuffer = new StringBuilder();
}
protected void flushLog() {
......
......@@ -342,7 +342,7 @@ public final class Vec<T> implements IVec<T> {
*/
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int i = 0; i < this.nbelem - 1; i++) {
stb.append(this.myarray[i]);
stb.append(","); //$NON-NLS-1$
......
......@@ -348,7 +348,7 @@ public final class VecInt implements IVecInt {
*/
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int i = 0; i < this.nbelem - 1; i++) {
stb.append(this.myarray[i]);
stb.append(","); //$NON-NLS-1$
......
......@@ -309,7 +309,7 @@ public class AtLeast implements Propagatable, Constr, Undoable, Serializable {
*/
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
stb.append("Card (" + this.lits.length + ") : ");
for (int lit : this.lits) {
// if (voc.isUnassigned(lits[i])) {
......@@ -413,7 +413,7 @@ public class AtLeast implements Propagatable, Constr, Undoable, Serializable {
}
public String toString(VarMapper mapper) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int lit : this.lits) {
stb.append(" + "); //$NON-NLS-1$
stb.append(mapper.map(LiteralsUtils.toDimacs(lit)));
......
......@@ -374,7 +374,7 @@ public final class MaxWatchCard
*/
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
if (this.lits.length > 0) {
if (this.voc.isUnassigned(this.lits[0])) {
......@@ -509,7 +509,7 @@ public final class MaxWatchCard
}
public String toString(VarMapper mapper) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
if (this.lits.length > 0) {
if (this.voc.isUnassigned(this.lits[0])) {
......
......@@ -438,7 +438,7 @@ public class MinWatchCard
*/
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
// stb.append("Card (" + this.lits.length + ") : ");
if (this.lits.length > 0) {
// if (voc.isUnassigned(lits[0])) {
......@@ -734,7 +734,7 @@ public class MinWatchCard
if (mapper == null) {
return toString();
}
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
// stb.append("Card (" + this.lits.length + ") : ");
if (this.lits.length > 0) {
// if (voc.isUnassigned(lits[0])) {
......
......@@ -151,7 +151,7 @@ public abstract class BinaryClause implements Propagatable, Constr,
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
stb.append(Lits.toString(this.head));
stb.append("["); //$NON-NLS-1$
stb.append(this.voc.valueToString(this.head));
......@@ -283,7 +283,7 @@ public abstract class BinaryClause implements Propagatable, Constr,
if (mapper == null) {
return toString();
}
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
stb.append(mapper.map(LiteralsUtils.toDimacs(this.head)));
stb.append("["); //$NON-NLS-1$
stb.append(this.voc.valueToString(this.head));
......
......@@ -259,7 +259,7 @@ public class CBClause implements Constr, Undoable, Propagatable, Serializable {
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int i = 0; i < lits.length; i++) {
stb.append(lits[i]);
stb.append("["); //$NON-NLS-1$
......
......@@ -194,7 +194,7 @@ public abstract class HTClause implements Propagatable, Constr, Serializable {
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
stb.append(Lits.toString(this.head));
stb.append("["); //$NON-NLS-1$
stb.append(this.voc.valueToString(this.head));
......@@ -351,7 +351,7 @@ public abstract class HTClause implements Propagatable, Constr, Serializable {
}
public String toString(VarMapper mapper) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
stb.append(mapper.map(LiteralsUtils.toDimacs(this.head)));
stb.append("["); //$NON-NLS-1$
stb.append(this.voc.valueToString(this.head));
......
......@@ -169,7 +169,7 @@ public abstract class WLClause implements Propagatable, Constr, Serializable {
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int lit : this.lits) {
stb.append(Lits.toString(lit));
stb.append("["); //$NON-NLS-1$
......@@ -184,7 +184,7 @@ public abstract class WLClause implements Propagatable, Constr, Serializable {
if (mapper == null) {
return toString();
}
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int lit : this.lits) {
stb.append(mapper.map(LiteralsUtils.toDimacs(lit)));
stb.append("["); //$NON-NLS-1$
......
......@@ -102,7 +102,7 @@ public final class IntQueue implements Serializable {
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
stb.append(">"); //$NON-NLS-1$
for (int i = this.first; i < this.size - 1; i++) {
stb.append(this.myarray[i]);
......
......@@ -109,7 +109,7 @@ public class SearchParams implements Serializable {
*/
@Override
public String toString() {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (Field field : SearchParams.class.getDeclaredFields()) {
if (!field.getName().startsWith("serial")
&& !field.getName().startsWith("class")) {
......
......@@ -2019,7 +2019,7 @@ public class Solver<D extends DataStructureFactory>
* @see java.lang.Object#toString()
*/
public String toString(String prefix) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
Object[] objs = { this.dsfactory, this.learner, this.params, this.order,
this.simplifier, this.restarter,
this.learnedConstraintsDeletionStrategy };
......
......@@ -63,7 +63,7 @@ public class AAGReader extends Reader {
@Override
public String decode(int[] model) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int i = 0; i < this.nbinputs; i++) {
stb.append(model[i] > 0 ? 1 : 0);
}
......
......@@ -62,7 +62,7 @@ public class AIGReader extends Reader {
@Override
public String decode(int[] model) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int i = 0; i < this.nbinputs; i++) {
stb.append(model[i] > 0 ? 1 : 0);
}
......
......@@ -263,7 +263,7 @@ public class DimacsReader extends Reader implements Serializable {
@Override
public String decode(int[] model) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int element : model) {
stb.append(element);
stb.append(" ");
......
......@@ -124,7 +124,7 @@ public class EfficientScanner implements Serializable {
}
public BigInteger nextBigInteger() throws IOException, ParseFormatException {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
char currentChar = skipSpaces();
if (currentChar == '-') {
stb.append(currentChar);
......@@ -149,7 +149,7 @@ public class EfficientScanner implements Serializable {
* never used in that method.
*/
public String next() throws IOException, ParseFormatException {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
char currentChar = skipSpaces();
while (currentChar != ' ' && currentChar != '\n') {
stb.append(currentChar);
......@@ -169,7 +169,7 @@ public class EfficientScanner implements Serializable {
}
public String nextLine() throws IOException {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
char car;
do {
car = (char) this.in.read();
......
......@@ -254,7 +254,7 @@ public class LecteurDimacs extends Reader implements Serializable {
private char manageCommentLine() throws IOException {
char car;
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
do {
car = (char) this.in.read();
stb.append(car);
......@@ -292,7 +292,7 @@ public class LecteurDimacs extends Reader implements Serializable {
@Override
public String decode(int[] model) {
StringBuffer stb = new StringBuffer();
StringBuilder stb = new StringBuilder();
for (int element : model) {
stb.append(element);
stb.append(" ");
......
......@@ -92,7 +92,7 @@ public class DimacsArrayReader implements Serializable {
}
public String decode(int[] model) {
StringBuffer stb = new StringBuffer(4 * model.length);
StringBuilder stb = new StringBuilder(4 * model.length);
for (int element : model) {
stb.append(element);
stb.append(" ");
......
......@@ -57,7 +57,7 @@ public class DimacsStringSolver extends AbstractOutputSolver
*/
private static final long serialVersionUID = 1L;
private StringBuffer out;
private StringBuilder out;
private int firstCharPos;
......@@ -70,11 +70,11 @@ public class DimacsStringSolver extends AbstractOutputSolver
}
public DimacsStringSolver(int initSize) {
this.out = new StringBuffer(initSize);
this.out = new StringBuilder(initSize);
this.initBuilderSize = initSize;
}
public StringBuffer getOut() {
public StringBuilder getOut() {
return this.out;
}
......@@ -174,7 +174,7 @@ public class DimacsStringSolver extends AbstractOutputSolver
public void reset() {
this.fixedNbClauses = false;
this.firstConstr = true;
this.out = new StringBuffer(this.initBuilderSize);
this.out = new StringBuilder(this.initBuilderSize);
this.maxvarid = 0;
}
......
......@@ -305,7 +305,7 @@ public class ManyCore<S extends ISolver>
}
public String toString(String prefix) {
StringBuffer res = new StringBuffer();
StringBuilder res = new StringBuilder();
res.append(prefix);
res.append("ManyCore solver with ");
res.append(this.numberOfSolvers);
......
......@@ -27,9 +27,8 @@ import org.xcsp.common.Types.TypeOperatorRel;
import org.xcsp.parser.entries.XVariables.XVarInteger;
/**
* A constraint builder for XCSP3 instance format.
* Used by {@link XMLCSP3Reader}.
* This class is dedicated to allDifferent constraints.
* A constraint builder for XCSP3 instance format. Used by
* {@link XMLCSP3Reader}. This class is dedicated to allDifferent constraints.
*
* @author Emmanuel Lonca - lonca@cril.fr
*
......@@ -42,64 +41,73 @@ public class ComparisonCtrBuilder {
this.intensionCtrEncoder = intensionEnc;
}
public boolean buildCtrAllDifferent(String id, XVarInteger[] list) { // TODO: remove dependence to varmapping
for(int i=0; i<list.length-1; ++i) {
public boolean buildCtrAllDifferent(String id, XVarInteger[] list) { // TODO:
// remove
// dependence
// to
// varmapping
for (int i = 0; i < list.length - 1; ++i) {
final String norm1 = CtrBuilderUtils.normalizeCspVarName(list[i].id);
for(int j=i+1; j<list.length; ++j) {
for (int j = i + 1; j < list.length; ++j) {
final String norm2 = CtrBuilderUtils.normalizeCspVarName(list[j].id);
final String expr = "ne("+norm1+","+norm2+")";
if(this.intensionCtrEncoder.encode(expr)) return true;
final String expr = "ne(" + norm1 + "," + norm2 + ")";
if (this.intensionCtrEncoder.encode(expr))
return true;
}
}
return false;
}
public boolean buildCtrAllDifferentExcept(String id, XVarInteger[] list, int[] except) {
SortedSet<XVarInteger> varSet = new TreeSet<>((o1,o2) -> o1.id.compareTo(o2.id));
for(int i=0; i<list.length; ++i) {
SortedSet<XVarInteger> varSet = new TreeSet<>((o1, o2) -> o1.id.compareTo(o2.id));
for (int i = 0; i < list.length; ++i) {
varSet.add(list[i]);
}
XVarInteger[] cleanList = new XVarInteger[varSet.size()];
cleanList = varSet.toArray(cleanList);
if(except.length == 0) {
if (except.length == 0) {
return buildCtrAllDifferent(id, cleanList);
}
if(cleanList.length < 2) return false;
String exceptBase = "eq(X,"+except[0]+")";
for(int i=1; i<except.length; ++i) {
exceptBase = "or("+exceptBase+",eq(X,"+except[i]+"))";
if (cleanList.length < 2)
return false;
String exceptBase = "eq(X," + except[0] + ")";
for (int i = 1; i < except.length; ++i) {
exceptBase = "or(" + exceptBase + ",eq(X," + except[i] + "))";
}
String[] exprs = new String[cleanList.length-1];
for(int i=0; i<cleanList.length-1; ++i) {
String[] exprs = new String[cleanList.length - 1];
for (int i = 0; i < cleanList.length - 1; ++i) {
String normalizedCurVar = CtrBuilderUtils.normalizeCspVarName(cleanList[i].id);
String exceptExpr = exceptBase.replaceAll("X", normalizedCurVar);
String neExpr = "ne("+normalizedCurVar+","+CtrBuilderUtils.normalizeCspVarName(cleanList[i+1].id)+")";
for(int j=i+2; j<cleanList.length; ++j) {
neExpr = "and("+neExpr+",ne("+normalizedCurVar+","+CtrBuilderUtils.normalizeCspVarName(cleanList[j].id)+"))";
String neExpr = "ne(" + normalizedCurVar + "," + CtrBuilderUtils.normalizeCspVarName(cleanList[i + 1].id)
+ ")";
for (int j = i + 2; j < cleanList.length; ++j) {
neExpr = "and(" + neExpr + ",ne(" + normalizedCurVar + ","
+ CtrBuilderUtils.normalizeCspVarName(cleanList[j].id) + "))";
}
exprs[i] = "or("+exceptExpr+","+neExpr+")";
exprs[i] = "or(" + exceptExpr + "," + neExpr + ")";
}
return this.intensionCtrEncoder.encode(CtrBuilderUtils.chainExpressionsForAssociativeOp(exprs, "and"));
}
public boolean buildCtrAllDifferentList(String id, XVarInteger[][] lists) {
for(int i=0; i<lists.length-1; ++i) {
for(int j=i+1; j<lists.length; ++j) {
StringBuffer sbufExpr = new StringBuffer();
for (int i = 0; i < lists.length - 1; ++i) {
for (int j = i + 1; j < lists.length; ++j) {
StringBuilder sbufExpr = new StringBuilder();
sbufExpr.append("or(");
buildCtrAllDifferentListAux(lists, i, j, sbufExpr, 0);
for(int k=1; k<lists[i].length; ++k) {
for (int k = 1; k < lists[i].length; ++k) {
sbufExpr.append(',');
buildCtrAllDifferentListAux(lists, i, j, sbufExpr, k);
}
sbufExpr.append(')');
if(this.intensionCtrEncoder.encode(sbufExpr.toString())) return true;
if (this.intensionCtrEncoder.encode(sbufExpr.toString()))
return true;
}
}
return false;
}
private void buildCtrAllDifferentListAux(XVarInteger[][] lists, int i, int j, StringBuffer sbufExpr, int k) {
private void buildCtrAllDifferentListAux(XVarInteger[][] lists, int i, int j, StringBuilder sbufExpr, int k) {
sbufExpr.append("ne(");
String var1Id = lists[i][k].id;
String normVar1 = CtrBuilderUtils.normalizeCspVarName(var1Id);
......@@ -112,38 +120,40 @@ public class ComparisonCtrBuilder {
public boolean buildCtrAllDifferentMatrix(String id, XVarInteger[][] matrix) {
boolean contradictionFound = false;
XVarInteger[][] tMatrix = CtrBuilderUtils.transposeMatrix(matrix);
for(int i=0; i<matrix.length; ++i) {
for (int i = 0; i < matrix.length; ++i) {
contradictionFound |= buildCtrAllDifferent(id, matrix[i]);
}
for(int i=0; i<tMatrix.length; ++i) {
for (int i = 0; i < tMatrix.length; ++i) {
contradictionFound |= buildCtrAllDifferent(id, tMatrix[i]);
}
return contradictionFound;
}
public boolean buildCtrAllEqual(String id, XVarInteger[] list) {
for(int i=0; i<list.length-1; ++i) {
for (int i = 0; i < list.length - 1; ++i) {
String norm1 = CtrBuilderUtils.normalizeCspVarName(list[i].id);
String norm2 = CtrBuilderUtils.normalizeCspVarName(list[i+1].id);
if(this.intensionCtrEncoder.encode("eq("+norm1+","+norm2+")")) return true;
String norm2 = CtrBuilderUtils.normalizeCspVarName(list[i + 1].id);
if (this.intensionCtrEncoder.encode("eq(" + norm1 + "," + norm2 + ")"))
return true;
}
return false;
}
public boolean buildCtrOrdered(String id, XVarInteger[] list, TypeOperatorRel operator) {
for(int i=0; i<list.length-1; ++i) {
for (int i = 0; i < list.length - 1; ++i) {
String normalized1 = CtrBuilderUtils.normalizeCspVarName(list[i].id);
String normalized2 = CtrBuilderUtils.normalizeCspVarName(list[i+1].id);
String expr = operator.name().toLowerCase()+"("+normalized1+","+normalized2+")";
if(this.intensionCtrEncoder.encode(expr)) return true;
String normalized2 = CtrBuilderUtils.normalizeCspVarName(list[i + 1].id);
String expr = operator.name().toLowerCase() + "(" + normalized1 + "," + normalized2 + ")";
if (this.intensionCtrEncoder.encode(expr))
return true;
}
return false;
}
public boolean buildCtrLex(String id, XVarInteger[][] lists, TypeOperatorRel operator) {
boolean contradictionFound = false;
for(int i=0; i<lists.length-1; ++i) {
contradictionFound |= buildCtrLex(id, lists[i], lists[i+1], operator);
for (int i = 0; i < lists.length - 1; ++i) {
contradictionFound |= buildCtrLex(id, lists[i], lists[i + 1], operator);
}
return contradictionFound;
}
......@@ -156,28 +166,33 @@ public class ComparisonCtrBuilder {
return contradictionFound;
}
private boolean buildCtrLex(String id, XVarInteger[] list1,
XVarInteger[] list2, TypeOperatorRel operator) {
private boolean buildCtrLex(String id, XVarInteger[] list1, XVarInteger[] list2, TypeOperatorRel operator) {
TypeOperatorRel strictOp = CtrBuilderUtils.strictTypeOperator(operator);
String[] chains = new String[list1.length];
String id01 = list1[0].id;
String id02 = list2[0].id;
chains[0] = list1.length == 1
? operator.name().toLowerCase()+"("+CtrBuilderUtils.normalizeCspVarName(id01)+","+CtrBuilderUtils.normalizeCspVarName(id02)+")"
: strictOp.name().toLowerCase()+"("+CtrBuilderUtils.normalizeCspVarName(id01)+","+CtrBuilderUtils.normalizeCspVarName(id02)+")";
for(int i=1; i<list1.length; ++i) {
String eqChain = "eq("+CtrBuilderUtils.normalizeCspVarName(id01)+","+CtrBuilderUtils.normalizeCspVarName(id02)+")";
for(int j=1; j<i; ++j) {
? operator.name().toLowerCase() + "(" + CtrBuilderUtils.normalizeCspVarName(id01) + ","
+ CtrBuilderUtils.normalizeCspVarName(id02) + ")"
: strictOp.name().toLowerCase() + "(" + CtrBuilderUtils.normalizeCspVarName(id01) + ","
+ CtrBuilderUtils.normalizeCspVarName(id02) + ")";
for (int i = 1; i < list1.length; ++i) {
String eqChain = "eq(" + CtrBuilderUtils.normalizeCspVarName(id01) + ","
+ CtrBuilderUtils.normalizeCspVarName(id02) + ")";
for (int j = 1; j < i; ++j) {
String idj1 = list1[j].id;
String idj2 = list2[j].id;
eqChain = "and("+eqChain+",eq("+CtrBuilderUtils.normalizeCspVarName(idj1)+","+CtrBuilderUtils.normalizeCspVarName(idj2)+"))";
eqChain = "and(" + eqChain + ",eq(" + CtrBuilderUtils.normalizeCspVarName(idj1) + ","
+ CtrBuilderUtils.normalizeCspVarName(idj2) + "))";
}
String idi1 = list1[i].id;
String idi2 = list2[i].id;
String finalMember = i == list1.length-1
? operator.name().toLowerCase()+"("+CtrBuilderUtils.normalizeCspVarName(idi1)+","+CtrBuilderUtils.normalizeCspVarName(idi2)+")"
: strictOp.name().toLowerCase()+"("+CtrBuilderUtils.normalizeCspVarName(idi1)+","+CtrBuilderUtils.normalizeCspVarName(idi2)+")";
chains[i] = "and("+eqChain+","+finalMember+")";
String finalMember = i == list1.length - 1
? operator.name().toLowerCase() + "(" + CtrBuilderUtils.normalizeCspVarName(idi1) + ","
+ CtrBuilderUtils.normalizeCspVarName(idi2) + ")"
: strictOp.name().toLowerCase() + "(" + CtrBuilderUtils.normalizeCspVarName(idi1) + ","
+ CtrBuilderUtils.normalizeCspVarName(idi2) + ")";
chains[i] = "and(" + eqChain + "," + finalMember + ")";
}
return this.intensionCtrEncoder.encode(CtrBuilderUtils.chainExpressionsForAssociativeOp(chains, "or"));
}
......
......@@ -93,7 +93,7 @@ public class ConnectionCtrBuilder {
}
private boolean buildCtrMinOrMax(XVarInteger[] list, Condition condition, boolean isMax) {
final StringBuffer leftOpBuf = new StringBuffer();
final StringBuilder leftOpBuf = new StringBuilder();
leftOpBuf.append(isMax ? "max(" : "min(");
String norm = CtrBuilderUtils.normalizeCspVarName(list[0].id);
leftOpBuf.append(norm);
......@@ -143,7 +143,7 @@ public class ConnectionCtrBuilder {
private boolean buildCtrMinOrMaxAtIndex(XVarInteger[] list, XVarInteger index, int startIndex, boolean isMax) {
String normIndex = CtrBuilderUtils.normalizeCspVarName(index.id);
StringBuffer maxExprBuf = new StringBuffer();
StringBuilder maxExprBuf = new StringBuilder();
maxExprBuf.append(isMax ? "max(" : "min(");
for(int i=0; i<list.length; ++i) {
String normVar = CtrBuilderUtils.normalizeCspVarName(list[i].id);
......@@ -165,7 +165,7 @@ public class ConnectionCtrBuilder {
// index==i => and(x0<xi,...,x(i-1)<xi)
String normIndex = CtrBuilderUtils.normalizeCspVarName(index.id);
String normMax = CtrBuilderUtils.normalizeCspVarName(list[i-startIndex].id);
StringBuffer andExprBuf = new StringBuffer();
StringBuilder andExprBuf = new StringBuilder();
andExprBuf.append("and(");
for(int j=0; j<i-startIndex; ++j) {
String normCurVar = CtrBuilderUtils.normalizeCspVarName(list[j].id);
......@@ -184,7 +184,7 @@ public class ConnectionCtrBuilder {
// index==i => and(x(i+1)<xi,...,xn<xi)
String normIndex = CtrBuilderUtils.normalizeCspVarName(index.id);
String normMax = CtrBuilderUtils.normalizeCspVarName(list[i-startIndex].id);
StringBuffer andExprBuf = new StringBuffer();
StringBuilder andExprBuf = new StringBuilder();
andExprBuf.append("and(");
for(int j=i-startIndex+1; j<list.length; ++j) {
String normCurVar = CtrBuilderUtils.normalizeCspVarName(list[j].id);
......@@ -271,7 +271,7 @@ public class ConnectionCtrBuilder {
// or(ne(i,index),and(eq(i,index),eq(xi,value),ne(x0,value),...,ne(xi-1,value)))
String normIndex = CtrBuilderUtils.normalizeCspVarName(index.id);
String normValue = CtrBuilderUtils.normalizeCspVarName(value.id);
StringBuffer sbuf = new StringBuffer();
StringBuilder sbuf = new StringBuilder();
sbuf.append("or(ne(").append(i+startIndex).append(',').append(normIndex).append("),and(eq(").append(i+startIndex).append(',').append(normIndex).append("),eq(").append(CtrBuilderUtils.normalizeCspVarName(list[i].id)).append(',').append(normValue).append(')');
for(int j=0; j<i; ++j) {
sbuf.append(",ne(").append(CtrBuilderUtils.normalizeCspVarName(list[j].id)).append(',').append(normValue).append(')'); // end NE operator
......@@ -287,7 +287,7 @@ public class ConnectionCtrBuilder {
// or(ne(i,index),and(eq(i,index),eq(xi,value),ne(xi+1,value),...,ne(xn,value)))
String normIndex = CtrBuilderUtils.normalizeCspVarName(index.id);
String normValue = CtrBuilderUtils.normalizeCspVarName(value.id);
StringBuffer sbuf = new StringBuffer();
StringBuilder sbuf = new StringBuilder();
sbuf.append("or(ne(").append(i+startIndex).append(',').append(normIndex).append("),and(eq(").append(i+startIndex).append(',').append(normIndex).append("),eq(").append(CtrBuilderUtils.normalizeCspVarName(list[i].id)).append(