repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
logic-ng/LogicNG | src/main/java/org/logicng/solvers/CleaneLing.java | CleaneLing.full | public static CleaneLing full(final FormulaFactory f) {
return new CleaneLing(f, SolverStyle.FULL, new CleaneLingConfig.Builder().build());
} | java | public static CleaneLing full(final FormulaFactory f) {
return new CleaneLing(f, SolverStyle.FULL, new CleaneLingConfig.Builder().build());
} | [
"public",
"static",
"CleaneLing",
"full",
"(",
"final",
"FormulaFactory",
"f",
")",
"{",
"return",
"new",
"CleaneLing",
"(",
"f",
",",
"SolverStyle",
".",
"FULL",
",",
"new",
"CleaneLingConfig",
".",
"Builder",
"(",
")",
".",
"build",
"(",
")",
")",
";",... | Returns a new full CleaneLing solver.
@param f the formula factory
@return the solver | [
"Returns",
"a",
"new",
"full",
"CleaneLing",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/CleaneLing.java#L137-L139 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/CleaneLing.java | CleaneLing.full | public static CleaneLing full(final FormulaFactory f, final CleaneLingConfig config) {
return new CleaneLing(f, SolverStyle.FULL, config);
} | java | public static CleaneLing full(final FormulaFactory f, final CleaneLingConfig config) {
return new CleaneLing(f, SolverStyle.FULL, config);
} | [
"public",
"static",
"CleaneLing",
"full",
"(",
"final",
"FormulaFactory",
"f",
",",
"final",
"CleaneLingConfig",
"config",
")",
"{",
"return",
"new",
"CleaneLing",
"(",
"f",
",",
"SolverStyle",
".",
"FULL",
",",
"config",
")",
";",
"}"
] | Returns a new full CleaneLing solver with a given configuration.
@param f the formula factory
@param config the configuration
@return the solver | [
"Returns",
"a",
"new",
"full",
"CleaneLing",
"solver",
"with",
"a",
"given",
"configuration",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/CleaneLing.java#L147-L149 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/CleaneLing.java | CleaneLing.addClause | private void addClause(final Collection<Literal> literals) {
for (final Literal lit : literals) {
Integer index = this.name2idx.get(lit.variable().name());
if (index == null) {
index = this.name2idx.size() + 1;
this.name2idx.put(lit.variable().name(), index);
this.idx2name.put(index, lit.variable().name());
}
this.solver.addlit(lit.phase() ? index : -index);
}
this.solver.addlit(CLAUSE_TERMINATOR);
} | java | private void addClause(final Collection<Literal> literals) {
for (final Literal lit : literals) {
Integer index = this.name2idx.get(lit.variable().name());
if (index == null) {
index = this.name2idx.size() + 1;
this.name2idx.put(lit.variable().name(), index);
this.idx2name.put(index, lit.variable().name());
}
this.solver.addlit(lit.phase() ? index : -index);
}
this.solver.addlit(CLAUSE_TERMINATOR);
} | [
"private",
"void",
"addClause",
"(",
"final",
"Collection",
"<",
"Literal",
">",
"literals",
")",
"{",
"for",
"(",
"final",
"Literal",
"lit",
":",
"literals",
")",
"{",
"Integer",
"index",
"=",
"this",
".",
"name2idx",
".",
"get",
"(",
"lit",
".",
"var... | Adds a collection of literals to the solver.
@param literals the literals | [
"Adds",
"a",
"collection",
"of",
"literals",
"to",
"the",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/CleaneLing.java#L302-L313 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/CleaneLing.java | CleaneLing.getOrCreateVarIndex | public int getOrCreateVarIndex(final Variable var) {
Integer index = this.name2idx.get(var.name());
if (index == null) {
index = this.name2idx.size() + 1;
this.name2idx.put(var.name(), index);
this.idx2name.put(index, var.name());
}
return index;
} | java | public int getOrCreateVarIndex(final Variable var) {
Integer index = this.name2idx.get(var.name());
if (index == null) {
index = this.name2idx.size() + 1;
this.name2idx.put(var.name(), index);
this.idx2name.put(index, var.name());
}
return index;
} | [
"public",
"int",
"getOrCreateVarIndex",
"(",
"final",
"Variable",
"var",
")",
"{",
"Integer",
"index",
"=",
"this",
".",
"name2idx",
".",
"get",
"(",
"var",
".",
"name",
"(",
")",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"index",
"=",
... | Returns the existing internal solver index for a variable or creates a new one if the variable is yet unknown.
@param var the variable
@return the (old or new) internal variable index | [
"Returns",
"the",
"existing",
"internal",
"solver",
"index",
"for",
"a",
"variable",
"or",
"creates",
"a",
"new",
"one",
"if",
"the",
"variable",
"is",
"yet",
"unknown",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/CleaneLing.java#L349-L357 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/CleaneLing.java | CleaneLing.createNewVariableOnSolver | public String createNewVariableOnSolver(final String prefix) {
final int index = this.name2idx.size() + 1;
final String varName = prefix + "_" + index;
this.name2idx.put(varName, index);
this.idx2name.put(index, varName);
return varName;
} | java | public String createNewVariableOnSolver(final String prefix) {
final int index = this.name2idx.size() + 1;
final String varName = prefix + "_" + index;
this.name2idx.put(varName, index);
this.idx2name.put(index, varName);
return varName;
} | [
"public",
"String",
"createNewVariableOnSolver",
"(",
"final",
"String",
"prefix",
")",
"{",
"final",
"int",
"index",
"=",
"this",
".",
"name2idx",
".",
"size",
"(",
")",
"+",
"1",
";",
"final",
"String",
"varName",
"=",
"prefix",
"+",
"\"_\"",
"+",
"ind... | Creates a new variable on the solver and returns its name.
@param prefix the prefix of the variable name
@return the name of the new variable | [
"Creates",
"a",
"new",
"variable",
"on",
"the",
"solver",
"and",
"returns",
"its",
"name",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/CleaneLing.java#L364-L370 | train |
logic-ng/LogicNG | src/main/java/org/logicng/transformations/FormulaFactoryImporter.java | FormulaFactoryImporter.gatherAppliedOperands | private LinkedHashSet<Formula> gatherAppliedOperands(final NAryOperator operator) {
final LinkedHashSet<Formula> applied = new LinkedHashSet<>();
for (final Formula operand : operator) {
applied.add(apply(operand, false));
}
return applied;
} | java | private LinkedHashSet<Formula> gatherAppliedOperands(final NAryOperator operator) {
final LinkedHashSet<Formula> applied = new LinkedHashSet<>();
for (final Formula operand : operator) {
applied.add(apply(operand, false));
}
return applied;
} | [
"private",
"LinkedHashSet",
"<",
"Formula",
">",
"gatherAppliedOperands",
"(",
"final",
"NAryOperator",
"operator",
")",
"{",
"final",
"LinkedHashSet",
"<",
"Formula",
">",
"applied",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Form... | Gather the operands of an n-ary operator and returns its applied operands.
@param operator the n-ary operator
@return the applied operands of the given operator | [
"Gather",
"the",
"operands",
"of",
"an",
"n",
"-",
"ary",
"operator",
"and",
"returns",
"its",
"applied",
"operands",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/transformations/FormulaFactoryImporter.java#L113-L119 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/jbuddy/BDDKernel.java | BDDKernel.setNumberOfVars | public void setNumberOfVars(final int num) {
if (this.varnum != 0)
throw new UnsupportedOperationException("Variable number is already set. Resetting it is not supported");
if (num < 1 || num > MAXVAR)
throw new IllegalArgumentException("Invalid variable number: " + num);
this.vars = new int[num * 2];
this.level2var = new int[num + 1];
this.refstack = new int[num * 2 + 4];
this.refstacktop = 0;
while (this.varnum < num) {
this.vars[this.varnum * 2] = pushRef(makeNode(this.varnum, 0, 1));
this.vars[this.varnum * 2 + 1] = makeNode(this.varnum, 1, 0);
popref(1);
this.nodes[this.vars[this.varnum * 2]].refcou = MAXREF;
this.nodes[this.vars[this.varnum * 2 + 1]].refcou = MAXREF;
this.level2var[this.varnum] = this.varnum;
this.varnum++;
}
this.nodes[0].level = num;
this.nodes[1].level = num;
this.level2var[num] = num;
varResize();
} | java | public void setNumberOfVars(final int num) {
if (this.varnum != 0)
throw new UnsupportedOperationException("Variable number is already set. Resetting it is not supported");
if (num < 1 || num > MAXVAR)
throw new IllegalArgumentException("Invalid variable number: " + num);
this.vars = new int[num * 2];
this.level2var = new int[num + 1];
this.refstack = new int[num * 2 + 4];
this.refstacktop = 0;
while (this.varnum < num) {
this.vars[this.varnum * 2] = pushRef(makeNode(this.varnum, 0, 1));
this.vars[this.varnum * 2 + 1] = makeNode(this.varnum, 1, 0);
popref(1);
this.nodes[this.vars[this.varnum * 2]].refcou = MAXREF;
this.nodes[this.vars[this.varnum * 2 + 1]].refcou = MAXREF;
this.level2var[this.varnum] = this.varnum;
this.varnum++;
}
this.nodes[0].level = num;
this.nodes[1].level = num;
this.level2var[num] = num;
varResize();
} | [
"public",
"void",
"setNumberOfVars",
"(",
"final",
"int",
"num",
")",
"{",
"if",
"(",
"this",
".",
"varnum",
"!=",
"0",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Variable number is already set. Resetting it is not supported\"",
")",
";",
"if",
"(... | Sets the number of variables to use. It may be called more than one time, but only
to increase the number of variables.
@param num the number of variables to use | [
"Sets",
"the",
"number",
"of",
"variables",
"to",
"use",
".",
"It",
"may",
"be",
"called",
"more",
"than",
"one",
"time",
"but",
"only",
"to",
"increase",
"the",
"number",
"of",
"variables",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/jbuddy/BDDKernel.java#L173-L195 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/jbuddy/BDDKernel.java | BDDKernel.delRef | private void delRef(final int root) {
if (root < 2)
return;
if (root >= this.nodesize)
throw new IllegalStateException("Cannot dereference a variable > varnum");
if (this.low(root) == -1)
throw new IllegalStateException("Cannot dereference variable -1");
if (!this.hasref(root))
throw new IllegalStateException("Cannot dereference a variable which has no reference");
this.decRef(root);
} | java | private void delRef(final int root) {
if (root < 2)
return;
if (root >= this.nodesize)
throw new IllegalStateException("Cannot dereference a variable > varnum");
if (this.low(root) == -1)
throw new IllegalStateException("Cannot dereference variable -1");
if (!this.hasref(root))
throw new IllegalStateException("Cannot dereference a variable which has no reference");
this.decRef(root);
} | [
"private",
"void",
"delRef",
"(",
"final",
"int",
"root",
")",
"{",
"if",
"(",
"root",
"<",
"2",
")",
"return",
";",
"if",
"(",
"root",
">=",
"this",
".",
"nodesize",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot dereference a variable > varnu... | Deletes a reference for a given node.
@param root the node
@throws IllegalArgumentException if the root node was invalid | [
"Deletes",
"a",
"reference",
"for",
"a",
"given",
"node",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/jbuddy/BDDKernel.java#L415-L425 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/jbuddy/BDDKernel.java | BDDKernel.allSat | public List<byte[]> allSat(final int r) {
final byte[] allsatProfile = new byte[this.varnum];
for (int v = level(r) - 1; v >= 0; --v)
allsatProfile[this.level2var[v]] = -1;
initRef();
final List<byte[]> allSat = new LinkedList<>();
allSatRec(r, allSat, allsatProfile);
return allSat;
} | java | public List<byte[]> allSat(final int r) {
final byte[] allsatProfile = new byte[this.varnum];
for (int v = level(r) - 1; v >= 0; --v)
allsatProfile[this.level2var[v]] = -1;
initRef();
final List<byte[]> allSat = new LinkedList<>();
allSatRec(r, allSat, allsatProfile);
return allSat;
} | [
"public",
"List",
"<",
"byte",
"[",
"]",
">",
"allSat",
"(",
"final",
"int",
"r",
")",
"{",
"final",
"byte",
"[",
"]",
"allsatProfile",
"=",
"new",
"byte",
"[",
"this",
".",
"varnum",
"]",
";",
"for",
"(",
"int",
"v",
"=",
"level",
"(",
"r",
")... | Returns all models for a given BDD.
@param r the BDD root node
@return all models for the BDD | [
"Returns",
"all",
"models",
"for",
"a",
"given",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/jbuddy/BDDKernel.java#L892-L900 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java | GlucoseSyrup.initializeGlucose | private void initializeGlucose() {
this.initializeGlucoseConfig();
this.watchesBin = new LNGVector<>();
this.permDiff = new LNGIntVector();
this.lastDecisionLevel = new LNGIntVector();
this.lbdQueue = new LNGBoundedLongQueue();
this.trailQueue = new LNGBoundedIntQueue();
this.assump = new LNGBooleanVector();
this.lbdQueue.initSize(sizeLBDQueue);
this.trailQueue.initSize(sizeTrailQueue);
this.myflag = 0;
this.analyzeBtLevel = 0;
this.analyzeLBD = 0;
this.analyzeSzWithoutSelectors = 0;
this.nbclausesbeforereduce = firstReduceDB;
this.conflicts = 0;
this.conflictsRestarts = 0;
this.sumLBD = 0;
this.curRestart = 1;
} | java | private void initializeGlucose() {
this.initializeGlucoseConfig();
this.watchesBin = new LNGVector<>();
this.permDiff = new LNGIntVector();
this.lastDecisionLevel = new LNGIntVector();
this.lbdQueue = new LNGBoundedLongQueue();
this.trailQueue = new LNGBoundedIntQueue();
this.assump = new LNGBooleanVector();
this.lbdQueue.initSize(sizeLBDQueue);
this.trailQueue.initSize(sizeTrailQueue);
this.myflag = 0;
this.analyzeBtLevel = 0;
this.analyzeLBD = 0;
this.analyzeSzWithoutSelectors = 0;
this.nbclausesbeforereduce = firstReduceDB;
this.conflicts = 0;
this.conflictsRestarts = 0;
this.sumLBD = 0;
this.curRestart = 1;
} | [
"private",
"void",
"initializeGlucose",
"(",
")",
"{",
"this",
".",
"initializeGlucoseConfig",
"(",
")",
";",
"this",
".",
"watchesBin",
"=",
"new",
"LNGVector",
"<>",
"(",
")",
";",
"this",
".",
"permDiff",
"=",
"new",
"LNGIntVector",
"(",
")",
";",
"th... | Initializes the additional parameters. | [
"Initializes",
"the",
"additional",
"parameters",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java#L165-L184 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java | GlucoseSyrup.initializeGlucoseConfig | private void initializeGlucoseConfig() {
this.lbLBDMinimizingClause = glucoseConfig.lbLBDMinimizingClause;
this.lbLBDFrozenClause = glucoseConfig.lbLBDFrozenClause;
this.lbSizeMinimizingClause = glucoseConfig.lbSizeMinimizingClause;
this.firstReduceDB = glucoseConfig.firstReduceDB;
this.specialIncReduceDB = glucoseConfig.specialIncReduceDB;
this.incReduceDB = glucoseConfig.incReduceDB;
this.factorK = glucoseConfig.factorK;
this.factorR = glucoseConfig.factorR;
this.sizeLBDQueue = glucoseConfig.sizeLBDQueue;
this.sizeTrailQueue = glucoseConfig.sizeTrailQueue;
this.reduceOnSize = glucoseConfig.reduceOnSize;
this.reduceOnSizeSize = glucoseConfig.reduceOnSizeSize;
this.maxVarDecay = glucoseConfig.maxVarDecay;
} | java | private void initializeGlucoseConfig() {
this.lbLBDMinimizingClause = glucoseConfig.lbLBDMinimizingClause;
this.lbLBDFrozenClause = glucoseConfig.lbLBDFrozenClause;
this.lbSizeMinimizingClause = glucoseConfig.lbSizeMinimizingClause;
this.firstReduceDB = glucoseConfig.firstReduceDB;
this.specialIncReduceDB = glucoseConfig.specialIncReduceDB;
this.incReduceDB = glucoseConfig.incReduceDB;
this.factorK = glucoseConfig.factorK;
this.factorR = glucoseConfig.factorR;
this.sizeLBDQueue = glucoseConfig.sizeLBDQueue;
this.sizeTrailQueue = glucoseConfig.sizeTrailQueue;
this.reduceOnSize = glucoseConfig.reduceOnSize;
this.reduceOnSizeSize = glucoseConfig.reduceOnSizeSize;
this.maxVarDecay = glucoseConfig.maxVarDecay;
} | [
"private",
"void",
"initializeGlucoseConfig",
"(",
")",
"{",
"this",
".",
"lbLBDMinimizingClause",
"=",
"glucoseConfig",
".",
"lbLBDMinimizingClause",
";",
"this",
".",
"lbLBDFrozenClause",
"=",
"glucoseConfig",
".",
"lbLBDFrozenClause",
";",
"this",
".",
"lbSizeMinim... | Initializes the glucose configuration. | [
"Initializes",
"the",
"glucose",
"configuration",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java#L189-L203 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java | GlucoseSyrup.computeLBD | private long computeLBD(final LNGIntVector lits, int e) {
int end = e;
long nblevels = 0;
myflag++;
if (incremental) {
if (end == -1)
end = lits.size();
long nbDone = 0;
for (int i = 0; i < lits.size(); i++) {
if (nbDone >= end)
break;
if (isSelector(var(lits.get(i))))
continue;
nbDone++;
int l = v(lits.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
} else {
for (int i = 0; i < lits.size(); i++) {
int l = v(lits.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
}
if (!reduceOnSize)
return nblevels;
if (lits.size() < reduceOnSizeSize)
return lits.size();
return lits.size() + nblevels;
} | java | private long computeLBD(final LNGIntVector lits, int e) {
int end = e;
long nblevels = 0;
myflag++;
if (incremental) {
if (end == -1)
end = lits.size();
long nbDone = 0;
for (int i = 0; i < lits.size(); i++) {
if (nbDone >= end)
break;
if (isSelector(var(lits.get(i))))
continue;
nbDone++;
int l = v(lits.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
} else {
for (int i = 0; i < lits.size(); i++) {
int l = v(lits.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
}
if (!reduceOnSize)
return nblevels;
if (lits.size() < reduceOnSizeSize)
return lits.size();
return lits.size() + nblevels;
} | [
"private",
"long",
"computeLBD",
"(",
"final",
"LNGIntVector",
"lits",
",",
"int",
"e",
")",
"{",
"int",
"end",
"=",
"e",
";",
"long",
"nblevels",
"=",
"0",
";",
"myflag",
"++",
";",
"if",
"(",
"incremental",
")",
"{",
"if",
"(",
"end",
"==",
"-",
... | Computes the LBD for a given vector of literals.
@param lits the vector of literals
@param e parameter for incremental mode
@return the LBD | [
"Computes",
"the",
"LBD",
"for",
"a",
"given",
"vector",
"of",
"literals",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java#L643-L677 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java | GlucoseSyrup.computeLBD | private long computeLBD(final MSClause c) {
long nblevels = 0;
myflag++;
if (incremental) {
long nbDone = 0;
for (int i = 0; i < c.size(); i++) {
if (nbDone >= c.sizeWithoutSelectors())
break;
if (isSelector(var(c.get(i))))
continue;
nbDone++;
int l = v(c.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
} else {
for (int i = 0; i < c.size(); i++) {
int l = v(c.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
}
if (!reduceOnSize)
return nblevels;
if (c.size() < reduceOnSizeSize)
return c.size();
return c.size() + nblevels;
} | java | private long computeLBD(final MSClause c) {
long nblevels = 0;
myflag++;
if (incremental) {
long nbDone = 0;
for (int i = 0; i < c.size(); i++) {
if (nbDone >= c.sizeWithoutSelectors())
break;
if (isSelector(var(c.get(i))))
continue;
nbDone++;
int l = v(c.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
} else {
for (int i = 0; i < c.size(); i++) {
int l = v(c.get(i)).level();
if (permDiff.get(l) != myflag) {
permDiff.set(l, myflag);
nblevels++;
}
}
}
if (!reduceOnSize)
return nblevels;
if (c.size() < reduceOnSizeSize)
return c.size();
return c.size() + nblevels;
} | [
"private",
"long",
"computeLBD",
"(",
"final",
"MSClause",
"c",
")",
"{",
"long",
"nblevels",
"=",
"0",
";",
"myflag",
"++",
";",
"if",
"(",
"incremental",
")",
"{",
"long",
"nbDone",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<"... | Computes the LBD for a given clause
@param c the clause
@return the LBD | [
"Computes",
"the",
"LBD",
"for",
"a",
"given",
"clause"
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java#L684-L715 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java | GlucoseSyrup.minimisationWithBinaryResolution | private void minimisationWithBinaryResolution(final LNGIntVector outLearnt) {
long lbd = computeLBD(outLearnt, -1);
int p = not(outLearnt.get(0));
if (lbd <= lbLBDMinimizingClause) {
myflag++;
for (int i = 1; i < outLearnt.size(); i++)
permDiff.set(var(outLearnt.get(i)), myflag);
int nb = 0;
for (final MSWatcher wbin : watchesBin.get(p)) {
int imp = wbin.blocker();
if (permDiff.get(var(imp)) == myflag && value(imp) == Tristate.TRUE) {
nb++;
permDiff.set(var(imp), myflag - 1);
}
}
int l = outLearnt.size() - 1;
if (nb > 0) {
for (int i = 1; i < outLearnt.size() - nb; i++) {
if (permDiff.get(var(outLearnt.get(i))) != myflag) {
p = outLearnt.get(l);
outLearnt.set(l, outLearnt.get(i));
outLearnt.set(i, p);
l--;
i--;
}
}
outLearnt.removeElements(nb);
}
}
} | java | private void minimisationWithBinaryResolution(final LNGIntVector outLearnt) {
long lbd = computeLBD(outLearnt, -1);
int p = not(outLearnt.get(0));
if (lbd <= lbLBDMinimizingClause) {
myflag++;
for (int i = 1; i < outLearnt.size(); i++)
permDiff.set(var(outLearnt.get(i)), myflag);
int nb = 0;
for (final MSWatcher wbin : watchesBin.get(p)) {
int imp = wbin.blocker();
if (permDiff.get(var(imp)) == myflag && value(imp) == Tristate.TRUE) {
nb++;
permDiff.set(var(imp), myflag - 1);
}
}
int l = outLearnt.size() - 1;
if (nb > 0) {
for (int i = 1; i < outLearnt.size() - nb; i++) {
if (permDiff.get(var(outLearnt.get(i))) != myflag) {
p = outLearnt.get(l);
outLearnt.set(l, outLearnt.get(i));
outLearnt.set(i, p);
l--;
i--;
}
}
outLearnt.removeElements(nb);
}
}
} | [
"private",
"void",
"minimisationWithBinaryResolution",
"(",
"final",
"LNGIntVector",
"outLearnt",
")",
"{",
"long",
"lbd",
"=",
"computeLBD",
"(",
"outLearnt",
",",
"-",
"1",
")",
";",
"int",
"p",
"=",
"not",
"(",
"outLearnt",
".",
"get",
"(",
"0",
")",
... | A special clause minimization by binary resolution for small clauses.
@param outLearnt the vector where the new learnt 1-UIP clause is stored | [
"A",
"special",
"clause",
"minimization",
"by",
"binary",
"resolution",
"for",
"small",
"clauses",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/GlucoseSyrup.java#L730-L759 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.buildRec | private int buildRec(final Formula formula) {
switch (formula.type()) {
case FALSE:
return BDDKernel.BDD_FALSE;
case TRUE:
return BDDKernel.BDD_TRUE;
case LITERAL:
final Literal lit = (Literal) formula;
Integer idx = this.var2idx.get(lit.variable());
if (idx == null) {
idx = this.var2idx.size();
this.var2idx.put(lit.variable(), idx);
this.idx2var.put(idx, lit.variable());
}
return lit.phase() ? this.kernel.ithVar(idx) : this.kernel.nithVar(idx);
case NOT:
final Not not = (Not) formula;
return this.kernel.addRef(this.kernel.not(buildRec(not.operand())));
case IMPL:
final Implication impl = (Implication) formula;
return this.kernel.addRef(this.kernel.implication(buildRec(impl.left()), buildRec(impl.right())));
case EQUIV:
final Equivalence equiv = (Equivalence) formula;
return this.kernel.addRef(this.kernel.equivalence(buildRec(equiv.left()), buildRec(equiv.right())));
case AND:
case OR:
final Iterator<Formula> it = formula.iterator();
int res = buildRec(it.next());
while (it.hasNext())
res = formula.type() == AND
? this.kernel.addRef(this.kernel.and(res, buildRec(it.next())))
: this.kernel.addRef(this.kernel.or(res, buildRec(it.next())));
return res;
case PBC:
return buildRec(formula.nnf());
default:
throw new IllegalArgumentException("Unsupported operator for BDD generation: " + formula.type());
}
} | java | private int buildRec(final Formula formula) {
switch (formula.type()) {
case FALSE:
return BDDKernel.BDD_FALSE;
case TRUE:
return BDDKernel.BDD_TRUE;
case LITERAL:
final Literal lit = (Literal) formula;
Integer idx = this.var2idx.get(lit.variable());
if (idx == null) {
idx = this.var2idx.size();
this.var2idx.put(lit.variable(), idx);
this.idx2var.put(idx, lit.variable());
}
return lit.phase() ? this.kernel.ithVar(idx) : this.kernel.nithVar(idx);
case NOT:
final Not not = (Not) formula;
return this.kernel.addRef(this.kernel.not(buildRec(not.operand())));
case IMPL:
final Implication impl = (Implication) formula;
return this.kernel.addRef(this.kernel.implication(buildRec(impl.left()), buildRec(impl.right())));
case EQUIV:
final Equivalence equiv = (Equivalence) formula;
return this.kernel.addRef(this.kernel.equivalence(buildRec(equiv.left()), buildRec(equiv.right())));
case AND:
case OR:
final Iterator<Formula> it = formula.iterator();
int res = buildRec(it.next());
while (it.hasNext())
res = formula.type() == AND
? this.kernel.addRef(this.kernel.and(res, buildRec(it.next())))
: this.kernel.addRef(this.kernel.or(res, buildRec(it.next())));
return res;
case PBC:
return buildRec(formula.nnf());
default:
throw new IllegalArgumentException("Unsupported operator for BDD generation: " + formula.type());
}
} | [
"private",
"int",
"buildRec",
"(",
"final",
"Formula",
"formula",
")",
"{",
"switch",
"(",
"formula",
".",
"type",
"(",
")",
")",
"{",
"case",
"FALSE",
":",
"return",
"BDDKernel",
".",
"BDD_FALSE",
";",
"case",
"TRUE",
":",
"return",
"BDDKernel",
".",
... | Recursive build procedure for the BDD.
@param formula the formula
@return the BDD index | [
"Recursive",
"build",
"procedure",
"for",
"the",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L137-L175 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.setVariableOrder | public void setVariableOrder(final Variable... varOrder) {
this.kernel.setNumberOfVars(varOrder.length);
for (final Variable lit : varOrder) {
final int idx = this.var2idx.size();
this.var2idx.put(lit.variable(), idx);
this.idx2var.put(idx, lit.variable());
}
} | java | public void setVariableOrder(final Variable... varOrder) {
this.kernel.setNumberOfVars(varOrder.length);
for (final Variable lit : varOrder) {
final int idx = this.var2idx.size();
this.var2idx.put(lit.variable(), idx);
this.idx2var.put(idx, lit.variable());
}
} | [
"public",
"void",
"setVariableOrder",
"(",
"final",
"Variable",
"...",
"varOrder",
")",
"{",
"this",
".",
"kernel",
".",
"setNumberOfVars",
"(",
"varOrder",
".",
"length",
")",
";",
"for",
"(",
"final",
"Variable",
"lit",
":",
"varOrder",
")",
"{",
"final"... | Sets the variable order for this factory manually. In this case the number of variables has not to be set manually.
@param varOrder the variable order. | [
"Sets",
"the",
"variable",
"order",
"for",
"this",
"factory",
"manually",
".",
"In",
"this",
"case",
"the",
"number",
"of",
"variables",
"has",
"not",
"to",
"be",
"set",
"manually",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L197-L204 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.modelCount | public BigDecimal modelCount(final BDD bdd, final int unimportantVars) {
return modelCount(bdd).divide(BigDecimal.valueOf((int) Math.pow(2, unimportantVars)));
} | java | public BigDecimal modelCount(final BDD bdd, final int unimportantVars) {
return modelCount(bdd).divide(BigDecimal.valueOf((int) Math.pow(2, unimportantVars)));
} | [
"public",
"BigDecimal",
"modelCount",
"(",
"final",
"BDD",
"bdd",
",",
"final",
"int",
"unimportantVars",
")",
"{",
"return",
"modelCount",
"(",
"bdd",
")",
".",
"divide",
"(",
"BigDecimal",
".",
"valueOf",
"(",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
... | Returns the model count of a given BDD with a given number of unimportant variables.
@param bdd the BDD
@param unimportantVars the number of unimportant variables
@return the model count | [
"Returns",
"the",
"model",
"count",
"of",
"a",
"given",
"BDD",
"with",
"a",
"given",
"number",
"of",
"unimportant",
"variables",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L247-L249 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.enumerateAllModels | public List<Assignment> enumerateAllModels(final BDD bdd, final Collection<Variable> variables) {
final Set<Assignment> res = new HashSet<>();
final List<byte[]> models = this.kernel.allSat(bdd.index());
final SortedSet<Integer> temp;
if (variables == null)
temp = new TreeSet<>(this.var2idx.values());
else {
temp = new TreeSet<>();
for (final Map.Entry<Variable, Integer> e : this.var2idx.entrySet())
if (variables.contains(e.getKey()))
temp.add(e.getValue());
}
final int[] relevantIndices = new int[temp.size()];
int count = 0;
for (final Integer i : temp)
relevantIndices[count++] = i;
for (final byte[] model : models) {
final List<Assignment> allAssignments = new LinkedList<>();
generateAllModels(allAssignments, model, relevantIndices, 0);
res.addAll(allAssignments);
}
return new ArrayList<>(res);
} | java | public List<Assignment> enumerateAllModels(final BDD bdd, final Collection<Variable> variables) {
final Set<Assignment> res = new HashSet<>();
final List<byte[]> models = this.kernel.allSat(bdd.index());
final SortedSet<Integer> temp;
if (variables == null)
temp = new TreeSet<>(this.var2idx.values());
else {
temp = new TreeSet<>();
for (final Map.Entry<Variable, Integer> e : this.var2idx.entrySet())
if (variables.contains(e.getKey()))
temp.add(e.getValue());
}
final int[] relevantIndices = new int[temp.size()];
int count = 0;
for (final Integer i : temp)
relevantIndices[count++] = i;
for (final byte[] model : models) {
final List<Assignment> allAssignments = new LinkedList<>();
generateAllModels(allAssignments, model, relevantIndices, 0);
res.addAll(allAssignments);
}
return new ArrayList<>(res);
} | [
"public",
"List",
"<",
"Assignment",
">",
"enumerateAllModels",
"(",
"final",
"BDD",
"bdd",
",",
"final",
"Collection",
"<",
"Variable",
">",
"variables",
")",
"{",
"final",
"Set",
"<",
"Assignment",
">",
"res",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";"... | Enumerates all models of a given BDD wrt. a given set of variables.
@param bdd the BDD
@param variables the variables
@return the list of all models | [
"Enumerates",
"all",
"models",
"of",
"a",
"given",
"BDD",
"wrt",
".",
"a",
"given",
"set",
"of",
"variables",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L266-L288 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.cnf | public Formula cnf(final BDD bdd) {
final List<byte[]> unsatPaths = this.kernel.allUnsat(bdd.index());
final List<Formula> clauses = new LinkedList<>();
List<Formula> literals;
for (final byte[] path : unsatPaths) {
literals = new LinkedList<>();
for (int i = 0; i < path.length; i++)
if (path[i] == 0)
literals.add(this.idx2var.get(i));
else if (path[i] == 1)
literals.add(this.idx2var.get(i).negate());
clauses.add(this.f.or(literals));
}
return this.f.and(clauses);
} | java | public Formula cnf(final BDD bdd) {
final List<byte[]> unsatPaths = this.kernel.allUnsat(bdd.index());
final List<Formula> clauses = new LinkedList<>();
List<Formula> literals;
for (final byte[] path : unsatPaths) {
literals = new LinkedList<>();
for (int i = 0; i < path.length; i++)
if (path[i] == 0)
literals.add(this.idx2var.get(i));
else if (path[i] == 1)
literals.add(this.idx2var.get(i).negate());
clauses.add(this.f.or(literals));
}
return this.f.and(clauses);
} | [
"public",
"Formula",
"cnf",
"(",
"final",
"BDD",
"bdd",
")",
"{",
"final",
"List",
"<",
"byte",
"[",
"]",
">",
"unsatPaths",
"=",
"this",
".",
"kernel",
".",
"allUnsat",
"(",
"bdd",
".",
"index",
"(",
")",
")",
";",
"final",
"List",
"<",
"Formula",... | Returns a CNF formula for a given BDD.
@param bdd the node
@return the CNF for the formula represented by the BDD | [
"Returns",
"a",
"CNF",
"formula",
"for",
"a",
"given",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L315-L329 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.dnf | public Formula dnf(final BDD bdd) {
final List<Formula> ops = new LinkedList<>();
for (final Assignment ass : this.enumerateAllModels(bdd))
ops.add(ass.formula(this.f));
return ops.isEmpty() ? this.f.falsum() : this.f.or(ops);
} | java | public Formula dnf(final BDD bdd) {
final List<Formula> ops = new LinkedList<>();
for (final Assignment ass : this.enumerateAllModels(bdd))
ops.add(ass.formula(this.f));
return ops.isEmpty() ? this.f.falsum() : this.f.or(ops);
} | [
"public",
"Formula",
"dnf",
"(",
"final",
"BDD",
"bdd",
")",
"{",
"final",
"List",
"<",
"Formula",
">",
"ops",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Assignment",
"ass",
":",
"this",
".",
"enumerateAllModels",
"(",
"bdd",
... | Returns a DNF formula for a given BDD.
@param bdd the BDD
@return the DNF for the formula represented by the BDD | [
"Returns",
"a",
"DNF",
"formula",
"for",
"a",
"given",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L345-L350 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.support | public SortedSet<Variable> support(final BDD bdd) {
final int supportBDD = this.kernel.support(bdd.index());
final Assignment assignment = createAssignment(supportBDD);
assert assignment == null || assignment.negativeLiterals().isEmpty();
return assignment == null ? new TreeSet<Variable>() : new TreeSet<>(assignment.positiveLiterals());
} | java | public SortedSet<Variable> support(final BDD bdd) {
final int supportBDD = this.kernel.support(bdd.index());
final Assignment assignment = createAssignment(supportBDD);
assert assignment == null || assignment.negativeLiterals().isEmpty();
return assignment == null ? new TreeSet<Variable>() : new TreeSet<>(assignment.positiveLiterals());
} | [
"public",
"SortedSet",
"<",
"Variable",
">",
"support",
"(",
"final",
"BDD",
"bdd",
")",
"{",
"final",
"int",
"supportBDD",
"=",
"this",
".",
"kernel",
".",
"support",
"(",
"bdd",
".",
"index",
"(",
")",
")",
";",
"final",
"Assignment",
"assignment",
"... | Returns all the variables that a given BDD depends on.
@param bdd the BDD
@return all the variables that the BDD depends on | [
"Returns",
"all",
"the",
"variables",
"that",
"a",
"given",
"BDD",
"depends",
"on",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L392-L397 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.createAssignment | private Assignment createAssignment(final int modelBDD) {
if (modelBDD == BDDKernel.BDD_FALSE)
return null;
if (modelBDD == BDDKernel.BDD_TRUE)
return new Assignment();
final List<int[]> nodes = this.kernel.allNodes(modelBDD);
final Assignment assignment = new Assignment();
for (final int[] node : nodes) {
final Variable variable = this.idx2var.get(node[1]);
if (node[2] == BDDKernel.BDD_FALSE)
assignment.addLiteral(variable);
else if (node[3] == BDDKernel.BDD_FALSE)
assignment.addLiteral(variable.negate());
else
throw new IllegalStateException("Expected that the model BDD has one unique path through the BDD.");
}
return assignment;
} | java | private Assignment createAssignment(final int modelBDD) {
if (modelBDD == BDDKernel.BDD_FALSE)
return null;
if (modelBDD == BDDKernel.BDD_TRUE)
return new Assignment();
final List<int[]> nodes = this.kernel.allNodes(modelBDD);
final Assignment assignment = new Assignment();
for (final int[] node : nodes) {
final Variable variable = this.idx2var.get(node[1]);
if (node[2] == BDDKernel.BDD_FALSE)
assignment.addLiteral(variable);
else if (node[3] == BDDKernel.BDD_FALSE)
assignment.addLiteral(variable.negate());
else
throw new IllegalStateException("Expected that the model BDD has one unique path through the BDD.");
}
return assignment;
} | [
"private",
"Assignment",
"createAssignment",
"(",
"final",
"int",
"modelBDD",
")",
"{",
"if",
"(",
"modelBDD",
"==",
"BDDKernel",
".",
"BDD_FALSE",
")",
"return",
"null",
";",
"if",
"(",
"modelBDD",
"==",
"BDDKernel",
".",
"BDD_TRUE",
")",
"return",
"new",
... | Creates an assignment from a BDD.
@param modelBDD the BDD
@return the assignment
@throws IllegalStateException if the BDD does not represent a unique model | [
"Creates",
"an",
"assignment",
"from",
"a",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L405-L422 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.variableProfile | public SortedMap<Variable, Integer> variableProfile(final BDD bdd) {
final int[] varProfile = this.kernel.varProfile(bdd.index());
final SortedMap<Variable, Integer> profile = new TreeMap<>();
for (int i = 0; i < varProfile.length; i++) {
profile.put(this.idx2var.get(i), varProfile[i]);
}
return profile;
} | java | public SortedMap<Variable, Integer> variableProfile(final BDD bdd) {
final int[] varProfile = this.kernel.varProfile(bdd.index());
final SortedMap<Variable, Integer> profile = new TreeMap<>();
for (int i = 0; i < varProfile.length; i++) {
profile.put(this.idx2var.get(i), varProfile[i]);
}
return profile;
} | [
"public",
"SortedMap",
"<",
"Variable",
",",
"Integer",
">",
"variableProfile",
"(",
"final",
"BDD",
"bdd",
")",
"{",
"final",
"int",
"[",
"]",
"varProfile",
"=",
"this",
".",
"kernel",
".",
"varProfile",
"(",
"bdd",
".",
"index",
"(",
")",
")",
";",
... | Returns how often each variable occurs in the given BDD.
@param bdd the BDD
@return how often each variable occurs in the BDD | [
"Returns",
"how",
"often",
"each",
"variable",
"occurs",
"in",
"the",
"given",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L429-L436 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/BDDFactory.java | BDDFactory.toLngBdd | public BDDNode toLngBdd(final int bdd) {
final BDDConstant falseNode = BDDConstant.getFalsumNode(this.f);
final BDDConstant trueNode = BDDConstant.getVerumNode(this.f);
if (bdd == BDDKernel.BDD_FALSE)
return falseNode;
if (bdd == BDDKernel.BDD_TRUE)
return trueNode;
final List<int[]> nodes = this.kernel.allNodes(bdd);
final Map<Integer, BDDInnerNode> innerNodes = new HashMap<>();
for (final int[] node : nodes) {
final int nodenum = node[0];
final Variable variable = this.idx2var.get(node[1]);
final BDDNode lowNode = getInnerNode(node[2], falseNode, trueNode, innerNodes);
final BDDNode highNode = getInnerNode(node[3], falseNode, trueNode, innerNodes);
if (innerNodes.get(nodenum) == null)
innerNodes.put(nodenum, new BDDInnerNode(variable, lowNode, highNode));
}
return innerNodes.get(bdd);
} | java | public BDDNode toLngBdd(final int bdd) {
final BDDConstant falseNode = BDDConstant.getFalsumNode(this.f);
final BDDConstant trueNode = BDDConstant.getVerumNode(this.f);
if (bdd == BDDKernel.BDD_FALSE)
return falseNode;
if (bdd == BDDKernel.BDD_TRUE)
return trueNode;
final List<int[]> nodes = this.kernel.allNodes(bdd);
final Map<Integer, BDDInnerNode> innerNodes = new HashMap<>();
for (final int[] node : nodes) {
final int nodenum = node[0];
final Variable variable = this.idx2var.get(node[1]);
final BDDNode lowNode = getInnerNode(node[2], falseNode, trueNode, innerNodes);
final BDDNode highNode = getInnerNode(node[3], falseNode, trueNode, innerNodes);
if (innerNodes.get(nodenum) == null)
innerNodes.put(nodenum, new BDDInnerNode(variable, lowNode, highNode));
}
return innerNodes.get(bdd);
} | [
"public",
"BDDNode",
"toLngBdd",
"(",
"final",
"int",
"bdd",
")",
"{",
"final",
"BDDConstant",
"falseNode",
"=",
"BDDConstant",
".",
"getFalsumNode",
"(",
"this",
".",
"f",
")",
";",
"final",
"BDDConstant",
"trueNode",
"=",
"BDDConstant",
".",
"getVerumNode",
... | Returns a LogicNG internal BDD data structure of a given BDD.
@param bdd the BDD
@return the BDD as LogicNG data structure | [
"Returns",
"a",
"LogicNG",
"internal",
"BDD",
"data",
"structure",
"of",
"a",
"given",
"BDD",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/BDDFactory.java#L443-L461 | train |
logic-ng/LogicNG | src/main/java/org/logicng/collections/ImmutableFormulaList.java | ImmutableFormulaList.formula | public Formula formula(final FormulaFactory f) {
if (this.operator != FType.AND && this.operator != FType.OR)
throw new IllegalStateException("Illegal operator for formula list formula construction: " + this.operator);
if (this.formula == null) {
if (this.operator == FType.AND)
this.formula = f.and(this.formulas);
else
this.formula = f.or(this.formulas);
}
return this.formula;
} | java | public Formula formula(final FormulaFactory f) {
if (this.operator != FType.AND && this.operator != FType.OR)
throw new IllegalStateException("Illegal operator for formula list formula construction: " + this.operator);
if (this.formula == null) {
if (this.operator == FType.AND)
this.formula = f.and(this.formulas);
else
this.formula = f.or(this.formulas);
}
return this.formula;
} | [
"public",
"Formula",
"formula",
"(",
"final",
"FormulaFactory",
"f",
")",
"{",
"if",
"(",
"this",
".",
"operator",
"!=",
"FType",
".",
"AND",
"&&",
"this",
".",
"operator",
"!=",
"FType",
".",
"OR",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"I... | Returns this formula list as a formula if there is an operator.
@param f the formula factory
@return this formula list as a formula
@throws IllegalStateException if the operator is not n-ary | [
"Returns",
"this",
"formula",
"list",
"as",
"a",
"formula",
"if",
"there",
"is",
"an",
"operator",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/ImmutableFormulaList.java#L156-L166 | train |
logic-ng/LogicNG | src/main/java/org/logicng/collections/ImmutableFormulaList.java | ImmutableFormulaList.get | public Formula get(final int i) {
if (i < 0 || i >= this.formulas.length)
throw new IllegalArgumentException("Illegal formula index: " + i);
return this.formulas[i];
} | java | public Formula get(final int i) {
if (i < 0 || i >= this.formulas.length)
throw new IllegalArgumentException("Illegal formula index: " + i);
return this.formulas[i];
} | [
"public",
"Formula",
"get",
"(",
"final",
"int",
"i",
")",
"{",
"if",
"(",
"i",
"<",
"0",
"||",
"i",
">=",
"this",
".",
"formulas",
".",
"length",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal formula index: \"",
"+",
"i",
")",
";",
... | Returns the i-th formula of this formula list.
@param i the index
@return the i-th formula of this formula list | [
"Returns",
"the",
"i",
"-",
"th",
"formula",
"of",
"this",
"formula",
"list",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/ImmutableFormulaList.java#L189-L193 | train |
logic-ng/LogicNG | src/main/java/org/logicng/collections/ImmutableFormulaList.java | ImmutableFormulaList.variables | public SortedSet<Variable> variables() {
if (this.variables == null) {
this.variables = new TreeSet<>();
for (final Formula f : this.formulas)
this.variables.addAll(f.variables());
}
return this.variables;
} | java | public SortedSet<Variable> variables() {
if (this.variables == null) {
this.variables = new TreeSet<>();
for (final Formula f : this.formulas)
this.variables.addAll(f.variables());
}
return this.variables;
} | [
"public",
"SortedSet",
"<",
"Variable",
">",
"variables",
"(",
")",
"{",
"if",
"(",
"this",
".",
"variables",
"==",
"null",
")",
"{",
"this",
".",
"variables",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Formula",
"f",
":",
"t... | Returns all variables occurring in this formula list.
@return all variables occurring in this formula list | [
"Returns",
"all",
"variables",
"occurring",
"in",
"this",
"formula",
"list",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/ImmutableFormulaList.java#L212-L219 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/Backbone.java | Backbone.getCompleteBackbone | public SortedSet<Literal> getCompleteBackbone() {
final SortedSet<Literal> completeBackbone = new TreeSet<>();
if (hasPositiveBackboneResult()) {
completeBackbone.addAll(this.positiveBackbone);
}
if (hasNegativeBackboneResult()) {
for (final Variable var : this.negativeBackbone) {
completeBackbone.add(var.negate());
}
}
return Collections.unmodifiableSortedSet(completeBackbone);
} | java | public SortedSet<Literal> getCompleteBackbone() {
final SortedSet<Literal> completeBackbone = new TreeSet<>();
if (hasPositiveBackboneResult()) {
completeBackbone.addAll(this.positiveBackbone);
}
if (hasNegativeBackboneResult()) {
for (final Variable var : this.negativeBackbone) {
completeBackbone.add(var.negate());
}
}
return Collections.unmodifiableSortedSet(completeBackbone);
} | [
"public",
"SortedSet",
"<",
"Literal",
">",
"getCompleteBackbone",
"(",
")",
"{",
"final",
"SortedSet",
"<",
"Literal",
">",
"completeBackbone",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"if",
"(",
"hasPositiveBackboneResult",
"(",
")",
")",
"{",
"complete... | Returns all literals of the backbone. Positive backbone variables have positive polarity, negative
backbone variables have negative polarity.
@return the set of both positive and negative backbone variables as literals | [
"Returns",
"all",
"literals",
"of",
"the",
"backbone",
".",
"Positive",
"backbone",
"variables",
"have",
"positive",
"polarity",
"negative",
"backbone",
"variables",
"have",
"negative",
"polarity",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/Backbone.java#L134-L145 | train |
logic-ng/LogicNG | src/main/java/org/logicng/graphs/datastructures/Graph.java | Graph.node | public Node<T> node(T content) {
final Node<T> search = nodes.get(content);
if (search != null)
return search;
final Node<T> n = new Node<>(content, this);
nodes.put(content, n);
return n;
} | java | public Node<T> node(T content) {
final Node<T> search = nodes.get(content);
if (search != null)
return search;
final Node<T> n = new Node<>(content, this);
nodes.put(content, n);
return n;
} | [
"public",
"Node",
"<",
"T",
">",
"node",
"(",
"T",
"content",
")",
"{",
"final",
"Node",
"<",
"T",
">",
"search",
"=",
"nodes",
".",
"get",
"(",
"content",
")",
";",
"if",
"(",
"search",
"!=",
"null",
")",
"return",
"search",
";",
"final",
"Node"... | Returns the node with a given content. If such a node does not exist, it is created and added to the graph.
@param content the given node content
@return the node with the given content | [
"Returns",
"the",
"node",
"with",
"a",
"given",
"content",
".",
"If",
"such",
"a",
"node",
"does",
"not",
"exist",
"it",
"is",
"created",
"and",
"added",
"to",
"the",
"graph",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/graphs/datastructures/Graph.java#L68-L75 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.encodeAMO | public void encodeAMO(final MiniSatStyleSolver s, final LNGIntVector lits) {
switch (this.amoEncoding) {
case LADDER:
this.ladder.encode(s, lits);
break;
default:
throw new IllegalStateException("Unknown AMO encoding: " + this.amoEncoding);
}
} | java | public void encodeAMO(final MiniSatStyleSolver s, final LNGIntVector lits) {
switch (this.amoEncoding) {
case LADDER:
this.ladder.encode(s, lits);
break;
default:
throw new IllegalStateException("Unknown AMO encoding: " + this.amoEncoding);
}
} | [
"public",
"void",
"encodeAMO",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
")",
"{",
"switch",
"(",
"this",
".",
"amoEncoding",
")",
"{",
"case",
"LADDER",
":",
"this",
".",
"ladder",
".",
"encode",
"(",
"s",
",",
"lits... | Encodes an AMO constraint in the given solver.
@param s the solver
@param lits the literals for the constraint
@throws IllegalStateException if the AMO encoding is unknown | [
"Encodes",
"an",
"AMO",
"constraint",
"in",
"the",
"given",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L151-L159 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.encodeCardinality | public void encodeCardinality(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) {
switch (this.cardinalityEncoding) {
case TOTALIZER:
this.totalizer.build(s, lits, rhs);
if (this.totalizer.hasCreatedEncoding())
this.totalizer.update(s, rhs);
break;
case MTOTALIZER:
this.mtotalizer.encode(s, lits, rhs);
break;
default:
throw new IllegalStateException("Unknown cardinality encoding: " + this.cardinalityEncoding);
}
} | java | public void encodeCardinality(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) {
switch (this.cardinalityEncoding) {
case TOTALIZER:
this.totalizer.build(s, lits, rhs);
if (this.totalizer.hasCreatedEncoding())
this.totalizer.update(s, rhs);
break;
case MTOTALIZER:
this.mtotalizer.encode(s, lits, rhs);
break;
default:
throw new IllegalStateException("Unknown cardinality encoding: " + this.cardinalityEncoding);
}
} | [
"public",
"void",
"encodeCardinality",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
",",
"int",
"rhs",
")",
"{",
"switch",
"(",
"this",
".",
"cardinalityEncoding",
")",
"{",
"case",
"TOTALIZER",
":",
"this",
".",
"totalizer",
... | Encodes a cardinality constraint in the given solver.
@param s the solver
@param lits the literals for the constraint
@param rhs the right hand side of the constraint
@throws IllegalStateException if the cardinality encoding is unknown | [
"Encodes",
"a",
"cardinality",
"constraint",
"in",
"the",
"given",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L168-L181 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.updateCardinality | public void updateCardinality(final MiniSatStyleSolver s, int rhs) {
switch (this.cardinalityEncoding) {
case TOTALIZER:
this.totalizer.update(s, rhs);
break;
case MTOTALIZER:
this.mtotalizer.update(s, rhs);
break;
default:
throw new IllegalStateException("Unknown cardinality encoding: " + this.cardinalityEncoding);
}
} | java | public void updateCardinality(final MiniSatStyleSolver s, int rhs) {
switch (this.cardinalityEncoding) {
case TOTALIZER:
this.totalizer.update(s, rhs);
break;
case MTOTALIZER:
this.mtotalizer.update(s, rhs);
break;
default:
throw new IllegalStateException("Unknown cardinality encoding: " + this.cardinalityEncoding);
}
} | [
"public",
"void",
"updateCardinality",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"int",
"rhs",
")",
"{",
"switch",
"(",
"this",
".",
"cardinalityEncoding",
")",
"{",
"case",
"TOTALIZER",
":",
"this",
".",
"totalizer",
".",
"update",
"(",
"s",
",",
"rhs... | Updates the cardinality constraint.
@param s the solver
@param rhs the new right hand side
@throws IllegalStateException if the cardinality encoding is unknown | [
"Updates",
"the",
"cardinality",
"constraint",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L189-L200 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.buildCardinality | public void buildCardinality(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) {
assert this.incrementalStrategy != IncrementalStrategy.NONE;
switch (this.cardinalityEncoding) {
case TOTALIZER:
this.totalizer.build(s, lits, rhs);
break;
default:
throw new IllegalStateException("Cardinality encoding does not support incrementality: " + this.incrementalStrategy);
}
} | java | public void buildCardinality(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) {
assert this.incrementalStrategy != IncrementalStrategy.NONE;
switch (this.cardinalityEncoding) {
case TOTALIZER:
this.totalizer.build(s, lits, rhs);
break;
default:
throw new IllegalStateException("Cardinality encoding does not support incrementality: " + this.incrementalStrategy);
}
} | [
"public",
"void",
"buildCardinality",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
",",
"int",
"rhs",
")",
"{",
"assert",
"this",
".",
"incrementalStrategy",
"!=",
"IncrementalStrategy",
".",
"NONE",
";",
"switch",
"(",
"this",
... | Manages the building of cardinality encodings. Currently is only used for incremental solving.
@param s the solver
@param lits the literals for the constraint
@param rhs the right hand side of the constraint
@throws IllegalStateException if the cardinality encoding does not support incrementality | [
"Manages",
"the",
"building",
"of",
"cardinality",
"encodings",
".",
"Currently",
"is",
"only",
"used",
"for",
"incremental",
"solving",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L209-L218 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.incUpdateCardinality | public void incUpdateCardinality(final MiniSatStyleSolver s, final LNGIntVector join, final LNGIntVector lits,
int rhs, final LNGIntVector assumptions) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.cardinalityEncoding) {
case TOTALIZER:
if (join.size() > 0)
this.totalizer.join(s, join, rhs);
assert lits.size() > 0;
this.totalizer.update(s, rhs, assumptions);
break;
default:
throw new IllegalArgumentException("Cardinality encoding does not support incrementality: " + this.incrementalStrategy);
}
} | java | public void incUpdateCardinality(final MiniSatStyleSolver s, final LNGIntVector join, final LNGIntVector lits,
int rhs, final LNGIntVector assumptions) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.cardinalityEncoding) {
case TOTALIZER:
if (join.size() > 0)
this.totalizer.join(s, join, rhs);
assert lits.size() > 0;
this.totalizer.update(s, rhs, assumptions);
break;
default:
throw new IllegalArgumentException("Cardinality encoding does not support incrementality: " + this.incrementalStrategy);
}
} | [
"public",
"void",
"incUpdateCardinality",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"join",
",",
"final",
"LNGIntVector",
"lits",
",",
"int",
"rhs",
",",
"final",
"LNGIntVector",
"assumptions",
")",
"{",
"assert",
"this",
".",
"incre... | Manages the incremental update of cardinality constraints.
@param s the solver
@param join the join literals
@param lits the literals of the constraint
@param rhs the right hand side of the constraint
@param assumptions the assumptions
@throws IllegalStateException if the cardinality encoding does not support incrementality | [
"Manages",
"the",
"incremental",
"update",
"of",
"cardinality",
"constraints",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L229-L242 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.encodePB | public void encodePB(final MiniSatStyleSolver s, final LNGIntVector lits, final LNGIntVector coeffs, int rhs) {
switch (this.pbEncoding) {
case SWC:
this.swc.encode(s, lits, coeffs, rhs);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | java | public void encodePB(final MiniSatStyleSolver s, final LNGIntVector lits, final LNGIntVector coeffs, int rhs) {
switch (this.pbEncoding) {
case SWC:
this.swc.encode(s, lits, coeffs, rhs);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | [
"public",
"void",
"encodePB",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
",",
"final",
"LNGIntVector",
"coeffs",
",",
"int",
"rhs",
")",
"{",
"switch",
"(",
"this",
".",
"pbEncoding",
")",
"{",
"case",
"SWC",
":",
"this"... | Encodes a pseudo-Boolean constraint.
@param s the solver
@param lits the literals of the constraint
@param coeffs the coefficients of the constraints
@param rhs the right hand side of the constraint
@throws IllegalStateException if the pseudo-Boolean encoding is unknown | [
"Encodes",
"a",
"pseudo",
"-",
"Boolean",
"constraint",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L252-L260 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.updatePB | public void updatePB(final MiniSatStyleSolver s, int rhs) {
switch (this.pbEncoding) {
case SWC:
this.swc.update(s, rhs);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | java | public void updatePB(final MiniSatStyleSolver s, int rhs) {
switch (this.pbEncoding) {
case SWC:
this.swc.update(s, rhs);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | [
"public",
"void",
"updatePB",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"int",
"rhs",
")",
"{",
"switch",
"(",
"this",
".",
"pbEncoding",
")",
"{",
"case",
"SWC",
":",
"this",
".",
"swc",
".",
"update",
"(",
"s",
",",
"rhs",
")",
";",
"break",
... | Updates a pseudo-Boolean encoding.
@param s the solver
@param rhs the new right hand side
@throws IllegalStateException if the pseudo-Boolean encoding is unknown | [
"Updates",
"a",
"pseudo",
"-",
"Boolean",
"encoding",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L268-L276 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.incEncodePB | public void incEncodePB(final MiniSatStyleSolver s, final LNGIntVector lits, final LNGIntVector coeffs,
int rhs, final LNGIntVector assumptions, int size) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.pbEncoding) {
case SWC:
this.swc.encode(s, lits, coeffs, rhs, assumptions, size);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | java | public void incEncodePB(final MiniSatStyleSolver s, final LNGIntVector lits, final LNGIntVector coeffs,
int rhs, final LNGIntVector assumptions, int size) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.pbEncoding) {
case SWC:
this.swc.encode(s, lits, coeffs, rhs, assumptions, size);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | [
"public",
"void",
"incEncodePB",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
",",
"final",
"LNGIntVector",
"coeffs",
",",
"int",
"rhs",
",",
"final",
"LNGIntVector",
"assumptions",
",",
"int",
"size",
")",
"{",
"assert",
"thi... | Incrementally encodes a pseudo-Boolean constraint.
@param s the solver
@param lits the literals of the constraint
@param coeffs the coefficients of the constraint
@param rhs the right hand size of the constraint
@param assumptions the current assumptions
@param size the size
@throws IllegalStateException if the pseudo-Boolean encoding is unknown | [
"Incrementally",
"encodes",
"a",
"pseudo",
"-",
"Boolean",
"constraint",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L288-L298 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.incUpdatePB | public void incUpdatePB(final MiniSatStyleSolver s, final LNGIntVector lits, final LNGIntVector coeffs, int rhs) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.pbEncoding) {
case SWC:
this.swc.updateInc(s, rhs);
this.swc.join(s, lits, coeffs);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | java | public void incUpdatePB(final MiniSatStyleSolver s, final LNGIntVector lits, final LNGIntVector coeffs, int rhs) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.pbEncoding) {
case SWC:
this.swc.updateInc(s, rhs);
this.swc.join(s, lits, coeffs);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | [
"public",
"void",
"incUpdatePB",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
",",
"final",
"LNGIntVector",
"coeffs",
",",
"int",
"rhs",
")",
"{",
"assert",
"this",
".",
"incrementalStrategy",
"==",
"IncrementalStrategy",
".",
"... | Manages the incremental update of pseudo-Boolean encodings.
@param s the solver
@param lits the literals of the constraint
@param coeffs the coefficients of the constraint
@param rhs the new right hand side of the constraint
@throws IllegalStateException if the pseudo-Boolean encoding is unknown | [
"Manages",
"the",
"incremental",
"update",
"of",
"pseudo",
"-",
"Boolean",
"encodings",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L308-L318 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java | Encoder.incUpdatePBAssumptions | public void incUpdatePBAssumptions(final LNGIntVector assumptions) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.pbEncoding) {
case SWC:
this.swc.updateAssumptions(assumptions);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | java | public void incUpdatePBAssumptions(final LNGIntVector assumptions) {
assert this.incrementalStrategy == IncrementalStrategy.ITERATIVE;
switch (this.pbEncoding) {
case SWC:
this.swc.updateAssumptions(assumptions);
break;
default:
throw new IllegalStateException("Unknown pseudo-Boolean encoding: " + this.pbEncoding);
}
} | [
"public",
"void",
"incUpdatePBAssumptions",
"(",
"final",
"LNGIntVector",
"assumptions",
")",
"{",
"assert",
"this",
".",
"incrementalStrategy",
"==",
"IncrementalStrategy",
".",
"ITERATIVE",
";",
"switch",
"(",
"this",
".",
"pbEncoding",
")",
"{",
"case",
"SWC",
... | Manages the incremental update of assumptions.
@param assumptions the assumptions
@throws IllegalStateException if the pseudo-Boolean encoding is unknown | [
"Manages",
"the",
"incremental",
"update",
"of",
"assumptions",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoder.java#L325-L334 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/datastructures/LNGBoundedIntQueue.java | LNGBoundedIntQueue.growTo | private void growTo(int size) {
this.elems.growTo(size, 0);
this.first = 0;
this.maxSize = size;
this.queueSize = 0;
this.last = 0;
} | java | private void growTo(int size) {
this.elems.growTo(size, 0);
this.first = 0;
this.maxSize = size;
this.queueSize = 0;
this.last = 0;
} | [
"private",
"void",
"growTo",
"(",
"int",
"size",
")",
"{",
"this",
".",
"elems",
".",
"growTo",
"(",
"size",
",",
"0",
")",
";",
"this",
".",
"first",
"=",
"0",
";",
"this",
".",
"maxSize",
"=",
"size",
";",
"this",
".",
"queueSize",
"=",
"0",
... | Grows this queue to a given size.
@param size the size | [
"Grows",
"this",
"queue",
"to",
"a",
"given",
"size",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/datastructures/LNGBoundedIntQueue.java#L147-L153 | train |
logic-ng/LogicNG | src/main/java/org/logicng/io/parsers/FormulaParser.java | FormulaParser.setLexerAndParser | void setLexerAndParser(final Lexer lexer, final ParserWithFormula parser) {
this.lexer = lexer;
this.parser = parser;
this.parser.setFormulaFactory(this.f);
this.lexer.removeErrorListeners();
this.parser.removeErrorListeners();
this.parser.setErrorHandler(new BailErrorStrategy());
} | java | void setLexerAndParser(final Lexer lexer, final ParserWithFormula parser) {
this.lexer = lexer;
this.parser = parser;
this.parser.setFormulaFactory(this.f);
this.lexer.removeErrorListeners();
this.parser.removeErrorListeners();
this.parser.setErrorHandler(new BailErrorStrategy());
} | [
"void",
"setLexerAndParser",
"(",
"final",
"Lexer",
"lexer",
",",
"final",
"ParserWithFormula",
"parser",
")",
"{",
"this",
".",
"lexer",
"=",
"lexer",
";",
"this",
".",
"parser",
"=",
"parser",
";",
"this",
".",
"parser",
".",
"setFormulaFactory",
"(",
"t... | Sets the internal lexer and the parser.
@param lexer the lexer
@param parser the parser | [
"Sets",
"the",
"internal",
"lexer",
"and",
"the",
"parser",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/io/parsers/FormulaParser.java#L67-L74 | train |
logic-ng/LogicNG | src/main/java/org/logicng/io/parsers/FormulaParser.java | FormulaParser.parse | public Formula parse(final InputStream inputStream) throws ParserException {
if (inputStream == null) {
return this.f.verum();
}
try {
final CharStream input = CharStreams.fromStream(inputStream);
this.lexer.setInputStream(input);
final CommonTokenStream tokens = new CommonTokenStream(this.lexer);
this.parser.setInputStream(tokens);
return this.parser.getParsedFormula();
} catch (final IOException e) {
throw new ParserException("IO exception when parsing the formula", e);
} catch (final ParseCancellationException e) {
throw new ParserException("Parse cancellation exception when parsing the formula", e);
} catch (final LexerException e) {
throw new ParserException("Lexer exception when parsing the formula.", e);
}
} | java | public Formula parse(final InputStream inputStream) throws ParserException {
if (inputStream == null) {
return this.f.verum();
}
try {
final CharStream input = CharStreams.fromStream(inputStream);
this.lexer.setInputStream(input);
final CommonTokenStream tokens = new CommonTokenStream(this.lexer);
this.parser.setInputStream(tokens);
return this.parser.getParsedFormula();
} catch (final IOException e) {
throw new ParserException("IO exception when parsing the formula", e);
} catch (final ParseCancellationException e) {
throw new ParserException("Parse cancellation exception when parsing the formula", e);
} catch (final LexerException e) {
throw new ParserException("Lexer exception when parsing the formula.", e);
}
} | [
"public",
"Formula",
"parse",
"(",
"final",
"InputStream",
"inputStream",
")",
"throws",
"ParserException",
"{",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"return",
"this",
".",
"f",
".",
"verum",
"(",
")",
";",
"}",
"try",
"{",
"final",
"CharStr... | Parses and returns a given input stream.
@param inputStream an input stream
@return the {@link Formula} representation of this stream
@throws ParserException if there was a problem with the input stream | [
"Parses",
"and",
"returns",
"a",
"given",
"input",
"stream",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/io/parsers/FormulaParser.java#L82-L99 | train |
logic-ng/LogicNG | src/main/java/org/logicng/io/parsers/FormulaParser.java | FormulaParser.parse | public Formula parse(final String in) throws ParserException {
if (in == null || in.isEmpty()) {
return this.f.verum();
}
try {
final CharStream input = CharStreams.fromString(in);
this.lexer.setInputStream(input);
final CommonTokenStream tokens = new CommonTokenStream(this.lexer);
this.parser.setInputStream(tokens);
return this.parser.getParsedFormula();
} catch (final ParseCancellationException e) {
throw new ParserException("Parse cancellation exception when parsing the formula", e);
} catch (final LexerException e) {
throw new ParserException("Lexer exception when parsing the formula.", e);
}
} | java | public Formula parse(final String in) throws ParserException {
if (in == null || in.isEmpty()) {
return this.f.verum();
}
try {
final CharStream input = CharStreams.fromString(in);
this.lexer.setInputStream(input);
final CommonTokenStream tokens = new CommonTokenStream(this.lexer);
this.parser.setInputStream(tokens);
return this.parser.getParsedFormula();
} catch (final ParseCancellationException e) {
throw new ParserException("Parse cancellation exception when parsing the formula", e);
} catch (final LexerException e) {
throw new ParserException("Lexer exception when parsing the formula.", e);
}
} | [
"public",
"Formula",
"parse",
"(",
"final",
"String",
"in",
")",
"throws",
"ParserException",
"{",
"if",
"(",
"in",
"==",
"null",
"||",
"in",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"this",
".",
"f",
".",
"verum",
"(",
")",
";",
"}",
"try",
... | Parses and returns a given string.
@param in a string
@return the {@link Formula} representation of this string
@throws ParserException if the string was not a valid formula | [
"Parses",
"and",
"returns",
"a",
"given",
"string",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/io/parsers/FormulaParser.java#L107-L122 | train |
logic-ng/LogicNG | src/main/java/org/logicng/cardinalityconstraints/CCAMOCommander.java | CCAMOCommander.encodeNonRecursive | private void encodeNonRecursive(final LNGVector<Literal> literals) {
if (literals.size() > 1)
for (int i = 0; i < literals.size(); i++)
for (int j = i + 1; j < literals.size(); j++)
this.result.addClause(literals.get(i).negate(), literals.get(j).negate());
} | java | private void encodeNonRecursive(final LNGVector<Literal> literals) {
if (literals.size() > 1)
for (int i = 0; i < literals.size(); i++)
for (int j = i + 1; j < literals.size(); j++)
this.result.addClause(literals.get(i).negate(), literals.get(j).negate());
} | [
"private",
"void",
"encodeNonRecursive",
"(",
"final",
"LNGVector",
"<",
"Literal",
">",
"literals",
")",
"{",
"if",
"(",
"literals",
".",
"size",
"(",
")",
">",
"1",
")",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"literals",
".",
"size",
"(... | Internal non recursive encoding.
@param literals the current literals | [
"Internal",
"non",
"recursive",
"encoding",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCAMOCommander.java#L127-L132 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Totalizer.java | Totalizer.update | public void update(final MiniSatStyleSolver s, int rhs) {
final LNGIntVector assumptions = new LNGIntVector();
this.update(s, rhs, assumptions);
} | java | public void update(final MiniSatStyleSolver s, int rhs) {
final LNGIntVector assumptions = new LNGIntVector();
this.update(s, rhs, assumptions);
} | [
"public",
"void",
"update",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"int",
"rhs",
")",
"{",
"final",
"LNGIntVector",
"assumptions",
"=",
"new",
"LNGIntVector",
"(",
")",
";",
"this",
".",
"update",
"(",
"s",
",",
"rhs",
",",
"assumptions",
")",
";"... | Updates the right hand side.
@param s the solver
@param rhs the new right hand side | [
"Updates",
"the",
"right",
"hand",
"side",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Totalizer.java#L103-L106 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/encodings/Totalizer.java | Totalizer.join | void join(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) {
assert this.incrementalStrategy == MaxSATConfig.IncrementalStrategy.ITERATIVE;
final LNGIntVector leftCardinalityOutlits = new LNGIntVector(this.cardinalityOutlits);
int oldCardinality = this.currentCardinalityRhs;
if (lits.size() > 1)
this.build(s, lits, rhs < lits.size() ? rhs : lits.size());
else {
assert lits.size() == 1;
this.cardinalityOutlits.clear();
this.cardinalityOutlits.push(lits.get(0));
}
final LNGIntVector rightCardinalityOutlits = new LNGIntVector(this.cardinalityOutlits);
this.cardinalityOutlits.clear();
for (int i = 0; i < leftCardinalityOutlits.size() + rightCardinalityOutlits.size(); i++) {
final int p = mkLit(s.nVars(), false);
MaxSAT.newSATVariable(s);
this.cardinalityOutlits.push(p);
}
this.currentCardinalityRhs = rhs;
this.adder(s, leftCardinalityOutlits, rightCardinalityOutlits, this.cardinalityOutlits);
this.currentCardinalityRhs = oldCardinality;
} | java | void join(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) {
assert this.incrementalStrategy == MaxSATConfig.IncrementalStrategy.ITERATIVE;
final LNGIntVector leftCardinalityOutlits = new LNGIntVector(this.cardinalityOutlits);
int oldCardinality = this.currentCardinalityRhs;
if (lits.size() > 1)
this.build(s, lits, rhs < lits.size() ? rhs : lits.size());
else {
assert lits.size() == 1;
this.cardinalityOutlits.clear();
this.cardinalityOutlits.push(lits.get(0));
}
final LNGIntVector rightCardinalityOutlits = new LNGIntVector(this.cardinalityOutlits);
this.cardinalityOutlits.clear();
for (int i = 0; i < leftCardinalityOutlits.size() + rightCardinalityOutlits.size(); i++) {
final int p = mkLit(s.nVars(), false);
MaxSAT.newSATVariable(s);
this.cardinalityOutlits.push(p);
}
this.currentCardinalityRhs = rhs;
this.adder(s, leftCardinalityOutlits, rightCardinalityOutlits, this.cardinalityOutlits);
this.currentCardinalityRhs = oldCardinality;
} | [
"void",
"join",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"LNGIntVector",
"lits",
",",
"int",
"rhs",
")",
"{",
"assert",
"this",
".",
"incrementalStrategy",
"==",
"MaxSATConfig",
".",
"IncrementalStrategy",
".",
"ITERATIVE",
";",
"final",
"LNGIntVec... | Joins two constraints. The given constraint is added to the current one.
@param s the solver
@param lits the literals of the constraint
@param rhs the right hand side of the constraint | [
"Joins",
"two",
"constraints",
".",
"The",
"given",
"constraint",
"is",
"added",
"to",
"the",
"current",
"one",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Totalizer.java#L138-L159 | train |
logic-ng/LogicNG | src/main/java/org/logicng/transformations/cnf/CNFEncoder.java | CNFEncoder.encode | public Formula encode(final Formula formula) {
switch (this.config().algorithm) {
case FACTORIZATION:
if (this.factorization == null)
this.factorization = new CNFFactorization();
return formula.transform(this.factorization);
case TSEITIN:
if (this.tseitin == null || this.currentAtomBoundary != this.config().atomBoundary) {
this.currentAtomBoundary = this.config().atomBoundary;
this.tseitin = new TseitinTransformation(this.config().atomBoundary);
}
return formula.transform(this.tseitin);
case PLAISTED_GREENBAUM:
if (this.plaistedGreenbaum == null || this.currentAtomBoundary != this.config().atomBoundary) {
this.currentAtomBoundary = this.config().atomBoundary;
this.plaistedGreenbaum = new PlaistedGreenbaumTransformation(this.config().atomBoundary);
}
return formula.transform(this.plaistedGreenbaum);
case BDD:
if (this.bddCnfTransformation == null)
this.bddCnfTransformation = new BDDCNFTransformation();
return formula.transform(this.bddCnfTransformation);
case ADVANCED:
if (this.factorizationHandler == null) {
this.factorizationHandler = new AdvancedFactorizationHandler();
this.advancedFactorization = new CNFFactorization(this.factorizationHandler);
}
this.factorizationHandler.reset(this.config().distributionBoundary, this.config().createdClauseBoundary);
return this.advancedEncoding(formula);
default:
throw new IllegalStateException("Unknown CNF encoding algorithm: " + this.config().algorithm);
}
} | java | public Formula encode(final Formula formula) {
switch (this.config().algorithm) {
case FACTORIZATION:
if (this.factorization == null)
this.factorization = new CNFFactorization();
return formula.transform(this.factorization);
case TSEITIN:
if (this.tseitin == null || this.currentAtomBoundary != this.config().atomBoundary) {
this.currentAtomBoundary = this.config().atomBoundary;
this.tseitin = new TseitinTransformation(this.config().atomBoundary);
}
return formula.transform(this.tseitin);
case PLAISTED_GREENBAUM:
if (this.plaistedGreenbaum == null || this.currentAtomBoundary != this.config().atomBoundary) {
this.currentAtomBoundary = this.config().atomBoundary;
this.plaistedGreenbaum = new PlaistedGreenbaumTransformation(this.config().atomBoundary);
}
return formula.transform(this.plaistedGreenbaum);
case BDD:
if (this.bddCnfTransformation == null)
this.bddCnfTransformation = new BDDCNFTransformation();
return formula.transform(this.bddCnfTransformation);
case ADVANCED:
if (this.factorizationHandler == null) {
this.factorizationHandler = new AdvancedFactorizationHandler();
this.advancedFactorization = new CNFFactorization(this.factorizationHandler);
}
this.factorizationHandler.reset(this.config().distributionBoundary, this.config().createdClauseBoundary);
return this.advancedEncoding(formula);
default:
throw new IllegalStateException("Unknown CNF encoding algorithm: " + this.config().algorithm);
}
} | [
"public",
"Formula",
"encode",
"(",
"final",
"Formula",
"formula",
")",
"{",
"switch",
"(",
"this",
".",
"config",
"(",
")",
".",
"algorithm",
")",
"{",
"case",
"FACTORIZATION",
":",
"if",
"(",
"this",
".",
"factorization",
"==",
"null",
")",
"this",
"... | Encodes a formula to CNF.
@param formula formula
@return the CNF encoding of the formula | [
"Encodes",
"a",
"formula",
"to",
"CNF",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/transformations/cnf/CNFEncoder.java#L84-L116 | train |
logic-ng/LogicNG | src/main/java/org/logicng/transformations/cnf/CNFEncoder.java | CNFEncoder.advancedEncoding | private Formula advancedEncoding(final Formula formula) {
if (formula.type() == FType.AND) {
final List<Formula> operands = new ArrayList<>(formula.numberOfOperands());
for (final Formula op : formula)
operands.add(singleAdvancedEncoding(op));
return this.f.and(operands);
}
return singleAdvancedEncoding(formula);
} | java | private Formula advancedEncoding(final Formula formula) {
if (formula.type() == FType.AND) {
final List<Formula> operands = new ArrayList<>(formula.numberOfOperands());
for (final Formula op : formula)
operands.add(singleAdvancedEncoding(op));
return this.f.and(operands);
}
return singleAdvancedEncoding(formula);
} | [
"private",
"Formula",
"advancedEncoding",
"(",
"final",
"Formula",
"formula",
")",
"{",
"if",
"(",
"formula",
".",
"type",
"(",
")",
"==",
"FType",
".",
"AND",
")",
"{",
"final",
"List",
"<",
"Formula",
">",
"operands",
"=",
"new",
"ArrayList",
"<>",
"... | Encodes the given formula to CNF by first trying to use Factorization for the single sub-formulas. When certain
user-provided boundaries are met, the method is switched to Tseitin or Plaisted & Greenbaum.
@param formula the formula
@return the CNF encoding of the formula | [
"Encodes",
"the",
"given",
"formula",
"to",
"CNF",
"by",
"first",
"trying",
"to",
"use",
"Factorization",
"for",
"the",
"single",
"sub",
"-",
"formulas",
".",
"When",
"certain",
"user",
"-",
"provided",
"boundaries",
"are",
"met",
"the",
"method",
"is",
"s... | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/transformations/cnf/CNFEncoder.java#L124-L132 | train |
logic-ng/LogicNG | src/main/java/org/logicng/functions/LiteralProfileFunction.java | LiteralProfileFunction.nonCachingLiteralProfile | private static Map<Literal, Integer> nonCachingLiteralProfile(final Formula formula) {
final SortedMap<Literal, Integer> map = new TreeMap<>();
nonCachingRecursion(formula, map);
return map;
} | java | private static Map<Literal, Integer> nonCachingLiteralProfile(final Formula formula) {
final SortedMap<Literal, Integer> map = new TreeMap<>();
nonCachingRecursion(formula, map);
return map;
} | [
"private",
"static",
"Map",
"<",
"Literal",
",",
"Integer",
">",
"nonCachingLiteralProfile",
"(",
"final",
"Formula",
"formula",
")",
"{",
"final",
"SortedMap",
"<",
"Literal",
",",
"Integer",
">",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"nonCac... | The non-caching implementation of the literal profile computation. In this case the result map is only
constructed once and results are just added to it.
@param formula the formula
@return the literal profile | [
"The",
"non",
"-",
"caching",
"implementation",
"of",
"the",
"literal",
"profile",
"computation",
".",
"In",
"this",
"case",
"the",
"result",
"map",
"is",
"only",
"constructed",
"once",
"and",
"results",
"are",
"just",
"added",
"to",
"it",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/functions/LiteralProfileFunction.java#L62-L66 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingMinimalisticSolver.java | CleaneLingMinimalisticSolver.printSolverState | public void printSolverState(final PrintStream output) {
output.println("level=" + this.level);
output.println("next=" + this.next);
output.println("ignore=" + this.ignore);
output.println("empty=" + this.empty);
output.println("vars=" + this.vars);
output.println("vals=" + this.vals);
output.println("phases=" + this.phases);
output.println("decisions=" + this.decisions);
output.println("control=" + this.control);
output.println("watches=" + this.watches);
output.println("trail=" + this.trail);
output.println("frames=" + this.frames);
} | java | public void printSolverState(final PrintStream output) {
output.println("level=" + this.level);
output.println("next=" + this.next);
output.println("ignore=" + this.ignore);
output.println("empty=" + this.empty);
output.println("vars=" + this.vars);
output.println("vals=" + this.vals);
output.println("phases=" + this.phases);
output.println("decisions=" + this.decisions);
output.println("control=" + this.control);
output.println("watches=" + this.watches);
output.println("trail=" + this.trail);
output.println("frames=" + this.frames);
} | [
"public",
"void",
"printSolverState",
"(",
"final",
"PrintStream",
"output",
")",
"{",
"output",
".",
"println",
"(",
"\"level=\"",
"+",
"this",
".",
"level",
")",
";",
"output",
".",
"println",
"(",
"\"next=\"",
"+",
"this",
".",
"next",
")",
";",
"outp... | Prints the current solver state to a given output stream.
@param output the output stream | [
"Prints",
"the",
"current",
"solver",
"state",
"to",
"a",
"given",
"output",
"stream",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingMinimalisticSolver.java#L355-L368 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.add | public void add(final Formula formula) {
final Formula cnf = formula.cnf();
switch (cnf.type()) {
case TRUE:
break;
case FALSE:
case LITERAL:
case OR:
this.addClause(generateClauseVector(cnf), null);
break;
case AND:
for (final Formula op : cnf) {
this.addClause(generateClauseVector(op), null);
}
break;
default:
throw new IllegalStateException("Unexpected formula type in CNF: " + cnf.type());
}
} | java | public void add(final Formula formula) {
final Formula cnf = formula.cnf();
switch (cnf.type()) {
case TRUE:
break;
case FALSE:
case LITERAL:
case OR:
this.addClause(generateClauseVector(cnf), null);
break;
case AND:
for (final Formula op : cnf) {
this.addClause(generateClauseVector(op), null);
}
break;
default:
throw new IllegalStateException("Unexpected formula type in CNF: " + cnf.type());
}
} | [
"public",
"void",
"add",
"(",
"final",
"Formula",
"formula",
")",
"{",
"final",
"Formula",
"cnf",
"=",
"formula",
".",
"cnf",
"(",
")",
";",
"switch",
"(",
"cnf",
".",
"type",
"(",
")",
")",
"{",
"case",
"TRUE",
":",
"break",
";",
"case",
"FALSE",
... | Adds an arbitrary formula to the solver.
@param formula the formula | [
"Adds",
"an",
"arbitrary",
"formula",
"to",
"the",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L119-L137 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.getRelevantVarIndices | private List<Integer> getRelevantVarIndices(final Collection<Variable> variables) {
final List<Integer> relevantVarIndices = new ArrayList<>(variables.size());
for (final Variable var : variables) {
final Integer idx = this.name2idx.get(var.name());
// Note: Unknown variables are variables added to the solver yet. Thus, these are optional variables and can
// be left out for the backbone computation.
if (idx != null) {
relevantVarIndices.add(idx);
}
}
return relevantVarIndices;
} | java | private List<Integer> getRelevantVarIndices(final Collection<Variable> variables) {
final List<Integer> relevantVarIndices = new ArrayList<>(variables.size());
for (final Variable var : variables) {
final Integer idx = this.name2idx.get(var.name());
// Note: Unknown variables are variables added to the solver yet. Thus, these are optional variables and can
// be left out for the backbone computation.
if (idx != null) {
relevantVarIndices.add(idx);
}
}
return relevantVarIndices;
} | [
"private",
"List",
"<",
"Integer",
">",
"getRelevantVarIndices",
"(",
"final",
"Collection",
"<",
"Variable",
">",
"variables",
")",
"{",
"final",
"List",
"<",
"Integer",
">",
"relevantVarIndices",
"=",
"new",
"ArrayList",
"<>",
"(",
"variables",
".",
"size",
... | Returns a list of relevant variable indices. A relevant variable is known by the solver.
@param variables variables to convert and filter
@return list of relevant variable indices | [
"Returns",
"a",
"list",
"of",
"relevant",
"variable",
"indices",
".",
"A",
"relevant",
"variable",
"is",
"known",
"by",
"the",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L154-L165 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.buildBackbone | private Backbone buildBackbone(final Collection<Variable> variables) {
final SortedSet<Variable> posBackboneVars = isBothOrPositiveType() ? new TreeSet<Variable>() : null;
final SortedSet<Variable> negBackboneVars = isBothOrNegativeType() ? new TreeSet<Variable>() : null;
final SortedSet<Variable> optionalVars = isBothType() ? new TreeSet<Variable>() : null;
for (final Variable var : variables) {
final Integer idx = this.name2idx.get(var.name());
if (idx == null) {
if (isBothType()) {
optionalVars.add(var);
}
} else {
switch (this.backboneMap.get(idx)) {
case TRUE:
if (isBothOrPositiveType()) {
posBackboneVars.add(var);
}
break;
case FALSE:
if (isBothOrNegativeType()) {
negBackboneVars.add(var);
}
break;
case UNDEF:
if (isBothType()) {
optionalVars.add(var);
}
break;
default:
throw new IllegalStateException("Unknown tristate: " + this.backboneMap.get(idx));
}
}
}
return new Backbone(posBackboneVars, negBackboneVars, optionalVars);
} | java | private Backbone buildBackbone(final Collection<Variable> variables) {
final SortedSet<Variable> posBackboneVars = isBothOrPositiveType() ? new TreeSet<Variable>() : null;
final SortedSet<Variable> negBackboneVars = isBothOrNegativeType() ? new TreeSet<Variable>() : null;
final SortedSet<Variable> optionalVars = isBothType() ? new TreeSet<Variable>() : null;
for (final Variable var : variables) {
final Integer idx = this.name2idx.get(var.name());
if (idx == null) {
if (isBothType()) {
optionalVars.add(var);
}
} else {
switch (this.backboneMap.get(idx)) {
case TRUE:
if (isBothOrPositiveType()) {
posBackboneVars.add(var);
}
break;
case FALSE:
if (isBothOrNegativeType()) {
negBackboneVars.add(var);
}
break;
case UNDEF:
if (isBothType()) {
optionalVars.add(var);
}
break;
default:
throw new IllegalStateException("Unknown tristate: " + this.backboneMap.get(idx));
}
}
}
return new Backbone(posBackboneVars, negBackboneVars, optionalVars);
} | [
"private",
"Backbone",
"buildBackbone",
"(",
"final",
"Collection",
"<",
"Variable",
">",
"variables",
")",
"{",
"final",
"SortedSet",
"<",
"Variable",
">",
"posBackboneVars",
"=",
"isBothOrPositiveType",
"(",
")",
"?",
"new",
"TreeSet",
"<",
"Variable",
">",
... | Builds the backbone object from the computed backbone literals.
@param variables relevant variables
@return backbone | [
"Builds",
"the",
"backbone",
"object",
"from",
"the",
"computed",
"backbone",
"literals",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L211-L244 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.compute | public Backbone compute(final Collection<Variable> variables, final BackboneType type) {
final boolean sat = solve(null) == Tristate.TRUE;
Backbone backbone = null;
if (sat) {
final List<Integer> relevantVarIndices = getRelevantVarIndices(variables);
init(relevantVarIndices, type);
compute(relevantVarIndices);
backbone = buildBackbone(variables);
}
return backbone;
} | java | public Backbone compute(final Collection<Variable> variables, final BackboneType type) {
final boolean sat = solve(null) == Tristate.TRUE;
Backbone backbone = null;
if (sat) {
final List<Integer> relevantVarIndices = getRelevantVarIndices(variables);
init(relevantVarIndices, type);
compute(relevantVarIndices);
backbone = buildBackbone(variables);
}
return backbone;
} | [
"public",
"Backbone",
"compute",
"(",
"final",
"Collection",
"<",
"Variable",
">",
"variables",
",",
"final",
"BackboneType",
"type",
")",
"{",
"final",
"boolean",
"sat",
"=",
"solve",
"(",
"null",
")",
"==",
"Tristate",
".",
"TRUE",
";",
"Backbone",
"back... | Computes the backbone of the given variables with respect to the formulas added to the solver.
@param variables variables to test
@param type backbone type
@return the backbone projected to the relevant variables or {@code null} if the formula on the solver with the restrictions are not satisfiable | [
"Computes",
"the",
"backbone",
"of",
"the",
"given",
"variables",
"with",
"respect",
"to",
"the",
"formulas",
"added",
"to",
"the",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L252-L262 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.isUnit | private boolean isUnit(final int lit, final MSClause clause) {
for (int i = 0; i < clause.size(); ++i) {
final int clauseLit = clause.get(i);
if (lit != clauseLit && this.model.get(var(clauseLit)) != sign(clauseLit)) {
return false;
}
}
return true;
} | java | private boolean isUnit(final int lit, final MSClause clause) {
for (int i = 0; i < clause.size(); ++i) {
final int clauseLit = clause.get(i);
if (lit != clauseLit && this.model.get(var(clauseLit)) != sign(clauseLit)) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"isUnit",
"(",
"final",
"int",
"lit",
",",
"final",
"MSClause",
"clause",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"clause",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"final",
"int",
"clauseLit",
"="... | Tests the given literal whether it is unit in the given clause.
@param lit literal to test
@param clause clause containing the literal
@return {@code true} if the literal is unit, {@code false} otherwise | [
"Tests",
"the",
"given",
"literal",
"whether",
"it",
"is",
"unit",
"in",
"the",
"given",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L281-L289 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.isRotatable | private boolean isRotatable(final int lit) {
// Unit propagated literals cannot be rotatable
if (v(var(lit)).reason() != null) {
return false;
}
// A rotatable literal MUST NOT be unit
for (final MSWatcher watcher : this.watches.get(not(lit))) {
if (isUnit(lit, watcher.clause())) {
return false;
}
}
return true;
} | java | private boolean isRotatable(final int lit) {
// Unit propagated literals cannot be rotatable
if (v(var(lit)).reason() != null) {
return false;
}
// A rotatable literal MUST NOT be unit
for (final MSWatcher watcher : this.watches.get(not(lit))) {
if (isUnit(lit, watcher.clause())) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"isRotatable",
"(",
"final",
"int",
"lit",
")",
"{",
"// Unit propagated literals cannot be rotatable",
"if",
"(",
"v",
"(",
"var",
"(",
"lit",
")",
")",
".",
"reason",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
... | Tests the given literal whether it is rotatable in the current model.
@param lit literal to test
@return {@code true} if the literal is rotatable, otherwise {@code false} | [
"Tests",
"the",
"given",
"literal",
"whether",
"it",
"is",
"rotatable",
"in",
"the",
"current",
"model",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L296-L308 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.addBackboneLiteral | private void addBackboneLiteral(final int lit) {
this.backboneMap.put(var(lit), sign(lit) ? Tristate.FALSE : Tristate.TRUE);
this.assumptions.push(lit);
} | java | private void addBackboneLiteral(final int lit) {
this.backboneMap.put(var(lit), sign(lit) ? Tristate.FALSE : Tristate.TRUE);
this.assumptions.push(lit);
} | [
"private",
"void",
"addBackboneLiteral",
"(",
"final",
"int",
"lit",
")",
"{",
"this",
".",
"backboneMap",
".",
"put",
"(",
"var",
"(",
"lit",
")",
",",
"sign",
"(",
"lit",
")",
"?",
"Tristate",
".",
"FALSE",
":",
"Tristate",
".",
"TRUE",
")",
";",
... | Adds the given literal to the backbone result and optionally adds the literal to the solver.
@param lit literal to add | [
"Adds",
"the",
"given",
"literal",
"to",
"the",
"backbone",
"result",
"and",
"optionally",
"adds",
"the",
"literal",
"to",
"the",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L314-L317 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.createInitialCandidates | private Stack<Integer> createInitialCandidates(final List<Integer> variables) {
for (final Integer var : variables) {
if (isUPZeroLit(var)) {
final int backboneLit = mkLit(var, !this.model.get(var));
addBackboneLiteral(backboneLit);
} else {
final boolean modelPhase = this.model.get(var);
if (isBothOrNegativeType() && !modelPhase || isBothOrPositiveType() && modelPhase) {
final int lit = mkLit(var, !modelPhase);
if (!this.config.isInitialUBCheckForRotatableLiterals() || !isRotatable(lit)) {
this.candidates.add(lit);
}
}
}
}
return this.candidates;
} | java | private Stack<Integer> createInitialCandidates(final List<Integer> variables) {
for (final Integer var : variables) {
if (isUPZeroLit(var)) {
final int backboneLit = mkLit(var, !this.model.get(var));
addBackboneLiteral(backboneLit);
} else {
final boolean modelPhase = this.model.get(var);
if (isBothOrNegativeType() && !modelPhase || isBothOrPositiveType() && modelPhase) {
final int lit = mkLit(var, !modelPhase);
if (!this.config.isInitialUBCheckForRotatableLiterals() || !isRotatable(lit)) {
this.candidates.add(lit);
}
}
}
}
return this.candidates;
} | [
"private",
"Stack",
"<",
"Integer",
">",
"createInitialCandidates",
"(",
"final",
"List",
"<",
"Integer",
">",
"variables",
")",
"{",
"for",
"(",
"final",
"Integer",
"var",
":",
"variables",
")",
"{",
"if",
"(",
"isUPZeroLit",
"(",
"var",
")",
")",
"{",
... | Creates the initial candidate literals for the backbone computation.
@param variables variables to test
@return initial candidates | [
"Creates",
"the",
"initial",
"candidate",
"literals",
"for",
"the",
"backbone",
"computation",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L324-L340 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.solve | private boolean solve(final int lit) {
this.assumptions.push(not(lit));
final boolean sat = solve(null, this.assumptions) == Tristate.TRUE;
this.assumptions.pop();
return sat;
} | java | private boolean solve(final int lit) {
this.assumptions.push(not(lit));
final boolean sat = solve(null, this.assumptions) == Tristate.TRUE;
this.assumptions.pop();
return sat;
} | [
"private",
"boolean",
"solve",
"(",
"final",
"int",
"lit",
")",
"{",
"this",
".",
"assumptions",
".",
"push",
"(",
"not",
"(",
"lit",
")",
")",
";",
"final",
"boolean",
"sat",
"=",
"solve",
"(",
"null",
",",
"this",
".",
"assumptions",
")",
"==",
"... | Tests the given literal with the formula on the solver for satisfiability.
@param lit literal to test
@return {@code true} if satisfiable, otherwise {@code false} | [
"Tests",
"the",
"given",
"literal",
"with",
"the",
"formula",
"on",
"the",
"solver",
"for",
"satisfiability",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L364-L369 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.compute | private void compute(final List<Integer> variables) {
final Stack<Integer> candidates = createInitialCandidates(variables);
while (candidates.size() > 0) {
final int lit = candidates.pop();
if (solve(lit)) {
refineUpperBound();
} else {
addBackboneLiteral(lit);
}
}
} | java | private void compute(final List<Integer> variables) {
final Stack<Integer> candidates = createInitialCandidates(variables);
while (candidates.size() > 0) {
final int lit = candidates.pop();
if (solve(lit)) {
refineUpperBound();
} else {
addBackboneLiteral(lit);
}
}
} | [
"private",
"void",
"compute",
"(",
"final",
"List",
"<",
"Integer",
">",
"variables",
")",
"{",
"final",
"Stack",
"<",
"Integer",
">",
"candidates",
"=",
"createInitialCandidates",
"(",
"variables",
")",
";",
"while",
"(",
"candidates",
".",
"size",
"(",
"... | Computes the backbone for the given variables.
@param variables variables to test | [
"Computes",
"the",
"backbone",
"for",
"the",
"given",
"variables",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L391-L401 | train |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/MiniSatBackbone.java | MiniSatBackbone.generateClauseVector | private LNGIntVector generateClauseVector(final Formula clause) {
final LNGIntVector clauseVec = new LNGIntVector(clause.numberOfOperands());
for (final Literal lit : clause.literals()) {
int index = this.idxForName(lit.name());
if (index == -1) {
index = this.newVar(false, true);
this.addName(lit.name(), index);
}
final int litNum = lit.phase() ? index * 2 : (index * 2) ^ 1;
clauseVec.push(litNum);
}
return clauseVec;
} | java | private LNGIntVector generateClauseVector(final Formula clause) {
final LNGIntVector clauseVec = new LNGIntVector(clause.numberOfOperands());
for (final Literal lit : clause.literals()) {
int index = this.idxForName(lit.name());
if (index == -1) {
index = this.newVar(false, true);
this.addName(lit.name(), index);
}
final int litNum = lit.phase() ? index * 2 : (index * 2) ^ 1;
clauseVec.push(litNum);
}
return clauseVec;
} | [
"private",
"LNGIntVector",
"generateClauseVector",
"(",
"final",
"Formula",
"clause",
")",
"{",
"final",
"LNGIntVector",
"clauseVec",
"=",
"new",
"LNGIntVector",
"(",
"clause",
".",
"numberOfOperands",
"(",
")",
")",
";",
"for",
"(",
"final",
"Literal",
"lit",
... | Generates a solver vector of a clause.
@param clause the clause
@return the solver vector | [
"Generates",
"a",
"solver",
"vector",
"of",
"a",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/MiniSatBackbone.java#L408-L420 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.biasPhases | private void biasPhases() {
final double[] score = new double[2 * (maxvar() + 1)];
for (final CLClause c : this.clauses) {
if (c.redundant() || c.satisfied()) { continue; }
double inc = 1;
for (int size = c.size(); size > 0; size--) { inc /= 2.0; }
for (int i = 0; i < c.lits().size(); i++) {
final int p = c.lits().get(i);
if (p > 0) { score[p * 2] += inc; } else { score[(-p * 2) - 1] += inc; }
}
}
for (int idx = 1; idx <= maxvar(); idx++) { this.phases.set(idx, (score[idx * 2] > score[(idx * 2) - 1]) ? (byte) 1 : (byte) -1); }
} | java | private void biasPhases() {
final double[] score = new double[2 * (maxvar() + 1)];
for (final CLClause c : this.clauses) {
if (c.redundant() || c.satisfied()) { continue; }
double inc = 1;
for (int size = c.size(); size > 0; size--) { inc /= 2.0; }
for (int i = 0; i < c.lits().size(); i++) {
final int p = c.lits().get(i);
if (p > 0) { score[p * 2] += inc; } else { score[(-p * 2) - 1] += inc; }
}
}
for (int idx = 1; idx <= maxvar(); idx++) { this.phases.set(idx, (score[idx * 2] > score[(idx * 2) - 1]) ? (byte) 1 : (byte) -1); }
} | [
"private",
"void",
"biasPhases",
"(",
")",
"{",
"final",
"double",
"[",
"]",
"score",
"=",
"new",
"double",
"[",
"2",
"*",
"(",
"maxvar",
"(",
")",
"+",
"1",
")",
"]",
";",
"for",
"(",
"final",
"CLClause",
"c",
":",
"this",
".",
"clauses",
")",
... | Initializes the initial phases of literals. | [
"Initializes",
"the",
"initial",
"phases",
"of",
"literals",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L523-L535 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.touch | private void touch(final int l) {
int lit = l;
if (lit < 0) { lit = -lit; }
final long newPriority = (long) occs(lit).count() + occs(-lit).count();
if (!var(lit).free()) { return; }
final LNGLongPriorityQueue queue = currentCands();
queue.update(lit, -newPriority);
if (this.schedule && !queue.contains(lit)) { queue.push(lit); }
} | java | private void touch(final int l) {
int lit = l;
if (lit < 0) { lit = -lit; }
final long newPriority = (long) occs(lit).count() + occs(-lit).count();
if (!var(lit).free()) { return; }
final LNGLongPriorityQueue queue = currentCands();
queue.update(lit, -newPriority);
if (this.schedule && !queue.contains(lit)) { queue.push(lit); }
} | [
"private",
"void",
"touch",
"(",
"final",
"int",
"l",
")",
"{",
"int",
"lit",
"=",
"l",
";",
"if",
"(",
"lit",
"<",
"0",
")",
"{",
"lit",
"=",
"-",
"lit",
";",
"}",
"final",
"long",
"newPriority",
"=",
"(",
"long",
")",
"occs",
"(",
"lit",
")... | Updates and pushes a literal as candidate to simplify.
@param l the literal | [
"Updates",
"and",
"pushes",
"a",
"literal",
"as",
"candidate",
"to",
"simplify",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L550-L558 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.touchFixed | private void touchFixed() {
assert this.dense;
assert this.level == 0;
assert this.schedule;
while (this.touched < this.trail.size()) {
final int lit = this.trail.get(this.touched++);
assert val(lit) > 0;
assert var(lit).level() == 0;
final CLOccs os = occs(lit);
for (final CLClause c : os) {
for (int i = 0; i < c.lits().size(); i++) {
final int other = c.lits().get(i);
if (val(other) == VALUE_TRUE) { continue; }
assert other != lit;
touch(other);
}
}
}
} | java | private void touchFixed() {
assert this.dense;
assert this.level == 0;
assert this.schedule;
while (this.touched < this.trail.size()) {
final int lit = this.trail.get(this.touched++);
assert val(lit) > 0;
assert var(lit).level() == 0;
final CLOccs os = occs(lit);
for (final CLClause c : os) {
for (int i = 0; i < c.lits().size(); i++) {
final int other = c.lits().get(i);
if (val(other) == VALUE_TRUE) { continue; }
assert other != lit;
touch(other);
}
}
}
} | [
"private",
"void",
"touchFixed",
"(",
")",
"{",
"assert",
"this",
".",
"dense",
";",
"assert",
"this",
".",
"level",
"==",
"0",
";",
"assert",
"this",
".",
"schedule",
";",
"while",
"(",
"this",
".",
"touched",
"<",
"this",
".",
"trail",
".",
"size",... | Touches literals in newly top-level satisfied clauses using the literals not touched yet. | [
"Touches",
"literals",
"in",
"newly",
"top",
"-",
"level",
"satisfied",
"clauses",
"using",
"the",
"literals",
"not",
"touched",
"yet",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L576-L594 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.addOcc | private void addOcc(final int lit, final CLClause c) {
assert this.dense;
occs(lit).add(c);
touch(lit);
} | java | private void addOcc(final int lit, final CLClause c) {
assert this.dense;
occs(lit).add(c);
touch(lit);
} | [
"private",
"void",
"addOcc",
"(",
"final",
"int",
"lit",
",",
"final",
"CLClause",
"c",
")",
"{",
"assert",
"this",
".",
"dense",
";",
"occs",
"(",
"lit",
")",
".",
"add",
"(",
"c",
")",
";",
"touch",
"(",
"lit",
")",
";",
"}"
] | Adds a clause to a literal's occurrence list.
@param lit the literal
@param c the clause | [
"Adds",
"a",
"clause",
"to",
"a",
"literal",
"s",
"occurrence",
"list",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L601-L605 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.connectOccs | private void connectOccs(final CLClause c) {
assert this.dense;
for (int i = 0; i < c.lits().size(); i++) { addOcc(c.lits().get(i), c); }
} | java | private void connectOccs(final CLClause c) {
assert this.dense;
for (int i = 0; i < c.lits().size(); i++) { addOcc(c.lits().get(i), c); }
} | [
"private",
"void",
"connectOccs",
"(",
"final",
"CLClause",
"c",
")",
"{",
"assert",
"this",
".",
"dense",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"c",
".",
"lits",
"(",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"add... | Connects a clause through a full occurrence list.
@param c the clause | [
"Connects",
"a",
"clause",
"through",
"a",
"full",
"occurrence",
"list",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L611-L614 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.connectOccs | private void connectOccs() {
assert !this.dense;
this.dense = true;
for (final CLClause c : this.clauses) { if (!c.redundant()) { connectOccs(c); } }
} | java | private void connectOccs() {
assert !this.dense;
this.dense = true;
for (final CLClause c : this.clauses) { if (!c.redundant()) { connectOccs(c); } }
} | [
"private",
"void",
"connectOccs",
"(",
")",
"{",
"assert",
"!",
"this",
".",
"dense",
";",
"this",
".",
"dense",
"=",
"true",
";",
"for",
"(",
"final",
"CLClause",
"c",
":",
"this",
".",
"clauses",
")",
"{",
"if",
"(",
"!",
"c",
".",
"redundant",
... | Connects all clauses through full occurrence lists. | [
"Connects",
"all",
"clauses",
"through",
"full",
"occurrence",
"lists",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L619-L623 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.updateGlue | private void updateGlue(final CLClause c) {
if (!this.config.glueupdate) { return; }
if (!this.config.gluered) {
assert c.glue() == 0;
return;
}
assert this.frames.empty();
for (int i = 0; i < c.lits().size(); i++) { markFrame(c.lits().get(i)); }
final int newGlue = unmarkFrames();
if (newGlue >= c.glue()) { return; }
c.setGlue(newGlue);
this.stats.gluesSum += newGlue;
this.stats.gluesCount++;
this.stats.gluesUpdates++;
} | java | private void updateGlue(final CLClause c) {
if (!this.config.glueupdate) { return; }
if (!this.config.gluered) {
assert c.glue() == 0;
return;
}
assert this.frames.empty();
for (int i = 0; i < c.lits().size(); i++) { markFrame(c.lits().get(i)); }
final int newGlue = unmarkFrames();
if (newGlue >= c.glue()) { return; }
c.setGlue(newGlue);
this.stats.gluesSum += newGlue;
this.stats.gluesCount++;
this.stats.gluesUpdates++;
} | [
"private",
"void",
"updateGlue",
"(",
"final",
"CLClause",
"c",
")",
"{",
"if",
"(",
"!",
"this",
".",
"config",
".",
"glueupdate",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"config",
".",
"gluered",
")",
"{",
"assert",
"c",
".",
... | Updates the glue value for a given clause.
@param c the clause | [
"Updates",
"the",
"glue",
"value",
"for",
"a",
"given",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L639-L653 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.dumpClause | private void dumpClause(final CLClause c) {
if (c.dumped()) { return; }
if (c.redundant()) {
assert this.stats.clausesRedundant > 0;
this.stats.clausesRedundant--;
} else {
assert this.stats.clausesIrredundant > 0;
this.stats.clausesIrredundant--;
if (this.dense) { for (int i = 0; i < c.lits().size(); i++) { decOcc(c.lits().get(i)); } }
}
c.setDumped(true);
} | java | private void dumpClause(final CLClause c) {
if (c.dumped()) { return; }
if (c.redundant()) {
assert this.stats.clausesRedundant > 0;
this.stats.clausesRedundant--;
} else {
assert this.stats.clausesIrredundant > 0;
this.stats.clausesIrredundant--;
if (this.dense) { for (int i = 0; i < c.lits().size(); i++) { decOcc(c.lits().get(i)); } }
}
c.setDumped(true);
} | [
"private",
"void",
"dumpClause",
"(",
"final",
"CLClause",
"c",
")",
"{",
"if",
"(",
"c",
".",
"dumped",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"c",
".",
"redundant",
"(",
")",
")",
"{",
"assert",
"this",
".",
"stats",
".",
"clausesRe... | Dumps a given clause.
@param c the clause | [
"Dumps",
"a",
"given",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L659-L670 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.bumpClause | private void bumpClause(final CLClause c) {
switch (this.config.cbump) {
case INC:
c.setActivity(c.activity() + 1);
break;
case LRU:
c.setActivity(this.stats.conflicts);
break;
case AVG:
c.setActivity((this.stats.conflicts + c.activity()) / 2);
break;
case NONE:
default:
assert this.config.cbump == CleaneLingConfig.ClauseBumping.NONE;
break;
}
} | java | private void bumpClause(final CLClause c) {
switch (this.config.cbump) {
case INC:
c.setActivity(c.activity() + 1);
break;
case LRU:
c.setActivity(this.stats.conflicts);
break;
case AVG:
c.setActivity((this.stats.conflicts + c.activity()) / 2);
break;
case NONE:
default:
assert this.config.cbump == CleaneLingConfig.ClauseBumping.NONE;
break;
}
} | [
"private",
"void",
"bumpClause",
"(",
"final",
"CLClause",
"c",
")",
"{",
"switch",
"(",
"this",
".",
"config",
".",
"cbump",
")",
"{",
"case",
"INC",
":",
"c",
".",
"setActivity",
"(",
"c",
".",
"activity",
"(",
")",
"+",
"1",
")",
";",
"break",
... | Bumps a clause and increments it's activity.
@param c the clause | [
"Bumps",
"a",
"clause",
"and",
"increments",
"it",
"s",
"activity",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L684-L700 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.reduce | private void reduce() {
this.stats.reductions++;
final LNGVector<CLClause> candidates = new LNGVector<>();
for (final CLClause c : this.clauses) { if (c.redundant() && !c.important() && !c.forcing()) { candidates.push(c); } }
final int keep = candidates.size() / 2;
candidates.sort(CLClause.comp);
for (int i = keep; i < candidates.size(); i++) { candidates.get(i).setRemove(true); }
for (int idx = 1; idx <= maxvar(); idx++) {
for (int sign = -1; sign <= 1; sign += 2) {
final LNGVector<CLWatch> ws = watches(sign * idx);
final LNGVector<CLWatch> newWs = new LNGVector<>(ws.size());
for (final CLWatch w : ws) { if (!w.clause().remove()) { newWs.push(w); } }
ws.replaceInplace(newWs);
}
}
int j = 0;
int i;
for (i = 0; i < this.clauses.size(); i++) {
final CLClause c = this.clauses.get(i);
if (i == this.distilled) { this.distilled = j; }
if (!c.remove()) { this.clauses.set(j++, c); }
}
if (i == this.distilled) { this.distilled = j; }
this.clauses.shrinkTo(j);
long reduced = 0;
for (int k = keep; k < candidates.size(); k++) {
deleteClause(candidates.get(k));
reduced++;
}
this.stats.clausesReduced += reduced;
candidates.release();
this.limits.reduceRedundant += this.config.redinc;
} | java | private void reduce() {
this.stats.reductions++;
final LNGVector<CLClause> candidates = new LNGVector<>();
for (final CLClause c : this.clauses) { if (c.redundant() && !c.important() && !c.forcing()) { candidates.push(c); } }
final int keep = candidates.size() / 2;
candidates.sort(CLClause.comp);
for (int i = keep; i < candidates.size(); i++) { candidates.get(i).setRemove(true); }
for (int idx = 1; idx <= maxvar(); idx++) {
for (int sign = -1; sign <= 1; sign += 2) {
final LNGVector<CLWatch> ws = watches(sign * idx);
final LNGVector<CLWatch> newWs = new LNGVector<>(ws.size());
for (final CLWatch w : ws) { if (!w.clause().remove()) { newWs.push(w); } }
ws.replaceInplace(newWs);
}
}
int j = 0;
int i;
for (i = 0; i < this.clauses.size(); i++) {
final CLClause c = this.clauses.get(i);
if (i == this.distilled) { this.distilled = j; }
if (!c.remove()) { this.clauses.set(j++, c); }
}
if (i == this.distilled) { this.distilled = j; }
this.clauses.shrinkTo(j);
long reduced = 0;
for (int k = keep; k < candidates.size(); k++) {
deleteClause(candidates.get(k));
reduced++;
}
this.stats.clausesReduced += reduced;
candidates.release();
this.limits.reduceRedundant += this.config.redinc;
} | [
"private",
"void",
"reduce",
"(",
")",
"{",
"this",
".",
"stats",
".",
"reductions",
"++",
";",
"final",
"LNGVector",
"<",
"CLClause",
">",
"candidates",
"=",
"new",
"LNGVector",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"CLClause",
"c",
":",
"this",
... | Reduces the number of redundant clauses. | [
"Reduces",
"the",
"number",
"of",
"redundant",
"clauses",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L717-L749 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.remainingVars | private int remainingVars() {
int res = maxvar();
res -= this.stats.varsFixed;
res -= this.stats.varsEquivalent;
res -= this.stats.varsEliminated;
return res;
} | java | private int remainingVars() {
int res = maxvar();
res -= this.stats.varsFixed;
res -= this.stats.varsEquivalent;
res -= this.stats.varsEliminated;
return res;
} | [
"private",
"int",
"remainingVars",
"(",
")",
"{",
"int",
"res",
"=",
"maxvar",
"(",
")",
";",
"res",
"-=",
"this",
".",
"stats",
".",
"varsFixed",
";",
"res",
"-=",
"this",
".",
"stats",
".",
"varsEquivalent",
";",
"res",
"-=",
"this",
".",
"stats",
... | Returns the number of remaining variables without fixed and eliminated.
@return the number of remaining variables | [
"Returns",
"the",
"number",
"of",
"remaining",
"variables",
"without",
"fixed",
"and",
"eliminated",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L755-L761 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.strengthen | private void strengthen(final CLClause c, final int remove) {
if (c.dumped() || satisfied(c)) { return; }
assert this.addedlits.empty();
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit != remove && val(lit) == 0) { this.addedlits.push(lit); }
}
newPushConnectClause();
this.addedlits.clear();
dumpClause(c);
} | java | private void strengthen(final CLClause c, final int remove) {
if (c.dumped() || satisfied(c)) { return; }
assert this.addedlits.empty();
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit != remove && val(lit) == 0) { this.addedlits.push(lit); }
}
newPushConnectClause();
this.addedlits.clear();
dumpClause(c);
} | [
"private",
"void",
"strengthen",
"(",
"final",
"CLClause",
"c",
",",
"final",
"int",
"remove",
")",
"{",
"if",
"(",
"c",
".",
"dumped",
"(",
")",
"||",
"satisfied",
"(",
"c",
")",
")",
"{",
"return",
";",
"}",
"assert",
"this",
".",
"addedlits",
".... | Removes a literal in a clause.
@param c the clause
@param remove the literal to remove | [
"Removes",
"a",
"literal",
"in",
"a",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L768-L778 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.sizePenalty | private int sizePenalty() {
long numClauses = (long) this.stats.clausesIrredundant / this.config.sizepen;
int logres = 0;
while (numClauses != 0 && logres < this.config.sizemaxpen) {
numClauses >>= 1;
logres++;
}
return 1 << logres;
} | java | private int sizePenalty() {
long numClauses = (long) this.stats.clausesIrredundant / this.config.sizepen;
int logres = 0;
while (numClauses != 0 && logres < this.config.sizemaxpen) {
numClauses >>= 1;
logres++;
}
return 1 << logres;
} | [
"private",
"int",
"sizePenalty",
"(",
")",
"{",
"long",
"numClauses",
"=",
"(",
"long",
")",
"this",
".",
"stats",
".",
"clausesIrredundant",
"/",
"this",
".",
"config",
".",
"sizepen",
";",
"int",
"logres",
"=",
"0",
";",
"while",
"(",
"numClauses",
"... | Reduces simplification steps for large formulas.
@return the size penalty | [
"Reduces",
"simplification",
"steps",
"for",
"large",
"formulas",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L800-L808 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.backward | private void backward(final CLClause c, final int ignore) {
int minlit = 0;
int minoccs = Integer.MAX_VALUE;
int litoccs;
this.stats.steps++;
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit == ignore) { continue; }
if (val(lit) < 0) { continue; }
litoccs = occs(lit).count();
if (minlit != 0 && minoccs >= litoccs) { continue; }
minlit = lit;
minoccs = litoccs;
}
if (minoccs >= this.config.bwocclim) { return; }
assert minlit != 0;
for (int i = 0; i < c.lits().size(); i++) { mark(c.lits().get(i)); }
final CLOccs os = occs(minlit);
for (final CLClause d : os) {
if (d == c) { continue; }
int lit;
int count = this.seen.size();
int negated = 0;
this.stats.steps++;
for (int p = 0; count != 0 && p < d.lits().size(); p++) {
lit = d.lits().get(p);
final int m = marked(lit);
if (m == 0) { continue; }
assert count > 0;
count--;
if (m > 0) { continue; }
assert m < 0;
if (negated != 0) {
count = Integer.MAX_VALUE;
break;
}
negated = lit;
}
if (count != 0) { continue; }
if (negated != 0) {
this.tostrengthen.push(new Pair<>(d, negated));
this.stats.backwardStrengthened++;
} else {
this.stats.backwardSubsumed++;
dumpClause(d);
}
}
unmark();
} | java | private void backward(final CLClause c, final int ignore) {
int minlit = 0;
int minoccs = Integer.MAX_VALUE;
int litoccs;
this.stats.steps++;
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit == ignore) { continue; }
if (val(lit) < 0) { continue; }
litoccs = occs(lit).count();
if (minlit != 0 && minoccs >= litoccs) { continue; }
minlit = lit;
minoccs = litoccs;
}
if (minoccs >= this.config.bwocclim) { return; }
assert minlit != 0;
for (int i = 0; i < c.lits().size(); i++) { mark(c.lits().get(i)); }
final CLOccs os = occs(minlit);
for (final CLClause d : os) {
if (d == c) { continue; }
int lit;
int count = this.seen.size();
int negated = 0;
this.stats.steps++;
for (int p = 0; count != 0 && p < d.lits().size(); p++) {
lit = d.lits().get(p);
final int m = marked(lit);
if (m == 0) { continue; }
assert count > 0;
count--;
if (m > 0) { continue; }
assert m < 0;
if (negated != 0) {
count = Integer.MAX_VALUE;
break;
}
negated = lit;
}
if (count != 0) { continue; }
if (negated != 0) {
this.tostrengthen.push(new Pair<>(d, negated));
this.stats.backwardStrengthened++;
} else {
this.stats.backwardSubsumed++;
dumpClause(d);
}
}
unmark();
} | [
"private",
"void",
"backward",
"(",
"final",
"CLClause",
"c",
",",
"final",
"int",
"ignore",
")",
"{",
"int",
"minlit",
"=",
"0",
";",
"int",
"minoccs",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"int",
"litoccs",
";",
"this",
".",
"stats",
".",
"steps",
... | Backward subsumes from clause.
@param c the clause
@param ignore the literal to ignore | [
"Backward",
"subsumes",
"from",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L906-L954 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.backward | private void backward(final int lit) {
assert this.level == 0;
assert this.dense;
assert this.tostrengthen.empty();
final CLOccs os = occs(lit);
for (final CLClause c : os) {
assert !c.redundant();
this.stats.steps++;
if (c.dumped()) { continue; }
if (c.size() >= this.config.bwclslim) { continue; }
if (satisfied(c)) { continue; }
backward(c, lit);
}
while (!this.tostrengthen.empty()) {
final Pair<CLClause, Integer> cplp = this.tostrengthen.back();
this.tostrengthen.pop();
strengthen(cplp.first(), cplp.second());
}
} | java | private void backward(final int lit) {
assert this.level == 0;
assert this.dense;
assert this.tostrengthen.empty();
final CLOccs os = occs(lit);
for (final CLClause c : os) {
assert !c.redundant();
this.stats.steps++;
if (c.dumped()) { continue; }
if (c.size() >= this.config.bwclslim) { continue; }
if (satisfied(c)) { continue; }
backward(c, lit);
}
while (!this.tostrengthen.empty()) {
final Pair<CLClause, Integer> cplp = this.tostrengthen.back();
this.tostrengthen.pop();
strengthen(cplp.first(), cplp.second());
}
} | [
"private",
"void",
"backward",
"(",
"final",
"int",
"lit",
")",
"{",
"assert",
"this",
".",
"level",
"==",
"0",
";",
"assert",
"this",
".",
"dense",
";",
"assert",
"this",
".",
"tostrengthen",
".",
"empty",
"(",
")",
";",
"final",
"CLOccs",
"os",
"="... | Backward subsumes from clauses in the occurrence list of a given literal.
@param lit the literal | [
"Backward",
"subsumes",
"from",
"clauses",
"in",
"the",
"occurrence",
"list",
"of",
"a",
"given",
"literal",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L960-L978 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.tryElim | private boolean tryElim(final int cand) {
assert var(cand).free();
final CLOccs p = occs(cand);
final CLOccs n = occs(-cand);
long limit = (long) p.count() + n.count();
for (int i = 0; limit >= 0 && i < p.clauses().size(); i++) {
final CLClause c = p.clauses().get(i);
assert !c.redundant();
this.stats.steps++;
if (c.dumped() || satisfied(c)) { continue; }
for (int j = 0; limit >= 0 && j < n.clauses().size(); j++) {
final CLClause d = n.clauses().get(j);
assert !d.redundant();
this.stats.steps++;
if (d.dumped() || satisfied(d)) { continue; }
if (tryResolve(c, cand, d)) { limit--; }
}
}
return limit >= 0;
} | java | private boolean tryElim(final int cand) {
assert var(cand).free();
final CLOccs p = occs(cand);
final CLOccs n = occs(-cand);
long limit = (long) p.count() + n.count();
for (int i = 0; limit >= 0 && i < p.clauses().size(); i++) {
final CLClause c = p.clauses().get(i);
assert !c.redundant();
this.stats.steps++;
if (c.dumped() || satisfied(c)) { continue; }
for (int j = 0; limit >= 0 && j < n.clauses().size(); j++) {
final CLClause d = n.clauses().get(j);
assert !d.redundant();
this.stats.steps++;
if (d.dumped() || satisfied(d)) { continue; }
if (tryResolve(c, cand, d)) { limit--; }
}
}
return limit >= 0;
} | [
"private",
"boolean",
"tryElim",
"(",
"final",
"int",
"cand",
")",
"{",
"assert",
"var",
"(",
"cand",
")",
".",
"free",
"(",
")",
";",
"final",
"CLOccs",
"p",
"=",
"occs",
"(",
"cand",
")",
";",
"final",
"CLOccs",
"n",
"=",
"occs",
"(",
"-",
"can... | Tries bounded variable elimination on a candidate literal.
@param cand the literal
@return {@code true} if resolution of all positive with all negative occurrences of the candidate produces at most
as many non trivial resolvents as the number of positive plus negative occurrences, {@code false} otherwise | [
"Tries",
"bounded",
"variable",
"elimination",
"on",
"a",
"candidate",
"literal",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L986-L1005 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.doResolve | private void doResolve(final CLClause c, final int pivot, final CLClause d) {
assert !c.dumped() && !c.satisfied();
assert !d.dumped() && !d.satisfied();
assert this.addedlits.empty();
this.stats.steps++;
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit != pivot) { this.addedlits.push(lit); }
}
this.stats.steps++;
for (int i = 0; i < d.lits().size(); i++) {
final int lit = d.lits().get(i);
if (lit != -pivot) { this.addedlits.push(lit); }
}
if (!trivialClause()) { newPushConnectClause(); }
this.addedlits.clear();
} | java | private void doResolve(final CLClause c, final int pivot, final CLClause d) {
assert !c.dumped() && !c.satisfied();
assert !d.dumped() && !d.satisfied();
assert this.addedlits.empty();
this.stats.steps++;
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit != pivot) { this.addedlits.push(lit); }
}
this.stats.steps++;
for (int i = 0; i < d.lits().size(); i++) {
final int lit = d.lits().get(i);
if (lit != -pivot) { this.addedlits.push(lit); }
}
if (!trivialClause()) { newPushConnectClause(); }
this.addedlits.clear();
} | [
"private",
"void",
"doResolve",
"(",
"final",
"CLClause",
"c",
",",
"final",
"int",
"pivot",
",",
"final",
"CLClause",
"d",
")",
"{",
"assert",
"!",
"c",
".",
"dumped",
"(",
")",
"&&",
"!",
"c",
".",
"satisfied",
"(",
")",
";",
"assert",
"!",
"d",
... | Performs resolution on two given clauses and a pivot literal.
@param c the first clause
@param pivot the pivot literal
@param d the second clause | [
"Performs",
"resolution",
"on",
"two",
"given",
"clauses",
"and",
"a",
"pivot",
"literal",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1013-L1029 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.pushExtension | private void pushExtension(final CLClause c, final int blit) {
pushExtension(0);
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit != blit) { pushExtension(lit); }
}
pushExtension(blit);
} | java | private void pushExtension(final CLClause c, final int blit) {
pushExtension(0);
for (int i = 0; i < c.lits().size(); i++) {
final int lit = c.lits().get(i);
if (lit != blit) { pushExtension(lit); }
}
pushExtension(blit);
} | [
"private",
"void",
"pushExtension",
"(",
"final",
"CLClause",
"c",
",",
"final",
"int",
"blit",
")",
"{",
"pushExtension",
"(",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"c",
".",
"lits",
"(",
")",
".",
"size",
"(",
")",
"... | Pushes and logs a clause and its blocking literal to the extension.
@param c the clause
@param blit the blocking literal | [
"Pushes",
"and",
"logs",
"a",
"clause",
"and",
"its",
"blocking",
"literal",
"to",
"the",
"extension",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1044-L1051 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.doElim | private void doElim(final int cand) {
assert this.schedule;
assert var(cand).free();
final CLOccs p = occs(cand);
final CLOccs n = occs(-cand);
for (final CLClause c : p) {
this.stats.steps++;
if (c.dumped() || satisfied(c)) { continue; }
for (final CLClause d : n) {
this.stats.steps++;
if (d.dumped() || satisfied(d)) { continue; }
doResolve(c, cand, d);
}
}
final int extend;
final CLOccs e;
if (p.count() < n.count()) {
extend = cand;
e = p;
} else {
extend = -cand;
e = n;
}
for (final CLClause c : e) {
if (c.dumped() || satisfied(c)) { continue; }
this.stats.steps++;
pushExtension(c, extend);
}
pushExtension(0);
pushExtension(-extend);
while (!p.clauses().empty()) {
final CLClause c = p.clauses().back();
this.stats.steps++;
p.clauses().pop();
if (c.satisfied() || c.dumped()) { continue; }
this.stats.clausesEliminated++;
dumpClause(c);
}
p.clauses().release();
while (!n.clauses().empty()) {
final CLClause c = n.clauses().back();
this.stats.steps++;
n.clauses().pop();
if (c.satisfied() || c.dumped()) { continue; }
this.stats.clausesEliminated++;
dumpClause(c);
}
n.clauses().release();
var(cand).setState(CLVar.State.ELIMINATED);
this.stats.varsEliminated++;
final CLClause conflict = bcp();
if (conflict != null) {
analyze(conflict);
assert this.empty != null;
}
touchFixed();
} | java | private void doElim(final int cand) {
assert this.schedule;
assert var(cand).free();
final CLOccs p = occs(cand);
final CLOccs n = occs(-cand);
for (final CLClause c : p) {
this.stats.steps++;
if (c.dumped() || satisfied(c)) { continue; }
for (final CLClause d : n) {
this.stats.steps++;
if (d.dumped() || satisfied(d)) { continue; }
doResolve(c, cand, d);
}
}
final int extend;
final CLOccs e;
if (p.count() < n.count()) {
extend = cand;
e = p;
} else {
extend = -cand;
e = n;
}
for (final CLClause c : e) {
if (c.dumped() || satisfied(c)) { continue; }
this.stats.steps++;
pushExtension(c, extend);
}
pushExtension(0);
pushExtension(-extend);
while (!p.clauses().empty()) {
final CLClause c = p.clauses().back();
this.stats.steps++;
p.clauses().pop();
if (c.satisfied() || c.dumped()) { continue; }
this.stats.clausesEliminated++;
dumpClause(c);
}
p.clauses().release();
while (!n.clauses().empty()) {
final CLClause c = n.clauses().back();
this.stats.steps++;
n.clauses().pop();
if (c.satisfied() || c.dumped()) { continue; }
this.stats.clausesEliminated++;
dumpClause(c);
}
n.clauses().release();
var(cand).setState(CLVar.State.ELIMINATED);
this.stats.varsEliminated++;
final CLClause conflict = bcp();
if (conflict != null) {
analyze(conflict);
assert this.empty != null;
}
touchFixed();
} | [
"private",
"void",
"doElim",
"(",
"final",
"int",
"cand",
")",
"{",
"assert",
"this",
".",
"schedule",
";",
"assert",
"var",
"(",
"cand",
")",
".",
"free",
"(",
")",
";",
"final",
"CLOccs",
"p",
"=",
"occs",
"(",
"cand",
")",
";",
"final",
"CLOccs"... | Performs blocking variable elimination on a candidate.
@param cand the candidate literal | [
"Performs",
"blocking",
"variable",
"elimination",
"on",
"a",
"candidate",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1057-L1113 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.dumpEliminatedRedundant | private void dumpEliminatedRedundant() {
for (final CLClause c : this.clauses) {
if (!c.redundant() || c.satisfied() || c.dumped()) { continue; }
if (containsEliminated(c)) { dumpClause(c); }
}
} | java | private void dumpEliminatedRedundant() {
for (final CLClause c : this.clauses) {
if (!c.redundant() || c.satisfied() || c.dumped()) { continue; }
if (containsEliminated(c)) { dumpClause(c); }
}
} | [
"private",
"void",
"dumpEliminatedRedundant",
"(",
")",
"{",
"for",
"(",
"final",
"CLClause",
"c",
":",
"this",
".",
"clauses",
")",
"{",
"if",
"(",
"!",
"c",
".",
"redundant",
"(",
")",
"||",
"c",
".",
"satisfied",
"(",
")",
"||",
"c",
".",
"dumpe... | Dumps redundant clauses with eliminated variables. | [
"Dumps",
"redundant",
"clauses",
"with",
"eliminated",
"variables",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1128-L1133 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.updateCands | private void updateCands() {
if (!this.dense) { connectOccs(); }
assert !this.schedule;
this.schedule = true;
if (this.schedule = currentCands().empty()) { for (int idx = 1; idx <= maxvar(); idx++) { touch(idx); } }
this.schedule = true;
touchFixed();
} | java | private void updateCands() {
if (!this.dense) { connectOccs(); }
assert !this.schedule;
this.schedule = true;
if (this.schedule = currentCands().empty()) { for (int idx = 1; idx <= maxvar(); idx++) { touch(idx); } }
this.schedule = true;
touchFixed();
} | [
"private",
"void",
"updateCands",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"dense",
")",
"{",
"connectOccs",
"(",
")",
";",
"}",
"assert",
"!",
"this",
".",
"schedule",
";",
"this",
".",
"schedule",
"=",
"true",
";",
"if",
"(",
"this",
".",
"s... | Updates the candidates priority queue for new rounds of simplification. | [
"Updates",
"the",
"candidates",
"priority",
"queue",
"for",
"new",
"rounds",
"of",
"simplification",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1138-L1145 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.blockLit | private void blockLit(final int blit) {
final CLOccs os = occs(blit);
for (final CLClause c : os) {
assert !c.redundant();
if (!blockClause(c, blit)) { continue; }
this.stats.clausesBlocked++;
pushExtension(c, blit);
dumpClause(c);
}
} | java | private void blockLit(final int blit) {
final CLOccs os = occs(blit);
for (final CLClause c : os) {
assert !c.redundant();
if (!blockClause(c, blit)) { continue; }
this.stats.clausesBlocked++;
pushExtension(c, blit);
dumpClause(c);
}
} | [
"private",
"void",
"blockLit",
"(",
"final",
"int",
"blit",
")",
"{",
"final",
"CLOccs",
"os",
"=",
"occs",
"(",
"blit",
")",
";",
"for",
"(",
"final",
"CLClause",
"c",
":",
"os",
")",
"{",
"assert",
"!",
"c",
".",
"redundant",
"(",
")",
";",
"if... | Finds and removes all blocked clauses blocked on a given blocking literal.
@param blit the blocking literal | [
"Finds",
"and",
"removes",
"all",
"blocked",
"clauses",
"blocked",
"on",
"a",
"given",
"blocking",
"literal",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1225-L1234 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.block | private void block() {
final long steps = this.limits.simpSteps;
assert this.level == 0;
assert !this.config.plain;
if (!this.config.block) { return; }
if (this.config.blkwait >= this.stats.simplifications) { return; }
assert this.simplifier == Simplifier.TOPSIMP;
this.simplifier = Simplifier.BLOCK;
updateCands();
final long limit;
if (this.stats.simplifications <= this.config.blkrtc) { limit = Long.MAX_VALUE; } else { limit = this.stats.steps + 10 * steps / sizePenalty(); }
while (this.empty == null && !this.candsBlock.empty() && this.stats.steps++ < limit) {
final int cand = this.candsBlock.top();
final long priority = this.candsBlock.priority(cand);
this.candsBlock.pop(cand);
if (priority == 0 || !var(cand).free()) { continue; }
blockLit(cand);
blockLit(-cand);
}
assert this.schedule;
this.schedule = false;
assert this.simplifier == Simplifier.BLOCK;
this.simplifier = Simplifier.TOPSIMP;
} | java | private void block() {
final long steps = this.limits.simpSteps;
assert this.level == 0;
assert !this.config.plain;
if (!this.config.block) { return; }
if (this.config.blkwait >= this.stats.simplifications) { return; }
assert this.simplifier == Simplifier.TOPSIMP;
this.simplifier = Simplifier.BLOCK;
updateCands();
final long limit;
if (this.stats.simplifications <= this.config.blkrtc) { limit = Long.MAX_VALUE; } else { limit = this.stats.steps + 10 * steps / sizePenalty(); }
while (this.empty == null && !this.candsBlock.empty() && this.stats.steps++ < limit) {
final int cand = this.candsBlock.top();
final long priority = this.candsBlock.priority(cand);
this.candsBlock.pop(cand);
if (priority == 0 || !var(cand).free()) { continue; }
blockLit(cand);
blockLit(-cand);
}
assert this.schedule;
this.schedule = false;
assert this.simplifier == Simplifier.BLOCK;
this.simplifier = Simplifier.TOPSIMP;
} | [
"private",
"void",
"block",
"(",
")",
"{",
"final",
"long",
"steps",
"=",
"this",
".",
"limits",
".",
"simpSteps",
";",
"assert",
"this",
".",
"level",
"==",
"0",
";",
"assert",
"!",
"this",
".",
"config",
".",
"plain",
";",
"if",
"(",
"!",
"this",... | Blocked Clause Elimination. | [
"Blocked",
"Clause",
"Elimination",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1239-L1262 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.disconnectClauses | private void disconnectClauses() {
this.limits.reduceImportant = 0;
for (int idx = 1; idx <= maxvar(); idx++) {
for (int sign = -1; sign <= 1; sign += 2) {
final int lit = sign * idx;
watches(lit).release();
occs(lit).release();
}
}
this.dense = false;
} | java | private void disconnectClauses() {
this.limits.reduceImportant = 0;
for (int idx = 1; idx <= maxvar(); idx++) {
for (int sign = -1; sign <= 1; sign += 2) {
final int lit = sign * idx;
watches(lit).release();
occs(lit).release();
}
}
this.dense = false;
} | [
"private",
"void",
"disconnectClauses",
"(",
")",
"{",
"this",
".",
"limits",
".",
"reduceImportant",
"=",
"0",
";",
"for",
"(",
"int",
"idx",
"=",
"1",
";",
"idx",
"<=",
"maxvar",
"(",
")",
";",
"idx",
"++",
")",
"{",
"for",
"(",
"int",
"sign",
... | Disconnects all clauses. | [
"Disconnects",
"all",
"clauses",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1267-L1277 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.reduceClause | private CLClause reduceClause(final CLClause c) {
int lit;
int i;
for (i = 0; i < c.lits().size(); i++) {
lit = c.lits().get(i);
if (val(lit) < 0) { break; }
}
if (i == c.lits().size()) { return c; }
assert this.addedlits.empty();
for (i = 0; i < c.lits().size(); i++) {
lit = c.lits().get(i);
if (val(lit) >= 0) { this.addedlits.push(lit); }
}
final boolean redundant = c.redundant();
final int glue = c.glue();
deleteClause(c);
final CLClause res = newClause(redundant, glue);
this.addedlits.clear();
return res;
} | java | private CLClause reduceClause(final CLClause c) {
int lit;
int i;
for (i = 0; i < c.lits().size(); i++) {
lit = c.lits().get(i);
if (val(lit) < 0) { break; }
}
if (i == c.lits().size()) { return c; }
assert this.addedlits.empty();
for (i = 0; i < c.lits().size(); i++) {
lit = c.lits().get(i);
if (val(lit) >= 0) { this.addedlits.push(lit); }
}
final boolean redundant = c.redundant();
final int glue = c.glue();
deleteClause(c);
final CLClause res = newClause(redundant, glue);
this.addedlits.clear();
return res;
} | [
"private",
"CLClause",
"reduceClause",
"(",
"final",
"CLClause",
"c",
")",
"{",
"int",
"lit",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"c",
".",
"lits",
"(",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"lit",
... | Removes false literals from a given clause.
@param c the clause
@return the new clause | [
"Removes",
"false",
"literals",
"from",
"a",
"given",
"clause",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1284-L1303 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.simplify | private Tristate simplify() {
assert this.simplifier == Simplifier.NOSIMP;
this.simplifier = Simplifier.TOPSIMP;
this.stats.simplifications++;
backtrack();
final int varsBefore = remainingVars();
if (!this.config.plain) {
if (this.empty == null) { distill(); }
if (this.empty == null) { block(); }
if (this.empty == null) { elim(); }
}
collect();
assert this.simplifier == Simplifier.TOPSIMP;
this.simplifier = Simplifier.NOSIMP;
final int varsAfter = remainingVars();
assert varsBefore >= varsAfter;
this.limits.simpRemovedVars = varsBefore - varsAfter;
return this.empty != null ? FALSE : UNDEF;
} | java | private Tristate simplify() {
assert this.simplifier == Simplifier.NOSIMP;
this.simplifier = Simplifier.TOPSIMP;
this.stats.simplifications++;
backtrack();
final int varsBefore = remainingVars();
if (!this.config.plain) {
if (this.empty == null) { distill(); }
if (this.empty == null) { block(); }
if (this.empty == null) { elim(); }
}
collect();
assert this.simplifier == Simplifier.TOPSIMP;
this.simplifier = Simplifier.NOSIMP;
final int varsAfter = remainingVars();
assert varsBefore >= varsAfter;
this.limits.simpRemovedVars = varsBefore - varsAfter;
return this.empty != null ? FALSE : UNDEF;
} | [
"private",
"Tristate",
"simplify",
"(",
")",
"{",
"assert",
"this",
".",
"simplifier",
"==",
"Simplifier",
".",
"NOSIMP",
";",
"this",
".",
"simplifier",
"=",
"Simplifier",
".",
"TOPSIMP",
";",
"this",
".",
"stats",
".",
"simplifications",
"++",
";",
"back... | Performs bounded inprocessing.
@return the status after simplification | [
"Performs",
"bounded",
"inprocessing",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1347-L1365 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java | CleaneLingSolver.extend | private void extend() {
while (!this.extension.empty()) {
final int lit = this.extension.back();
int other;
boolean satisfied = false;
while ((other = this.extension.back()) != 0) {
this.extension.pop();
if (val(other) == VALUE_TRUE) { satisfied = true; }
}
this.extension.pop();
if (!satisfied) { this.vals.set(Math.abs(lit), sign(lit)); }
}
} | java | private void extend() {
while (!this.extension.empty()) {
final int lit = this.extension.back();
int other;
boolean satisfied = false;
while ((other = this.extension.back()) != 0) {
this.extension.pop();
if (val(other) == VALUE_TRUE) { satisfied = true; }
}
this.extension.pop();
if (!satisfied) { this.vals.set(Math.abs(lit), sign(lit)); }
}
} | [
"private",
"void",
"extend",
"(",
")",
"{",
"while",
"(",
"!",
"this",
".",
"extension",
".",
"empty",
"(",
")",
")",
"{",
"final",
"int",
"lit",
"=",
"this",
".",
"extension",
".",
"back",
"(",
")",
";",
"int",
"other",
";",
"boolean",
"satisfied"... | Extends a partial to a full assignment. | [
"Extends",
"a",
"partial",
"to",
"a",
"full",
"assignment",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingSolver.java#L1370-L1382 | train |
logic-ng/LogicNG | src/main/java/org/logicng/graphs/algorithms/ConnectedComponentsComputation.java | ConnectedComponentsComputation.compute | public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());
while (!unmarkedNodes.isEmpty()) {
Set<Node<T>> connectedComp = new LinkedHashSet<>();
deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
connectedComponents.add(connectedComp);
}
return connectedComponents;
} | java | public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());
while (!unmarkedNodes.isEmpty()) {
Set<Node<T>> connectedComp = new LinkedHashSet<>();
deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
connectedComponents.add(connectedComp);
}
return connectedComponents;
} | [
"public",
"static",
"<",
"T",
">",
"Set",
"<",
"Set",
"<",
"Node",
"<",
"T",
">",
">",
">",
"compute",
"(",
"final",
"Graph",
"<",
"T",
">",
"graph",
")",
"{",
"final",
"Set",
"<",
"Set",
"<",
"Node",
"<",
"T",
">",
">",
">",
"connectedComponen... | Computes the set of connected components of a graph, where each component is represented by a set of nodes.
@param graph the graph
@param <T> the type of the graph content
@return the set of sets of nodes representing the connected components | [
"Computes",
"the",
"set",
"of",
"connected",
"components",
"of",
"a",
"graph",
"where",
"each",
"component",
"is",
"represented",
"by",
"a",
"set",
"of",
"nodes",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/graphs/algorithms/ConnectedComponentsComputation.java#L50-L61 | train |
logic-ng/LogicNG | src/main/java/org/logicng/bdds/jbuddy/BDDCache.java | BDDCache.resize | private void resize(final int ns) {
final int size = BDDPrime.primeGTE(ns);
this.table = new BDDCacheEntry[size];
for (int n = 0; n < size; n++)
this.table[n] = new BDDCacheEntry();
} | java | private void resize(final int ns) {
final int size = BDDPrime.primeGTE(ns);
this.table = new BDDCacheEntry[size];
for (int n = 0; n < size; n++)
this.table[n] = new BDDCacheEntry();
} | [
"private",
"void",
"resize",
"(",
"final",
"int",
"ns",
")",
"{",
"final",
"int",
"size",
"=",
"BDDPrime",
".",
"primeGTE",
"(",
"ns",
")",
";",
"this",
".",
"table",
"=",
"new",
"BDDCacheEntry",
"[",
"size",
"]",
";",
"for",
"(",
"int",
"n",
"=",
... | Resizes the cache to a new number of entries. The old cache entries are removed in this process.
@param ns the new number of entries | [
"Resizes",
"the",
"cache",
"to",
"a",
"new",
"number",
"of",
"entries",
".",
"The",
"old",
"cache",
"entries",
"are",
"removed",
"in",
"this",
"process",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/jbuddy/BDDCache.java#L80-L85 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.searchSATSolver | public static Tristate searchSATSolver(final MiniSatStyleSolver s, final SATHandler handler, final LNGIntVector assumptions) {
return s.solve(handler, assumptions);
} | java | public static Tristate searchSATSolver(final MiniSatStyleSolver s, final SATHandler handler, final LNGIntVector assumptions) {
return s.solve(handler, assumptions);
} | [
"public",
"static",
"Tristate",
"searchSATSolver",
"(",
"final",
"MiniSatStyleSolver",
"s",
",",
"final",
"SATHandler",
"handler",
",",
"final",
"LNGIntVector",
"assumptions",
")",
"{",
"return",
"s",
".",
"solve",
"(",
"handler",
",",
"assumptions",
")",
";",
... | Solves the formula that is currently loaded in the SAT solver with a set of assumptions.
@param s the SAT solver
@param handler a SAT handler
@param assumptions the assumptions
@return the result of the solving process | [
"Solves",
"the",
"formula",
"that",
"is",
"currently",
"loaded",
"in",
"the",
"SAT",
"solver",
"with",
"a",
"set",
"of",
"assumptions",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L164-L166 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.search | public final MaxSATResult search(final MaxSATHandler handler) {
this.handler = handler;
if (handler != null)
handler.startedSolving();
final MaxSATResult result = search();
if (handler != null)
handler.finishedSolving();
this.handler = null;
return result;
} | java | public final MaxSATResult search(final MaxSATHandler handler) {
this.handler = handler;
if (handler != null)
handler.startedSolving();
final MaxSATResult result = search();
if (handler != null)
handler.finishedSolving();
this.handler = null;
return result;
} | [
"public",
"final",
"MaxSATResult",
"search",
"(",
"final",
"MaxSATHandler",
"handler",
")",
"{",
"this",
".",
"handler",
"=",
"handler",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"handler",
".",
"startedSolving",
"(",
")",
";",
"final",
"MaxSATResult",
... | The main MaxSAT solving method.
@param handler a MaxSAT handler
@return the result of the solving process
@throws IllegalArgumentException if the configuration was not valid | [
"The",
"main",
"MaxSAT",
"solving",
"method",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L184-L193 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.addSoftClause | public void addSoftClause(int weight, final LNGIntVector lits) {
final LNGIntVector rVars = new LNGIntVector();
this.softClauses.push(new MSSoftClause(lits, weight, LIT_UNDEF, rVars));
this.nbSoft++;
} | java | public void addSoftClause(int weight, final LNGIntVector lits) {
final LNGIntVector rVars = new LNGIntVector();
this.softClauses.push(new MSSoftClause(lits, weight, LIT_UNDEF, rVars));
this.nbSoft++;
} | [
"public",
"void",
"addSoftClause",
"(",
"int",
"weight",
",",
"final",
"LNGIntVector",
"lits",
")",
"{",
"final",
"LNGIntVector",
"rVars",
"=",
"new",
"LNGIntVector",
"(",
")",
";",
"this",
".",
"softClauses",
".",
"push",
"(",
"new",
"MSSoftClause",
"(",
... | Adds a new soft clause to the soft clause database.
@param weight the weight of the soft clause
@param lits the literals of the soft clause | [
"Adds",
"a",
"new",
"soft",
"clause",
"to",
"the",
"soft",
"clause",
"database",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L247-L251 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.newSATSolver | public MiniSatStyleSolver newSATSolver() {
switch (this.solverType) {
case GLUCOSE:
return new GlucoseSyrup(new MiniSatConfig.Builder().incremental(true).build(),
new GlucoseConfig.Builder().build());
case MINISAT:
return new MiniSat2Solver(new MiniSatConfig.Builder().incremental(false).build());
default:
throw new IllegalStateException("Unknown solver type: " + this.solverType);
}
} | java | public MiniSatStyleSolver newSATSolver() {
switch (this.solverType) {
case GLUCOSE:
return new GlucoseSyrup(new MiniSatConfig.Builder().incremental(true).build(),
new GlucoseConfig.Builder().build());
case MINISAT:
return new MiniSat2Solver(new MiniSatConfig.Builder().incremental(false).build());
default:
throw new IllegalStateException("Unknown solver type: " + this.solverType);
}
} | [
"public",
"MiniSatStyleSolver",
"newSATSolver",
"(",
")",
"{",
"switch",
"(",
"this",
".",
"solverType",
")",
"{",
"case",
"GLUCOSE",
":",
"return",
"new",
"GlucoseSyrup",
"(",
"new",
"MiniSatConfig",
".",
"Builder",
"(",
")",
".",
"incremental",
"(",
"true"... | Creates an empty SAT Solver.
@return the empty SAT solver | [
"Creates",
"an",
"empty",
"SAT",
"Solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L313-L323 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.saveModel | public void saveModel(final LNGBooleanVector currentModel) {
assert nbInitialVariables != 0;
assert currentModel.size() != 0;
this.model.clear();
for (int i = 0; i < nbInitialVariables; i++)
this.model.push(currentModel.get(i));
} | java | public void saveModel(final LNGBooleanVector currentModel) {
assert nbInitialVariables != 0;
assert currentModel.size() != 0;
this.model.clear();
for (int i = 0; i < nbInitialVariables; i++)
this.model.push(currentModel.get(i));
} | [
"public",
"void",
"saveModel",
"(",
"final",
"LNGBooleanVector",
"currentModel",
")",
"{",
"assert",
"nbInitialVariables",
"!=",
"0",
";",
"assert",
"currentModel",
".",
"size",
"(",
")",
"!=",
"0",
";",
"this",
".",
"model",
".",
"clear",
"(",
")",
";",
... | Saves the current model found by the SAT solver.
@param currentModel the model found by the solver | [
"Saves",
"the",
"current",
"model",
"found",
"by",
"the",
"SAT",
"solver",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L329-L335 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.computeCostModel | public int computeCostModel(final LNGBooleanVector currentModel, int weight) {
assert currentModel.size() != 0;
int currentCost = 0;
for (int i = 0; i < nSoft(); i++) {
boolean unsatisfied = true;
for (int j = 0; j < softClauses.get(i).clause().size(); j++) {
if (weight != Integer.MAX_VALUE && softClauses.get(i).weight() != weight) {
unsatisfied = false;
continue;
}
assert var(softClauses.get(i).clause().get(j)) < currentModel.size();
if ((sign(softClauses.get(i).clause().get(j)) && !currentModel.get(var(softClauses.get(i).clause().get(j))))
|| (!sign(softClauses.get(i).clause().get(j)) && currentModel.get(var(softClauses.get(i).clause().get(j))))) {
unsatisfied = false;
break;
}
}
if (unsatisfied)
currentCost += softClauses.get(i).weight();
}
return currentCost;
} | java | public int computeCostModel(final LNGBooleanVector currentModel, int weight) {
assert currentModel.size() != 0;
int currentCost = 0;
for (int i = 0; i < nSoft(); i++) {
boolean unsatisfied = true;
for (int j = 0; j < softClauses.get(i).clause().size(); j++) {
if (weight != Integer.MAX_VALUE && softClauses.get(i).weight() != weight) {
unsatisfied = false;
continue;
}
assert var(softClauses.get(i).clause().get(j)) < currentModel.size();
if ((sign(softClauses.get(i).clause().get(j)) && !currentModel.get(var(softClauses.get(i).clause().get(j))))
|| (!sign(softClauses.get(i).clause().get(j)) && currentModel.get(var(softClauses.get(i).clause().get(j))))) {
unsatisfied = false;
break;
}
}
if (unsatisfied)
currentCost += softClauses.get(i).weight();
}
return currentCost;
} | [
"public",
"int",
"computeCostModel",
"(",
"final",
"LNGBooleanVector",
"currentModel",
",",
"int",
"weight",
")",
"{",
"assert",
"currentModel",
".",
"size",
"(",
")",
"!=",
"0",
";",
"int",
"currentCost",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",... | Computes the cost of a given model. The cost of a model is the sum of the weights of the unsatisfied soft
clauses. If a weight is specified, then it only considers the sum of the weights of the unsatisfied soft clauses
with the specified weight.
@param currentModel the model
@param weight the weight
@return the cost of the given model | [
"Computes",
"the",
"cost",
"of",
"a",
"given",
"model",
".",
"The",
"cost",
"of",
"a",
"model",
"is",
"the",
"sum",
"of",
"the",
"weights",
"of",
"the",
"unsatisfied",
"soft",
"clauses",
".",
"If",
"a",
"weight",
"is",
"specified",
"then",
"it",
"only"... | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L345-L366 | train |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java | MaxSAT.isBMO | public boolean isBMO(boolean cache) {
assert orderWeights.size() == 0;
boolean bmo = true;
final SortedSet<Integer> partitionWeights = new TreeSet<>();
final SortedMap<Integer, Integer> nbPartitionWeights = new TreeMap<>();
for (int i = 0; i < nSoft(); i++) {
final int weight = softClauses.get(i).weight();
partitionWeights.add(weight);
final Integer foundNB = nbPartitionWeights.get(weight);
if (foundNB == null)
nbPartitionWeights.put(weight, 1);
else
nbPartitionWeights.put(weight, foundNB + 1);
}
for (final int i : partitionWeights)
orderWeights.push(i);
orderWeights.sortReverse();
long totalWeights = 0;
for (int i = 0; i < orderWeights.size(); i++)
totalWeights += orderWeights.get(i) * nbPartitionWeights.get(orderWeights.get(i));
for (int i = 0; i < orderWeights.size(); i++) {
totalWeights -= orderWeights.get(i) * nbPartitionWeights.get(orderWeights.get(i));
if (orderWeights.get(i) < totalWeights) {
bmo = false;
break;
}
}
if (!cache)
orderWeights.clear();
return bmo;
} | java | public boolean isBMO(boolean cache) {
assert orderWeights.size() == 0;
boolean bmo = true;
final SortedSet<Integer> partitionWeights = new TreeSet<>();
final SortedMap<Integer, Integer> nbPartitionWeights = new TreeMap<>();
for (int i = 0; i < nSoft(); i++) {
final int weight = softClauses.get(i).weight();
partitionWeights.add(weight);
final Integer foundNB = nbPartitionWeights.get(weight);
if (foundNB == null)
nbPartitionWeights.put(weight, 1);
else
nbPartitionWeights.put(weight, foundNB + 1);
}
for (final int i : partitionWeights)
orderWeights.push(i);
orderWeights.sortReverse();
long totalWeights = 0;
for (int i = 0; i < orderWeights.size(); i++)
totalWeights += orderWeights.get(i) * nbPartitionWeights.get(orderWeights.get(i));
for (int i = 0; i < orderWeights.size(); i++) {
totalWeights -= orderWeights.get(i) * nbPartitionWeights.get(orderWeights.get(i));
if (orderWeights.get(i) < totalWeights) {
bmo = false;
break;
}
}
if (!cache)
orderWeights.clear();
return bmo;
} | [
"public",
"boolean",
"isBMO",
"(",
"boolean",
"cache",
")",
"{",
"assert",
"orderWeights",
".",
"size",
"(",
")",
"==",
"0",
";",
"boolean",
"bmo",
"=",
"true",
";",
"final",
"SortedSet",
"<",
"Integer",
">",
"partitionWeights",
"=",
"new",
"TreeSet",
"<... | Tests if the MaxSAT formula has lexicographical optimization criterion.
@param cache is indicates whether the result should be cached.
@return {@code true} if the formula has lexicographical optimization criterion | [
"Tests",
"if",
"the",
"MaxSAT",
"formula",
"has",
"lexicographical",
"optimization",
"criterion",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/algorithms/MaxSAT.java#L373-L403 | train |
logic-ng/LogicNG | src/main/java/org/logicng/formulas/printer/UTF8StringRepresentation.java | UTF8StringRepresentation.utf8Name | private static String utf8Name(final String name) {
final Matcher matcher = pattern.matcher(name);
if (!matcher.matches())
return name;
if (matcher.group(2).isEmpty())
return matcher.group(1);
return matcher.group(1) + getSubscript(matcher.group(2));
} | java | private static String utf8Name(final String name) {
final Matcher matcher = pattern.matcher(name);
if (!matcher.matches())
return name;
if (matcher.group(2).isEmpty())
return matcher.group(1);
return matcher.group(1) + getSubscript(matcher.group(2));
} | [
"private",
"static",
"String",
"utf8Name",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"name",
")",
";",
"if",
"(",
"!",
"matcher",
".",
"matches",
"(",
")",
")",
"return",
"name",
";",
... | Returns the UTF8 string for a variable name
@param name the name
@return the matching UTF8 symbol | [
"Returns",
"the",
"UTF8",
"string",
"for",
"a",
"variable",
"name"
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/printer/UTF8StringRepresentation.java#L52-L59 | train |
logic-ng/LogicNG | src/main/java/org/logicng/cardinalityconstraints/CCIncrementalData.java | CCIncrementalData.newUpperBound | public List<Formula> newUpperBound(int rhs) {
this.result.reset();
this.computeUBConstraint(this.result, rhs);
return this.result.result();
} | java | public List<Formula> newUpperBound(int rhs) {
this.result.reset();
this.computeUBConstraint(this.result, rhs);
return this.result.result();
} | [
"public",
"List",
"<",
"Formula",
">",
"newUpperBound",
"(",
"int",
"rhs",
")",
"{",
"this",
".",
"result",
".",
"reset",
"(",
")",
";",
"this",
".",
"computeUBConstraint",
"(",
"this",
".",
"result",
",",
"rhs",
")",
";",
"return",
"this",
".",
"res... | Tightens the upper bound of an at-most-k constraint and returns the resulting formula.
@param rhs the new upperBound
@return the incremental encoding of the new upper bound | [
"Tightens",
"the",
"upper",
"bound",
"of",
"an",
"at",
"-",
"most",
"-",
"k",
"constraint",
"and",
"returns",
"the",
"resulting",
"formula",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCIncrementalData.java#L150-L154 | train |
logic-ng/LogicNG | src/main/java/org/logicng/cardinalityconstraints/CCIncrementalData.java | CCIncrementalData.newLowerBound | public List<Formula> newLowerBound(int rhs) {
this.result.reset();
this.computeLBConstraint(this.result, rhs);
return this.result.result();
} | java | public List<Formula> newLowerBound(int rhs) {
this.result.reset();
this.computeLBConstraint(this.result, rhs);
return this.result.result();
} | [
"public",
"List",
"<",
"Formula",
">",
"newLowerBound",
"(",
"int",
"rhs",
")",
"{",
"this",
".",
"result",
".",
"reset",
"(",
")",
";",
"this",
".",
"computeLBConstraint",
"(",
"this",
".",
"result",
",",
"rhs",
")",
";",
"return",
"this",
".",
"res... | Tightens the lower bound of an at-least-k constraint and returns the resulting formula.
@param rhs the new upperBound
@return the incremental encoding of the new lower bound | [
"Tightens",
"the",
"lower",
"bound",
"of",
"an",
"at",
"-",
"least",
"-",
"k",
"constraint",
"and",
"returns",
"the",
"resulting",
"formula",
"."
] | bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCIncrementalData.java#L213-L217 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.