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/formulas/ExtendedFormulaFactory.java
ExtendedFormulaFactory.shrinkMap
private static <T, U> void shrinkMap(final Map<T, U> map, int newSize) { if (!(map instanceof LinkedHashMap)) throw new IllegalStateException("Cannot shrink a map which is not of type LinkedHashMap"); if (newSize > map.size()) throw new IllegalStateException("Cannot shrink a map of size " + map.size() + " to new size " + newSize); Iterator<Map.Entry<T, U>> entryIterator = map.entrySet().iterator(); int count = 0; while (count < newSize) { entryIterator.next(); count++; } while (entryIterator.hasNext()) { entryIterator.next(); entryIterator.remove(); } }
java
private static <T, U> void shrinkMap(final Map<T, U> map, int newSize) { if (!(map instanceof LinkedHashMap)) throw new IllegalStateException("Cannot shrink a map which is not of type LinkedHashMap"); if (newSize > map.size()) throw new IllegalStateException("Cannot shrink a map of size " + map.size() + " to new size " + newSize); Iterator<Map.Entry<T, U>> entryIterator = map.entrySet().iterator(); int count = 0; while (count < newSize) { entryIterator.next(); count++; } while (entryIterator.hasNext()) { entryIterator.next(); entryIterator.remove(); } }
[ "private", "static", "<", "T", ",", "U", ">", "void", "shrinkMap", "(", "final", "Map", "<", "T", ",", "U", ">", "map", ",", "int", "newSize", ")", "{", "if", "(", "!", "(", "map", "instanceof", "LinkedHashMap", ")", ")", "throw", "new", "IllegalSt...
Shrinks a given map to a given size @param map the map to be shrunk @param newSize the new size, the map shall be shrunk to
[ "Shrinks", "a", "given", "map", "to", "a", "given", "size" ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java#L60-L75
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java
ExtendedFormulaFactory.shrinkSet
private static <T> void shrinkSet(final Set<T> set, int newSize) { if (!(set instanceof LinkedHashSet)) throw new IllegalStateException("Cannot shrink a set which is not of type LinkedHashSet"); if (newSize > set.size()) throw new IllegalStateException("Cannot shrink a set of size " + set.size() + " to new size " + newSize); Iterator<T> entryIterator = set.iterator(); int count = 0; while (count < newSize) { entryIterator.next(); count++; } while (entryIterator.hasNext()) { entryIterator.next(); entryIterator.remove(); } }
java
private static <T> void shrinkSet(final Set<T> set, int newSize) { if (!(set instanceof LinkedHashSet)) throw new IllegalStateException("Cannot shrink a set which is not of type LinkedHashSet"); if (newSize > set.size()) throw new IllegalStateException("Cannot shrink a set of size " + set.size() + " to new size " + newSize); Iterator<T> entryIterator = set.iterator(); int count = 0; while (count < newSize) { entryIterator.next(); count++; } while (entryIterator.hasNext()) { entryIterator.next(); entryIterator.remove(); } }
[ "private", "static", "<", "T", ">", "void", "shrinkSet", "(", "final", "Set", "<", "T", ">", "set", ",", "int", "newSize", ")", "{", "if", "(", "!", "(", "set", "instanceof", "LinkedHashSet", ")", ")", "throw", "new", "IllegalStateException", "(", "\"C...
Shrinks a given set to a given size @param set the set to be shrunk @param newSize the new size, the set shall be shrunk to
[ "Shrinks", "a", "given", "set", "to", "a", "given", "size" ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java#L82-L97
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java
ExtendedFormulaFactory.save
public FormulaFactoryState save() { int[] state = new int[18]; state[0] = this.posLiterals.size(); state[1] = this.negLiterals.size(); state[2] = this.generatedVariables.size(); state[3] = this.nots.size(); state[4] = this.implications.size(); state[5] = this.equivalences.size(); state[6] = this.ands2.size(); state[7] = this.ands3.size(); state[8] = this.ands4.size(); state[9] = this.andsN.size(); state[10] = this.ors2.size(); state[11] = this.ors3.size(); state[12] = this.ors4.size(); state[13] = this.orsN.size(); state[14] = this.pbConstraints.size(); state[15] = this.ccCounter; state[16] = this.pbCounter; state[17] = this.cnfCounter; final int id = this.nextStateId++; validStates.push(id); return new FormulaFactoryState(id, state); }
java
public FormulaFactoryState save() { int[] state = new int[18]; state[0] = this.posLiterals.size(); state[1] = this.negLiterals.size(); state[2] = this.generatedVariables.size(); state[3] = this.nots.size(); state[4] = this.implications.size(); state[5] = this.equivalences.size(); state[6] = this.ands2.size(); state[7] = this.ands3.size(); state[8] = this.ands4.size(); state[9] = this.andsN.size(); state[10] = this.ors2.size(); state[11] = this.ors3.size(); state[12] = this.ors4.size(); state[13] = this.orsN.size(); state[14] = this.pbConstraints.size(); state[15] = this.ccCounter; state[16] = this.pbCounter; state[17] = this.cnfCounter; final int id = this.nextStateId++; validStates.push(id); return new FormulaFactoryState(id, state); }
[ "public", "FormulaFactoryState", "save", "(", ")", "{", "int", "[", "]", "state", "=", "new", "int", "[", "18", "]", ";", "state", "[", "0", "]", "=", "this", ".", "posLiterals", ".", "size", "(", ")", ";", "state", "[", "1", "]", "=", "this", ...
Saves the FormulaFactoryState to be loaded later. @return the FormulaFactoryState.
[ "Saves", "the", "FormulaFactoryState", "to", "be", "loaded", "later", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java#L125-L148
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java
ExtendedFormulaFactory.load
public void load(final FormulaFactoryState state) { int index = -1; for (int i = validStates.size() - 1; i >= 0 && index == -1; i--) if (validStates.get(i) == state.id()) index = i; if (index == -1) throw new IllegalArgumentException("The given formula factory state is not valid anymore."); this.validStates.shrinkTo(index + 1); shrinkMap(this.posLiterals, state.state()[0]); shrinkMap(this.negLiterals, state.state()[1]); shrinkSet(this.generatedVariables, state.state()[2]); shrinkMap(this.nots, state.state()[3]); shrinkMap(this.implications, state.state()[4]); shrinkMap(this.equivalences, state.state()[5]); shrinkMap(this.ands2, state.state()[6]); shrinkMap(this.ands3, state.state()[7]); shrinkMap(this.ands4, state.state()[8]); shrinkMap(this.andsN, state.state()[9]); shrinkMap(this.ors2, state.state()[10]); shrinkMap(this.ors3, state.state()[11]); shrinkMap(this.ors4, state.state()[12]); shrinkMap(this.orsN, state.state()[13]); shrinkMap(this.pbConstraints, state.state()[14]); this.ccCounter = state.state()[15]; this.pbCounter = state.state()[16]; this.cnfCounter = state.state()[17]; clearCaches(); }
java
public void load(final FormulaFactoryState state) { int index = -1; for (int i = validStates.size() - 1; i >= 0 && index == -1; i--) if (validStates.get(i) == state.id()) index = i; if (index == -1) throw new IllegalArgumentException("The given formula factory state is not valid anymore."); this.validStates.shrinkTo(index + 1); shrinkMap(this.posLiterals, state.state()[0]); shrinkMap(this.negLiterals, state.state()[1]); shrinkSet(this.generatedVariables, state.state()[2]); shrinkMap(this.nots, state.state()[3]); shrinkMap(this.implications, state.state()[4]); shrinkMap(this.equivalences, state.state()[5]); shrinkMap(this.ands2, state.state()[6]); shrinkMap(this.ands3, state.state()[7]); shrinkMap(this.ands4, state.state()[8]); shrinkMap(this.andsN, state.state()[9]); shrinkMap(this.ors2, state.state()[10]); shrinkMap(this.ors3, state.state()[11]); shrinkMap(this.ors4, state.state()[12]); shrinkMap(this.orsN, state.state()[13]); shrinkMap(this.pbConstraints, state.state()[14]); this.ccCounter = state.state()[15]; this.pbCounter = state.state()[16]; this.cnfCounter = state.state()[17]; clearCaches(); }
[ "public", "void", "load", "(", "final", "FormulaFactoryState", "state", ")", "{", "int", "index", "=", "-", "1", ";", "for", "(", "int", "i", "=", "validStates", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", "&&", "index", "==", "-", "1",...
Loads a previously saved FormulaFactoryState. All formula factory states saved after the loaded one become invalid. @param state the FormulaFactoryState to be loaded @throws IllegalArgumentException if the FormulaFactoryState to be loaded is invalid
[ "Loads", "a", "previously", "saved", "FormulaFactoryState", ".", "All", "formula", "factory", "states", "saved", "after", "the", "loaded", "one", "become", "invalid", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java#L155-L184
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java
ExtendedFormulaFactory.clearCaches
private void clearCaches() { for (Formula formula : this.posLiterals.values()) formula.clearCaches(); for (Formula formula : this.negLiterals.values()) formula.clearCaches(); for (Formula formula : this.generatedVariables) formula.clearCaches(); for (Formula formula : this.nots.values()) formula.clearCaches(); for (Formula formula : this.implications.values()) formula.clearCaches(); for (Formula formula : this.equivalences.values()) formula.clearCaches(); for (Formula formula : this.ands2.values()) formula.clearCaches(); for (Formula formula : this.ands3.values()) formula.clearCaches(); for (Formula formula : this.ands4.values()) formula.clearCaches(); for (Formula formula : this.andsN.values()) formula.clearCaches(); for (Formula formula : this.ors2.values()) formula.clearCaches(); for (Formula formula : this.ors3.values()) formula.clearCaches(); for (Formula formula : this.ors4.values()) formula.clearCaches(); for (Formula formula : this.orsN.values()) formula.clearCaches(); for (Formula formula : this.pbConstraints.values()) formula.clearCaches(); }
java
private void clearCaches() { for (Formula formula : this.posLiterals.values()) formula.clearCaches(); for (Formula formula : this.negLiterals.values()) formula.clearCaches(); for (Formula formula : this.generatedVariables) formula.clearCaches(); for (Formula formula : this.nots.values()) formula.clearCaches(); for (Formula formula : this.implications.values()) formula.clearCaches(); for (Formula formula : this.equivalences.values()) formula.clearCaches(); for (Formula formula : this.ands2.values()) formula.clearCaches(); for (Formula formula : this.ands3.values()) formula.clearCaches(); for (Formula formula : this.ands4.values()) formula.clearCaches(); for (Formula formula : this.andsN.values()) formula.clearCaches(); for (Formula formula : this.ors2.values()) formula.clearCaches(); for (Formula formula : this.ors3.values()) formula.clearCaches(); for (Formula formula : this.ors4.values()) formula.clearCaches(); for (Formula formula : this.orsN.values()) formula.clearCaches(); for (Formula formula : this.pbConstraints.values()) formula.clearCaches(); }
[ "private", "void", "clearCaches", "(", ")", "{", "for", "(", "Formula", "formula", ":", "this", ".", "posLiterals", ".", "values", "(", ")", ")", "formula", ".", "clearCaches", "(", ")", ";", "for", "(", "Formula", "formula", ":", "this", ".", "negLite...
Clears the caches of every cached Formula.
[ "Clears", "the", "caches", "of", "every", "cached", "Formula", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/ExtendedFormulaFactory.java#L189-L220
train
logic-ng/LogicNG
src/main/java/org/logicng/io/writers/FormulaDimacsFileWriter.java
FormulaDimacsFileWriter.write
public static void write(final String fileName, Formula formula, boolean writeMapping) throws IOException { File file = new File(fileName.endsWith(".cnf") ? fileName : fileName + ".cnf"); SortedMap<Variable, Long> var2id = new TreeMap<>(); long i = 1; for (Variable var : new TreeSet<>(formula.variables())) { var2id.put(var, i++); } if (!formula.holds(CNF_PREDICATE)) { throw new IllegalArgumentException("Cannot write a non-CNF formula to dimacs. Convert to CNF first."); } List<Formula> parts = new ArrayList<>(); if (formula.type().equals(FType.LITERAL)) { parts.add(formula); } else { for (Formula part : formula) { parts.add(part); } } StringBuilder sb = new StringBuilder("p cnf "); int partsSize = formula.type().equals(FType.FALSE) ? 1 : parts.size(); sb.append(var2id.size()).append(" ").append(partsSize).append(System.lineSeparator()); for (Formula part : parts) { for (Literal lit : part.literals()) { sb.append(lit.phase() ? "" : "-").append(var2id.get(lit.variable())).append(" "); } sb.append(String.format(" 0%n")); } if (formula.type().equals(FType.FALSE)) { sb.append(String.format("0%n")); } try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) { writer.append(sb); writer.flush(); } if (writeMapping) { String mappingFileName = (fileName.endsWith(".cnf") ? fileName.substring(0, fileName.length() - 4) : fileName) + ".map"; writeMapping(new File(mappingFileName), var2id); } }
java
public static void write(final String fileName, Formula formula, boolean writeMapping) throws IOException { File file = new File(fileName.endsWith(".cnf") ? fileName : fileName + ".cnf"); SortedMap<Variable, Long> var2id = new TreeMap<>(); long i = 1; for (Variable var : new TreeSet<>(formula.variables())) { var2id.put(var, i++); } if (!formula.holds(CNF_PREDICATE)) { throw new IllegalArgumentException("Cannot write a non-CNF formula to dimacs. Convert to CNF first."); } List<Formula> parts = new ArrayList<>(); if (formula.type().equals(FType.LITERAL)) { parts.add(formula); } else { for (Formula part : formula) { parts.add(part); } } StringBuilder sb = new StringBuilder("p cnf "); int partsSize = formula.type().equals(FType.FALSE) ? 1 : parts.size(); sb.append(var2id.size()).append(" ").append(partsSize).append(System.lineSeparator()); for (Formula part : parts) { for (Literal lit : part.literals()) { sb.append(lit.phase() ? "" : "-").append(var2id.get(lit.variable())).append(" "); } sb.append(String.format(" 0%n")); } if (formula.type().equals(FType.FALSE)) { sb.append(String.format("0%n")); } try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) { writer.append(sb); writer.flush(); } if (writeMapping) { String mappingFileName = (fileName.endsWith(".cnf") ? fileName.substring(0, fileName.length() - 4) : fileName) + ".map"; writeMapping(new File(mappingFileName), var2id); } }
[ "public", "static", "void", "write", "(", "final", "String", "fileName", ",", "Formula", "formula", ",", "boolean", "writeMapping", ")", "throws", "IOException", "{", "File", "file", "=", "new", "File", "(", "fileName", ".", "endsWith", "(", "\".cnf\"", ")",...
Writes a given formula's internal data structure as a dimacs file. Must only be called with a formula which is in CNF. @param fileName the file name of the dimacs file to write @param formula the formula @param writeMapping indicates whether an additional file for translating the ids to variable names shall be written @throws IOException if there was a problem writing the file @throws IllegalArgumentException if the formula was not in CNF
[ "Writes", "a", "given", "formula", "s", "internal", "data", "structure", "as", "a", "dimacs", "file", ".", "Must", "only", "be", "called", "with", "a", "formula", "which", "is", "in", "CNF", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/io/writers/FormulaDimacsFileWriter.java#L74-L113
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.contains
public boolean contains(int element) { return element >= 0 && this.imported(element) && this.pos.get(Math.abs(element)) >= 0; }
java
public boolean contains(int element) { return element >= 0 && this.imported(element) && this.pos.get(Math.abs(element)) >= 0; }
[ "public", "boolean", "contains", "(", "int", "element", ")", "{", "return", "element", ">=", "0", "&&", "this", ".", "imported", "(", "element", ")", "&&", "this", ".", "pos", ".", "get", "(", "Math", ".", "abs", "(", "element", ")", ")", ">=", "0"...
Returns whether a given element is already imported and present in the queue or not. @param element the element @return {@code true} if the element is already imported and present in the queue, {@code false otherwise}.
[ "Returns", "whether", "a", "given", "element", "is", "already", "imported", "and", "present", "in", "the", "queue", "or", "not", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L124-L126
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.push
public void push(int element) { if (element < 0) throw new IllegalArgumentException("Cannot add negative integers to the priority queue"); assert !this.contains(element); this.doImport(element); this.pos.set(element, this.heap.size()); this.heap.push(element); assert this.heap.get(this.pos.get(element)) == element; this.up(element); }
java
public void push(int element) { if (element < 0) throw new IllegalArgumentException("Cannot add negative integers to the priority queue"); assert !this.contains(element); this.doImport(element); this.pos.set(element, this.heap.size()); this.heap.push(element); assert this.heap.get(this.pos.get(element)) == element; this.up(element); }
[ "public", "void", "push", "(", "int", "element", ")", "{", "if", "(", "element", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"Cannot add negative integers to the priority queue\"", ")", ";", "assert", "!", "this", ".", "contains", "(", "ele...
Pushes a new positive element to the queue. @param element the element @throws IllegalArgumentException if the element to add is negative
[ "Pushes", "a", "new", "positive", "element", "to", "the", "queue", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L151-L160
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.update
public void update(int element, double priority) { this.doImport(element); final double q = this.prior.get(element); if (Double.compare(q, priority) == 0) return; this.prior.set(element, priority); if (this.pos.get(element) < 0) return; if (priority < q) this.down(element); if (q < priority) this.up(element); }
java
public void update(int element, double priority) { this.doImport(element); final double q = this.prior.get(element); if (Double.compare(q, priority) == 0) return; this.prior.set(element, priority); if (this.pos.get(element) < 0) return; if (priority < q) this.down(element); if (q < priority) this.up(element); }
[ "public", "void", "update", "(", "int", "element", ",", "double", "priority", ")", "{", "this", ".", "doImport", "(", "element", ")", ";", "final", "double", "q", "=", "this", ".", "prior", ".", "get", "(", "element", ")", ";", "if", "(", "Double", ...
Updated the priority of a given element. @param element the element @param priority the new priority
[ "Updated", "the", "priority", "of", "a", "given", "element", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L167-L179
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.pop
public void pop(int element) { assert this.contains(element); int i = this.pos.get(element); this.pos.set(element, -1); int last = this.heap.back(); this.heap.pop(); int j = this.heap.size(); if (i == j) return; assert i < j; this.pos.set(last, i); this.heap.set(i, last); this.up(last); this.down(last); }
java
public void pop(int element) { assert this.contains(element); int i = this.pos.get(element); this.pos.set(element, -1); int last = this.heap.back(); this.heap.pop(); int j = this.heap.size(); if (i == j) return; assert i < j; this.pos.set(last, i); this.heap.set(i, last); this.up(last); this.down(last); }
[ "public", "void", "pop", "(", "int", "element", ")", "{", "assert", "this", ".", "contains", "(", "element", ")", ";", "int", "i", "=", "this", ".", "pos", ".", "get", "(", "element", ")", ";", "this", ".", "pos", ".", "set", "(", "element", ",",...
Removes a given element from the priority queue. Its priority is kept as is. @param element the element
[ "Removes", "a", "given", "element", "from", "the", "priority", "queue", ".", "Its", "priority", "is", "kept", "as", "is", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L185-L199
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.rescore
public void rescore(double factor) { for (int i = 0; i < this.prior.size(); i++) this.prior.set(i, this.prior.get(i) * factor); }
java
public void rescore(double factor) { for (int i = 0; i < this.prior.size(); i++) this.prior.set(i, this.prior.get(i) * factor); }
[ "public", "void", "rescore", "(", "double", "factor", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "prior", ".", "size", "(", ")", ";", "i", "++", ")", "this", ".", "prior", ".", "set", "(", "i", ",", "this", ".", ...
Rescores all priorities by multiplying them with the same factor. @param factor the factor to multiply with
[ "Rescores", "all", "priorities", "by", "multiplying", "them", "with", "the", "same", "factor", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L212-L215
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.up
private void up(int element) { int epos = this.pos.get(element); while (epos > 0) { int ppos = parent(epos); int p = this.heap.get(ppos); if (!this.less(p, element)) break; this.heap.set(epos, p); this.heap.set(ppos, element); this.pos.set(p, epos); epos = ppos; } this.pos.set(element, epos); }
java
private void up(int element) { int epos = this.pos.get(element); while (epos > 0) { int ppos = parent(epos); int p = this.heap.get(ppos); if (!this.less(p, element)) break; this.heap.set(epos, p); this.heap.set(ppos, element); this.pos.set(p, epos); epos = ppos; } this.pos.set(element, epos); }
[ "private", "void", "up", "(", "int", "element", ")", "{", "int", "epos", "=", "this", ".", "pos", ".", "get", "(", "element", ")", ";", "while", "(", "epos", ">", "0", ")", "{", "int", "ppos", "=", "parent", "(", "epos", ")", ";", "int", "p", ...
Bubbles a given element up. @param element the element
[ "Bubbles", "a", "given", "element", "up", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L232-L245
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java
LNGDoublePriorityQueue.down
private void down(int element) { assert this.contains(element); int epos = this.pos.get(element); int size = this.heap.size(); while (true) { int cpos = left(epos); if (cpos >= size) break; int c = this.heap.get(cpos); int o; int opos = right(epos); if (!this.less(element, c)) { if (opos >= size) break; o = this.heap.get(opos); if (!this.less(element, o)) break; cpos = opos; c = o; } else if (opos < size) { o = this.heap.get(opos); if (!this.less(o, c)) { cpos = opos; c = o; } } this.heap.set(cpos, element); this.heap.set(epos, c); this.pos.set(c, epos); epos = cpos; } this.pos.set(element, epos); }
java
private void down(int element) { assert this.contains(element); int epos = this.pos.get(element); int size = this.heap.size(); while (true) { int cpos = left(epos); if (cpos >= size) break; int c = this.heap.get(cpos); int o; int opos = right(epos); if (!this.less(element, c)) { if (opos >= size) break; o = this.heap.get(opos); if (!this.less(element, o)) break; cpos = opos; c = o; } else if (opos < size) { o = this.heap.get(opos); if (!this.less(o, c)) { cpos = opos; c = o; } } this.heap.set(cpos, element); this.heap.set(epos, c); this.pos.set(c, epos); epos = cpos; } this.pos.set(element, epos); }
[ "private", "void", "down", "(", "int", "element", ")", "{", "assert", "this", ".", "contains", "(", "element", ")", ";", "int", "epos", "=", "this", ".", "pos", ".", "get", "(", "element", ")", ";", "int", "size", "=", "this", ".", "heap", ".", "...
Bubbles a given element down. @param element the element
[ "Bubbles", "a", "given", "element", "down", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGDoublePriorityQueue.java#L251-L283
train
logic-ng/LogicNG
src/main/java/org/logicng/io/readers/FormulaReader.java
FormulaReader.read
private static Formula read(final File file, final FormulaParser parser) throws IOException, ParserException { try (final BufferedReader br = new BufferedReader(new FileReader(file))) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(); while (br.ready()) ops.add(parser.parse(br.readLine())); return parser.factory().and(ops); } }
java
private static Formula read(final File file, final FormulaParser parser) throws IOException, ParserException { try (final BufferedReader br = new BufferedReader(new FileReader(file))) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(); while (br.ready()) ops.add(parser.parse(br.readLine())); return parser.factory().and(ops); } }
[ "private", "static", "Formula", "read", "(", "final", "File", "file", ",", "final", "FormulaParser", "parser", ")", "throws", "IOException", ",", "ParserException", "{", "try", "(", "final", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "Fi...
Internal read function. @param file the file @param parser the parser @return the parsed formula @throws IOException if there was a problem reading the file @throws ParserException if there was a problem parsing the formula
[ "Internal", "read", "function", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/io/readers/FormulaReader.java#L116-L123
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.linearSU
public static MaxSATSolver linearSU() { return new MaxSATSolver(new MaxSATConfig.Builder().cardinality(MaxSATConfig.CardinalityEncoding.MTOTALIZER).build(), Algorithm.LINEAR_SU); }
java
public static MaxSATSolver linearSU() { return new MaxSATSolver(new MaxSATConfig.Builder().cardinality(MaxSATConfig.CardinalityEncoding.MTOTALIZER).build(), Algorithm.LINEAR_SU); }
[ "public", "static", "MaxSATSolver", "linearSU", "(", ")", "{", "return", "new", "MaxSATSolver", "(", "new", "MaxSATConfig", ".", "Builder", "(", ")", ".", "cardinality", "(", "MaxSATConfig", ".", "CardinalityEncoding", ".", "MTOTALIZER", ")", ".", "build", "("...
Returns a new MaxSAT solver using LinearSU as algorithm with the default configuration. @return the MaxSAT solver
[ "Returns", "a", "new", "MaxSAT", "solver", "using", "LinearSU", "as", "algorithm", "with", "the", "default", "configuration", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L103-L105
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.wmsu3
public static MaxSATSolver wmsu3() { return new MaxSATSolver(new MaxSATConfig.Builder().incremental(MaxSATConfig.IncrementalStrategy.ITERATIVE).build(), Algorithm.WMSU3); }
java
public static MaxSATSolver wmsu3() { return new MaxSATSolver(new MaxSATConfig.Builder().incremental(MaxSATConfig.IncrementalStrategy.ITERATIVE).build(), Algorithm.WMSU3); }
[ "public", "static", "MaxSATSolver", "wmsu3", "(", ")", "{", "return", "new", "MaxSATSolver", "(", "new", "MaxSATConfig", ".", "Builder", "(", ")", ".", "incremental", "(", "MaxSATConfig", ".", "IncrementalStrategy", ".", "ITERATIVE", ")", ".", "build", "(", ...
Returns a new MaxSAT solver using weighted MSU3 as algorithm with the default configuration. @return the MaxSAT solver
[ "Returns", "a", "new", "MaxSAT", "solver", "using", "weighted", "MSU3", "as", "algorithm", "with", "the", "default", "configuration", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L171-L173
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.reset
public void reset() { this.result = UNDEF; this.var2index = new TreeMap<>(); this.index2var = new TreeMap<>(); switch (this.algorithm) { case WBO: this.solver = new WBO(this.configuration); break; case INC_WBO: this.solver = new IncWBO(this.configuration); break; case LINEAR_SU: this.solver = new LinearSU(this.configuration); break; case LINEAR_US: this.solver = new LinearUS(this.configuration); break; case MSU3: this.solver = new MSU3(this.configuration); break; case WMSU3: this.solver = new WMSU3(this.configuration); break; default: throw new IllegalArgumentException("Unknown MaxSAT algorithm: " + this.algorithm); } }
java
public void reset() { this.result = UNDEF; this.var2index = new TreeMap<>(); this.index2var = new TreeMap<>(); switch (this.algorithm) { case WBO: this.solver = new WBO(this.configuration); break; case INC_WBO: this.solver = new IncWBO(this.configuration); break; case LINEAR_SU: this.solver = new LinearSU(this.configuration); break; case LINEAR_US: this.solver = new LinearUS(this.configuration); break; case MSU3: this.solver = new MSU3(this.configuration); break; case WMSU3: this.solver = new WMSU3(this.configuration); break; default: throw new IllegalArgumentException("Unknown MaxSAT algorithm: " + this.algorithm); } }
[ "public", "void", "reset", "(", ")", "{", "this", ".", "result", "=", "UNDEF", ";", "this", ".", "var2index", "=", "new", "TreeMap", "<>", "(", ")", ";", "this", ".", "index2var", "=", "new", "TreeMap", "<>", "(", ")", ";", "switch", "(", "this", ...
Resets the solver. @throws IllegalArgumentException if the algorithm was unknown
[ "Resets", "the", "solver", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L188-L214
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.addSoftFormula
public void addSoftFormula(final Formula formula, int weight) { if (this.result != UNDEF) throw new IllegalStateException("The MaxSAT solver does currently not support an incremental interface. Reset the solver."); if (weight < 1) throw new IllegalArgumentException("The weight of a formula must be > 0"); this.addCNF(formula.cnf(), weight); }
java
public void addSoftFormula(final Formula formula, int weight) { if (this.result != UNDEF) throw new IllegalStateException("The MaxSAT solver does currently not support an incremental interface. Reset the solver."); if (weight < 1) throw new IllegalArgumentException("The weight of a formula must be > 0"); this.addCNF(formula.cnf(), weight); }
[ "public", "void", "addSoftFormula", "(", "final", "Formula", "formula", ",", "int", "weight", ")", "{", "if", "(", "this", ".", "result", "!=", "UNDEF", ")", "throw", "new", "IllegalStateException", "(", "\"The MaxSAT solver does currently not support an incremental i...
Adds a new soft formula to the solver. @param formula the formula @param weight the weight @throws IllegalStateException if a formula is added to a solver which is already solved. @throws IllegalArgumentException if the weight is &lt;1
[ "Adds", "a", "new", "soft", "formula", "to", "the", "solver", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L234-L240
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.addClause
private void addClause(final Formula formula, int weight) { this.result = UNDEF; final LNGIntVector clauseVec = new LNGIntVector((int) formula.numberOfAtoms()); for (Literal lit : formula.literals()) { Integer index = this.var2index.get(lit.variable()); if (index == null) { index = this.solver.newLiteral(false) >> 1; this.var2index.put(lit.variable(), index); this.index2var.put(index, lit.variable()); } int litNum = lit.phase() ? index * 2 : (index * 2) ^ 1; clauseVec.push(litNum); } if (weight == -1) { this.solver.addHardClause(clauseVec); } else { this.solver.setCurrentWeight(weight); this.solver.updateSumWeights(weight); this.solver.addSoftClause(weight, clauseVec); } }
java
private void addClause(final Formula formula, int weight) { this.result = UNDEF; final LNGIntVector clauseVec = new LNGIntVector((int) formula.numberOfAtoms()); for (Literal lit : formula.literals()) { Integer index = this.var2index.get(lit.variable()); if (index == null) { index = this.solver.newLiteral(false) >> 1; this.var2index.put(lit.variable(), index); this.index2var.put(index, lit.variable()); } int litNum = lit.phase() ? index * 2 : (index * 2) ^ 1; clauseVec.push(litNum); } if (weight == -1) { this.solver.addHardClause(clauseVec); } else { this.solver.setCurrentWeight(weight); this.solver.updateSumWeights(weight); this.solver.addSoftClause(weight, clauseVec); } }
[ "private", "void", "addClause", "(", "final", "Formula", "formula", ",", "int", "weight", ")", "{", "this", ".", "result", "=", "UNDEF", ";", "final", "LNGIntVector", "clauseVec", "=", "new", "LNGIntVector", "(", "(", "int", ")", "formula", ".", "numberOfA...
Adds a clause to the solver. @param formula the clause @param weight the weight of the clause (or -1 for a hard clause)
[ "Adds", "a", "clause", "to", "the", "solver", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L270-L290
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.solve
public MaxSAT.MaxSATResult solve(final MaxSATHandler handler) { if (this.result != UNDEF) return this.result; if (this.solver.currentWeight() == 1) this.solver.setProblemType(MaxSAT.ProblemType.UNWEIGHTED); else this.solver.setProblemType(MaxSAT.ProblemType.WEIGHTED); this.result = this.solver.search(handler); return this.result; }
java
public MaxSAT.MaxSATResult solve(final MaxSATHandler handler) { if (this.result != UNDEF) return this.result; if (this.solver.currentWeight() == 1) this.solver.setProblemType(MaxSAT.ProblemType.UNWEIGHTED); else this.solver.setProblemType(MaxSAT.ProblemType.WEIGHTED); this.result = this.solver.search(handler); return this.result; }
[ "public", "MaxSAT", ".", "MaxSATResult", "solve", "(", "final", "MaxSATHandler", "handler", ")", "{", "if", "(", "this", ".", "result", "!=", "UNDEF", ")", "return", "this", ".", "result", ";", "if", "(", "this", ".", "solver", ".", "currentWeight", "(",...
Solves the formula on the solver and returns the result. @param handler a MaxSAT handler @return the result (SAT, UNSAT, Optimum found, or UNDEF if canceled by the handler)
[ "Solves", "the", "formula", "on", "the", "solver", "and", "returns", "the", "result", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L305-L314
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/MaxSATSolver.java
MaxSATSolver.model
public Assignment model() { if (this.result == UNDEF) throw new IllegalStateException("Cannot get a model as long as the formula is not solved. Call 'solve' first."); return this.result != UNSATISFIABLE ? this.createAssignment(this.solver.model()) : null; }
java
public Assignment model() { if (this.result == UNDEF) throw new IllegalStateException("Cannot get a model as long as the formula is not solved. Call 'solve' first."); return this.result != UNSATISFIABLE ? this.createAssignment(this.solver.model()) : null; }
[ "public", "Assignment", "model", "(", ")", "{", "if", "(", "this", ".", "result", "==", "UNDEF", ")", "throw", "new", "IllegalStateException", "(", "\"Cannot get a model as long as the formula is not solved. Call 'solve' first.\"", ")", ";", "return", "this", ".", "r...
Returns the model of the current result. @return the model of the current result @throws IllegalStateException if the formula is not yet solved
[ "Returns", "the", "model", "of", "the", "current", "result", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/MaxSATSolver.java#L333-L337
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java
Encoding.addUnitClause
private void addUnitClause(final MiniSatStyleSolver s, int a, int blocking) { assert this.clause.size() == 0; assert a != LIT_UNDEF; assert var(a) < s.nVars(); this.clause.push(a); if (blocking != LIT_UNDEF) this.clause.push(blocking); s.addClause(this.clause, null); this.clause.clear(); }
java
private void addUnitClause(final MiniSatStyleSolver s, int a, int blocking) { assert this.clause.size() == 0; assert a != LIT_UNDEF; assert var(a) < s.nVars(); this.clause.push(a); if (blocking != LIT_UNDEF) this.clause.push(blocking); s.addClause(this.clause, null); this.clause.clear(); }
[ "private", "void", "addUnitClause", "(", "final", "MiniSatStyleSolver", "s", ",", "int", "a", ",", "int", "blocking", ")", "{", "assert", "this", ".", "clause", ".", "size", "(", ")", "==", "0", ";", "assert", "a", "!=", "LIT_UNDEF", ";", "assert", "va...
Adds a unit clause to the given SAT solver. @param s the sat solver @param a the unit literal @param blocking the blocking literal
[ "Adds", "a", "unit", "clause", "to", "the", "given", "SAT", "solver", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java#L90-L99
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java
Encoding.addBinaryClause
void addBinaryClause(final MiniSatStyleSolver s, int a, int b) { this.addBinaryClause(s, a, b, LIT_UNDEF); }
java
void addBinaryClause(final MiniSatStyleSolver s, int a, int b) { this.addBinaryClause(s, a, b, LIT_UNDEF); }
[ "void", "addBinaryClause", "(", "final", "MiniSatStyleSolver", "s", ",", "int", "a", ",", "int", "b", ")", "{", "this", ".", "addBinaryClause", "(", "s", ",", "a", ",", "b", ",", "LIT_UNDEF", ")", ";", "}" ]
Adds a binary clause to the given SAT solver. @param s the sat solver @param a the first literal @param b the second literal
[ "Adds", "a", "binary", "clause", "to", "the", "given", "SAT", "solver", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java#L107-L109
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java
Encoding.addTernaryClause
void addTernaryClause(final MiniSatStyleSolver s, int a, int b, int c) { this.addTernaryClause(s, a, b, c, LIT_UNDEF); }
java
void addTernaryClause(final MiniSatStyleSolver s, int a, int b, int c) { this.addTernaryClause(s, a, b, c, LIT_UNDEF); }
[ "void", "addTernaryClause", "(", "final", "MiniSatStyleSolver", "s", ",", "int", "a", ",", "int", "b", ",", "int", "c", ")", "{", "this", ".", "addTernaryClause", "(", "s", ",", "a", ",", "b", ",", "c", ",", "LIT_UNDEF", ")", ";", "}" ]
Adds a ternary clause to the given SAT solver. @param s the sat solver @param a the first literal @param b the second literal @param c the third literal
[ "Adds", "a", "ternary", "clause", "to", "the", "given", "SAT", "solver", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/Encoding.java#L137-L139
train
logic-ng/LogicNG
src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java
CCTotalizer.buildAMK
void buildAMK(final EncodingResult result, final Variable[] vars, int rhs) { final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars); this.incData = new CCIncrementalData(result, CCConfig.AMK_ENCODER.TOTALIZER, rhs, cardinalityOutvars); this.toCNF(cardinalityOutvars, rhs, Bound.UPPER); assert this.cardinalityInvars.size() == 0; for (int i = rhs; i < cardinalityOutvars.size(); i++) this.result.addClause(cardinalityOutvars.get(i).negate()); }
java
void buildAMK(final EncodingResult result, final Variable[] vars, int rhs) { final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars); this.incData = new CCIncrementalData(result, CCConfig.AMK_ENCODER.TOTALIZER, rhs, cardinalityOutvars); this.toCNF(cardinalityOutvars, rhs, Bound.UPPER); assert this.cardinalityInvars.size() == 0; for (int i = rhs; i < cardinalityOutvars.size(); i++) this.result.addClause(cardinalityOutvars.get(i).negate()); }
[ "void", "buildAMK", "(", "final", "EncodingResult", "result", ",", "final", "Variable", "[", "]", "vars", ",", "int", "rhs", ")", "{", "final", "LNGVector", "<", "Variable", ">", "cardinalityOutvars", "=", "this", ".", "initializeConstraint", "(", "result", ...
Builds an at-most-k constraint. @param result the result @param vars the variables @param rhs the right-hand side @throws IllegalArgumentException if the right hand side of the constraint was negative
[ "Builds", "an", "at", "-", "most", "-", "k", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java#L83-L90
train
logic-ng/LogicNG
src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java
CCTotalizer.buildALK
void buildALK(final EncodingResult result, final Variable[] vars, int rhs) { final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars); this.incData = new CCIncrementalData(result, CCConfig.ALK_ENCODER.TOTALIZER, rhs, vars.length, cardinalityOutvars); this.toCNF(cardinalityOutvars, rhs, Bound.LOWER); assert this.cardinalityInvars.size() == 0; for (int i = 0; i < rhs; i++) this.result.addClause(cardinalityOutvars.get(i)); }
java
void buildALK(final EncodingResult result, final Variable[] vars, int rhs) { final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars); this.incData = new CCIncrementalData(result, CCConfig.ALK_ENCODER.TOTALIZER, rhs, vars.length, cardinalityOutvars); this.toCNF(cardinalityOutvars, rhs, Bound.LOWER); assert this.cardinalityInvars.size() == 0; for (int i = 0; i < rhs; i++) this.result.addClause(cardinalityOutvars.get(i)); }
[ "void", "buildALK", "(", "final", "EncodingResult", "result", ",", "final", "Variable", "[", "]", "vars", ",", "int", "rhs", ")", "{", "final", "LNGVector", "<", "Variable", ">", "cardinalityOutvars", "=", "this", ".", "initializeConstraint", "(", "result", ...
Builds an at-least-k constraint. @param result the result @param vars the variables @param rhs the right-hand side @throws IllegalArgumentException if the right hand side of the constraint was negative
[ "Builds", "an", "at", "-", "least", "-", "k", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java#L99-L106
train
logic-ng/LogicNG
src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java
CCTotalizer.buildEXK
void buildEXK(final EncodingResult result, final Variable[] vars, int rhs) { final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars); this.toCNF(cardinalityOutvars, rhs, Bound.BOTH); assert this.cardinalityInvars.size() == 0; for (int i = 0; i < rhs; i++) this.result.addClause(cardinalityOutvars.get(i)); for (int i = rhs; i < cardinalityOutvars.size(); i++) this.result.addClause(cardinalityOutvars.get(i).negate()); }
java
void buildEXK(final EncodingResult result, final Variable[] vars, int rhs) { final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars); this.toCNF(cardinalityOutvars, rhs, Bound.BOTH); assert this.cardinalityInvars.size() == 0; for (int i = 0; i < rhs; i++) this.result.addClause(cardinalityOutvars.get(i)); for (int i = rhs; i < cardinalityOutvars.size(); i++) this.result.addClause(cardinalityOutvars.get(i).negate()); }
[ "void", "buildEXK", "(", "final", "EncodingResult", "result", ",", "final", "Variable", "[", "]", "vars", ",", "int", "rhs", ")", "{", "final", "LNGVector", "<", "Variable", ">", "cardinalityOutvars", "=", "this", ".", "initializeConstraint", "(", "result", ...
Builds an exactly-k constraint. @param vars the variables @param rhs the right-hand side @throws IllegalArgumentException if the right hand side of the constraint was negative
[ "Builds", "an", "exactly", "-", "k", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java#L114-L122
train
logic-ng/LogicNG
src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java
CCTotalizer.initializeConstraint
private LNGVector<Variable> initializeConstraint(final EncodingResult result, final Variable[] vars) { result.reset(); this.result = result; this.cardinalityInvars = new LNGVector<>(vars.length); final LNGVector<Variable> cardinalityOutvars = new LNGVector<>(vars.length); for (final Variable var : vars) { this.cardinalityInvars.push(var); cardinalityOutvars.push(this.result.newVariable()); } return cardinalityOutvars; }
java
private LNGVector<Variable> initializeConstraint(final EncodingResult result, final Variable[] vars) { result.reset(); this.result = result; this.cardinalityInvars = new LNGVector<>(vars.length); final LNGVector<Variable> cardinalityOutvars = new LNGVector<>(vars.length); for (final Variable var : vars) { this.cardinalityInvars.push(var); cardinalityOutvars.push(this.result.newVariable()); } return cardinalityOutvars; }
[ "private", "LNGVector", "<", "Variable", ">", "initializeConstraint", "(", "final", "EncodingResult", "result", ",", "final", "Variable", "[", "]", "vars", ")", "{", "result", ".", "reset", "(", ")", ";", "this", ".", "result", "=", "result", ";", "this", ...
Initializes the constraint. @param vars the variables @return the auxiliary variables
[ "Initializes", "the", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java#L129-L139
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/printer/LatexStringRepresentation.java
LatexStringRepresentation.latexName
private static String latexName(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) + "_{" + matcher.group(2) + "}"; }
java
private static String latexName(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) + "_{" + matcher.group(2) + "}"; }
[ "private", "static", "String", "latexName", "(", "final", "String", "name", ")", "{", "final", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "name", ")", ";", "if", "(", "!", "matcher", ".", "matches", "(", ")", ")", "return", "name", ";",...
Returns the latex string for a variable name @param name the name @return the matching UTF8 symbol
[ "Returns", "the", "latex", "string", "for", "a", "variable", "name" ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/printer/LatexStringRepresentation.java#L52-L59
train
logic-ng/LogicNG
src/main/java/org/logicng/explanations/unsatcores/MUSGeneration.java
MUSGeneration.computeMUS
public <T extends Proposition> UNSATCore<T> computeMUS(final List<T> propositions, final FormulaFactory f) { return this.computeMUS(propositions, f, new MUSConfig.Builder().build()); }
java
public <T extends Proposition> UNSATCore<T> computeMUS(final List<T> propositions, final FormulaFactory f) { return this.computeMUS(propositions, f, new MUSConfig.Builder().build()); }
[ "public", "<", "T", "extends", "Proposition", ">", "UNSATCore", "<", "T", ">", "computeMUS", "(", "final", "List", "<", "T", ">", "propositions", ",", "final", "FormulaFactory", "f", ")", "{", "return", "this", ".", "computeMUS", "(", "propositions", ",", ...
Computes a MUS for the given propositions with the default algorithm and the default configuration. @param propositions the propositions @param f the formula factory @param <T> the type of the MUSes propositions @return the MUS
[ "Computes", "a", "MUS", "for", "the", "given", "propositions", "with", "the", "default", "algorithm", "and", "the", "default", "configuration", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/explanations/unsatcores/MUSGeneration.java#L63-L65
train
logic-ng/LogicNG
src/main/java/org/logicng/explanations/unsatcores/MUSGeneration.java
MUSGeneration.computeMUS
public <T extends Proposition> UNSATCore<T> computeMUS(final List<T> propositions, final FormulaFactory f, final MUSConfig config) { if (propositions.isEmpty()) throw new IllegalArgumentException("Cannot generate a MUS for an empty list of propositions"); switch (config.algorithm) { case PLAIN_INSERTION: return insertion.computeMUS(propositions, f, config); case DELETION: default: return deletion.computeMUS(propositions, f, config); } }
java
public <T extends Proposition> UNSATCore<T> computeMUS(final List<T> propositions, final FormulaFactory f, final MUSConfig config) { if (propositions.isEmpty()) throw new IllegalArgumentException("Cannot generate a MUS for an empty list of propositions"); switch (config.algorithm) { case PLAIN_INSERTION: return insertion.computeMUS(propositions, f, config); case DELETION: default: return deletion.computeMUS(propositions, f, config); } }
[ "public", "<", "T", "extends", "Proposition", ">", "UNSATCore", "<", "T", ">", "computeMUS", "(", "final", "List", "<", "T", ">", "propositions", ",", "final", "FormulaFactory", "f", ",", "final", "MUSConfig", "config", ")", "{", "if", "(", "propositions",...
Computes a MUS for the given propositions and the given configuration of the MUS generation. @param propositions the propositions @param f the formula factory @param config the MUS configuration @param <T> the type of the MUSes propositions @return the MUS
[ "Computes", "a", "MUS", "for", "the", "given", "propositions", "and", "the", "given", "configuration", "of", "the", "MUS", "generation", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/explanations/unsatcores/MUSGeneration.java#L75-L85
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/datastructures/CLVar.java
CLVar.reset
public void reset() { this.state = State.FREE; this.level = Integer.MAX_VALUE; this.mark = 0; this.reason = null; }
java
public void reset() { this.state = State.FREE; this.level = Integer.MAX_VALUE; this.mark = 0; this.reason = null; }
[ "public", "void", "reset", "(", ")", "{", "this", ".", "state", "=", "State", ".", "FREE", ";", "this", ".", "level", "=", "Integer", ".", "MAX_VALUE", ";", "this", ".", "mark", "=", "0", ";", "this", ".", "reason", "=", "null", ";", "}" ]
Resets this variable's members.
[ "Resets", "this", "variable", "s", "members", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/datastructures/CLVar.java#L84-L89
train
logic-ng/LogicNG
src/main/java/org/logicng/pseudobooleans/PBEncoder.java
PBEncoder.encode
public ImmutableFormulaList encode(final PBConstraint constraint) { if (constraint.isCC()) return this.ccEncoder.encode(constraint); final Formula normalized = constraint.normalize(); switch (normalized.type()) { case TRUE: return new ImmutableFormulaList(FType.AND); case FALSE: return new ImmutableFormulaList(FType.AND, this.f.falsum()); case PBC: final PBConstraint pbc = (PBConstraint) normalized; if (pbc.isCC()) return this.ccEncoder.encode(pbc); return new ImmutableFormulaList(FType.AND, this.encode(pbc.operands(), pbc.coefficients(), pbc.rhs())); case AND: final List<Formula> list = new LinkedList<>(); for (final Formula op : normalized) { switch (op.type()) { case FALSE: return new ImmutableFormulaList(FType.AND, this.f.falsum()); case PBC: list.addAll(this.encode((PBConstraint) op).toList()); break; default: throw new IllegalArgumentException("Illegal return value of PBConstraint.normalize"); } } return new ImmutableFormulaList(FType.AND, list); default: throw new IllegalArgumentException("Illegal return value of PBConstraint.normalize"); } }
java
public ImmutableFormulaList encode(final PBConstraint constraint) { if (constraint.isCC()) return this.ccEncoder.encode(constraint); final Formula normalized = constraint.normalize(); switch (normalized.type()) { case TRUE: return new ImmutableFormulaList(FType.AND); case FALSE: return new ImmutableFormulaList(FType.AND, this.f.falsum()); case PBC: final PBConstraint pbc = (PBConstraint) normalized; if (pbc.isCC()) return this.ccEncoder.encode(pbc); return new ImmutableFormulaList(FType.AND, this.encode(pbc.operands(), pbc.coefficients(), pbc.rhs())); case AND: final List<Formula> list = new LinkedList<>(); for (final Formula op : normalized) { switch (op.type()) { case FALSE: return new ImmutableFormulaList(FType.AND, this.f.falsum()); case PBC: list.addAll(this.encode((PBConstraint) op).toList()); break; default: throw new IllegalArgumentException("Illegal return value of PBConstraint.normalize"); } } return new ImmutableFormulaList(FType.AND, list); default: throw new IllegalArgumentException("Illegal return value of PBConstraint.normalize"); } }
[ "public", "ImmutableFormulaList", "encode", "(", "final", "PBConstraint", "constraint", ")", "{", "if", "(", "constraint", ".", "isCC", "(", ")", ")", "return", "this", ".", "ccEncoder", ".", "encode", "(", "constraint", ")", ";", "final", "Formula", "normal...
Encodes a pseudo-Boolean constraint and returns its CNF encoding. @param constraint the pseudo-Boolean constraint @return the CNF encoding of the pseudo-Boolean constraint
[ "Encodes", "a", "pseudo", "-", "Boolean", "constraint", "and", "returns", "its", "CNF", "encoding", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/pseudobooleans/PBEncoder.java#L105-L136
train
logic-ng/LogicNG
src/main/java/org/logicng/datastructures/ubtrees/UBTree.java
UBTree.addSet
public void addSet(final SortedSet<T> set) { SortedMap<T, UBNode<T>> nodes = rootNodes; UBNode<T> node = null; for (T element : set) { node = nodes.get(element); if (node == null) { node = new UBNode<>(element); nodes.put(element, node); } nodes = node.children(); } if (node != null) { node.setEndSet(set); } }
java
public void addSet(final SortedSet<T> set) { SortedMap<T, UBNode<T>> nodes = rootNodes; UBNode<T> node = null; for (T element : set) { node = nodes.get(element); if (node == null) { node = new UBNode<>(element); nodes.put(element, node); } nodes = node.children(); } if (node != null) { node.setEndSet(set); } }
[ "public", "void", "addSet", "(", "final", "SortedSet", "<", "T", ">", "set", ")", "{", "SortedMap", "<", "T", ",", "UBNode", "<", "T", ">", ">", "nodes", "=", "rootNodes", ";", "UBNode", "<", "T", ">", "node", "=", "null", ";", "for", "(", "T", ...
Adds a set of comparable objects to this UBTree. @param set the set of comparable objects
[ "Adds", "a", "set", "of", "comparable", "objects", "to", "this", "UBTree", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/datastructures/ubtrees/UBTree.java#L33-L47
train
logic-ng/LogicNG
src/main/java/org/logicng/datastructures/ubtrees/UBTree.java
UBTree.firstSubset
public SortedSet<T> firstSubset(SortedSet<T> set) { if (this.rootNodes.isEmpty() || set == null || set.isEmpty()) { return null; } return firstSubset(set, this.rootNodes); }
java
public SortedSet<T> firstSubset(SortedSet<T> set) { if (this.rootNodes.isEmpty() || set == null || set.isEmpty()) { return null; } return firstSubset(set, this.rootNodes); }
[ "public", "SortedSet", "<", "T", ">", "firstSubset", "(", "SortedSet", "<", "T", ">", "set", ")", "{", "if", "(", "this", ".", "rootNodes", ".", "isEmpty", "(", ")", "||", "set", "==", "null", "||", "set", ".", "isEmpty", "(", ")", ")", "{", "ret...
Returns the first subset of a given set in this UBTree. @param set the set to search for @return the first subset which is found for the given set or {@code null} if there is none
[ "Returns", "the", "first", "subset", "of", "a", "given", "set", "in", "this", "UBTree", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/datastructures/ubtrees/UBTree.java#L54-L59
train
logic-ng/LogicNG
src/main/java/org/logicng/datastructures/ubtrees/UBTree.java
UBTree.allSubsets
public Set<SortedSet<T>> allSubsets(final SortedSet<T> set) { final Set<SortedSet<T>> subsets = new LinkedHashSet<>(); allSubsets(set, this.rootNodes, subsets); return subsets; }
java
public Set<SortedSet<T>> allSubsets(final SortedSet<T> set) { final Set<SortedSet<T>> subsets = new LinkedHashSet<>(); allSubsets(set, this.rootNodes, subsets); return subsets; }
[ "public", "Set", "<", "SortedSet", "<", "T", ">", ">", "allSubsets", "(", "final", "SortedSet", "<", "T", ">", "set", ")", "{", "final", "Set", "<", "SortedSet", "<", "T", ">", ">", "subsets", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "allS...
Returns all subsets of a given set in this UBTree. @param set the set to search for @return all subsets of of the given set
[ "Returns", "all", "subsets", "of", "a", "given", "set", "in", "this", "UBTree", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/datastructures/ubtrees/UBTree.java#L66-L70
train
logic-ng/LogicNG
src/main/java/org/logicng/datastructures/ubtrees/UBTree.java
UBTree.allSupersets
public Set<SortedSet<T>> allSupersets(final SortedSet<T> set) { final Set<SortedSet<T>> supersets = new LinkedHashSet<>(); allSupersets(set, this.rootNodes, supersets); return supersets; }
java
public Set<SortedSet<T>> allSupersets(final SortedSet<T> set) { final Set<SortedSet<T>> supersets = new LinkedHashSet<>(); allSupersets(set, this.rootNodes, supersets); return supersets; }
[ "public", "Set", "<", "SortedSet", "<", "T", ">", ">", "allSupersets", "(", "final", "SortedSet", "<", "T", ">", "set", ")", "{", "final", "Set", "<", "SortedSet", "<", "T", ">", ">", "supersets", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "...
Returns all supersets of a given set in this UBTree. @param set the set to search for @return all supersets of the given set
[ "Returns", "all", "supersets", "of", "a", "given", "set", "in", "this", "UBTree", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/datastructures/ubtrees/UBTree.java#L77-L81
train
logic-ng/LogicNG
src/main/java/org/logicng/datastructures/ubtrees/UBTree.java
UBTree.allSets
public Set<SortedSet<T>> allSets() { final List<UBNode<T>> allEndOfPathNodes = getAllEndOfPathNodes(this.rootNodes); final Set<SortedSet<T>> allSets = new LinkedHashSet<>(); for (UBNode<T> endOfPathNode : allEndOfPathNodes) { allSets.add(endOfPathNode.set()); } return allSets; }
java
public Set<SortedSet<T>> allSets() { final List<UBNode<T>> allEndOfPathNodes = getAllEndOfPathNodes(this.rootNodes); final Set<SortedSet<T>> allSets = new LinkedHashSet<>(); for (UBNode<T> endOfPathNode : allEndOfPathNodes) { allSets.add(endOfPathNode.set()); } return allSets; }
[ "public", "Set", "<", "SortedSet", "<", "T", ">", ">", "allSets", "(", ")", "{", "final", "List", "<", "UBNode", "<", "T", ">", ">", "allEndOfPathNodes", "=", "getAllEndOfPathNodes", "(", "this", ".", "rootNodes", ")", ";", "final", "Set", "<", "Sorted...
Returns all sets in this UBTree. @return all sets in this UBTree
[ "Returns", "all", "sets", "in", "this", "UBTree", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/datastructures/ubtrees/UBTree.java#L87-L94
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.clear
public void clear() { this.posLiterals = new HashMap<>(); this.negLiterals = new HashMap<>(); this.generatedVariables = new HashSet<>(); this.nots = new HashMap<>(); this.implications = new HashMap<>(); this.equivalences = new HashMap<>(); this.ands2 = new HashMap<>(); this.ands3 = new HashMap<>(); this.ands4 = new HashMap<>(); this.andsN = new HashMap<>(); this.ors2 = new HashMap<>(); this.ors3 = new HashMap<>(); this.ors4 = new HashMap<>(); this.orsN = new HashMap<>(); this.pbConstraints = new HashMap<>(); this.ccCounter = 0; this.pbCounter = 0; this.cnfCounter = 0; }
java
public void clear() { this.posLiterals = new HashMap<>(); this.negLiterals = new HashMap<>(); this.generatedVariables = new HashSet<>(); this.nots = new HashMap<>(); this.implications = new HashMap<>(); this.equivalences = new HashMap<>(); this.ands2 = new HashMap<>(); this.ands3 = new HashMap<>(); this.ands4 = new HashMap<>(); this.andsN = new HashMap<>(); this.ors2 = new HashMap<>(); this.ors3 = new HashMap<>(); this.ors4 = new HashMap<>(); this.orsN = new HashMap<>(); this.pbConstraints = new HashMap<>(); this.ccCounter = 0; this.pbCounter = 0; this.cnfCounter = 0; }
[ "public", "void", "clear", "(", ")", "{", "this", ".", "posLiterals", "=", "new", "HashMap", "<>", "(", ")", ";", "this", ".", "negLiterals", "=", "new", "HashMap", "<>", "(", ")", ";", "this", ".", "generatedVariables", "=", "new", "HashSet", "<>", ...
Removes all formulas from the factory cache.
[ "Removes", "all", "formulas", "from", "the", "factory", "cache", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L174-L193
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.binaryOperator
public Formula binaryOperator(final FType type, final Formula left, final Formula right) { switch (type) { case IMPL: return this.implication(left, right); case EQUIV: return this.equivalence(left, right); default: throw new IllegalArgumentException("Cannot create a binary formula with operator: " + type); } }
java
public Formula binaryOperator(final FType type, final Formula left, final Formula right) { switch (type) { case IMPL: return this.implication(left, right); case EQUIV: return this.equivalence(left, right); default: throw new IllegalArgumentException("Cannot create a binary formula with operator: " + type); } }
[ "public", "Formula", "binaryOperator", "(", "final", "FType", "type", ",", "final", "Formula", "left", ",", "final", "Formula", "right", ")", "{", "switch", "(", "type", ")", "{", "case", "IMPL", ":", "return", "this", ".", "implication", "(", "left", ",...
Creates a new binary operator with a given type and two operands. @param type the type of the formula @param left the left-hand side operand @param right the right-hand side operand @return the newly generated formula @throws IllegalArgumentException if a wrong formula type is passed
[ "Creates", "a", "new", "binary", "operator", "with", "a", "given", "type", "and", "two", "operands", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L253-L262
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.implication
public Formula implication(final Formula left, final Formula right) { if (left.type() == FALSE || right.type() == TRUE) return this.verum(); if (left.type() == TRUE) return right; if (right.type() == FALSE) return this.not(left); if (left.equals(right)) return this.verum(); final Pair<Formula, Formula> key = new Pair<>(left, right); Implication implication = this.implications.get(key); if (implication == null) { implication = new Implication(left, right, this); this.implications.put(key, implication); } return implication; }
java
public Formula implication(final Formula left, final Formula right) { if (left.type() == FALSE || right.type() == TRUE) return this.verum(); if (left.type() == TRUE) return right; if (right.type() == FALSE) return this.not(left); if (left.equals(right)) return this.verum(); final Pair<Formula, Formula> key = new Pair<>(left, right); Implication implication = this.implications.get(key); if (implication == null) { implication = new Implication(left, right, this); this.implications.put(key, implication); } return implication; }
[ "public", "Formula", "implication", "(", "final", "Formula", "left", ",", "final", "Formula", "right", ")", "{", "if", "(", "left", ".", "type", "(", ")", "==", "FALSE", "||", "right", ".", "type", "(", ")", "==", "TRUE", ")", "return", "this", ".", ...
Creates a new implication. @param left the left-hand side operand @param right the right-hand side operand @return a new implication
[ "Creates", "a", "new", "implication", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L270-L286
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.equivalence
public Formula equivalence(final Formula left, final Formula right) { if (left.type() == TRUE) return right; if (right.type() == TRUE) return left; if (left.type() == FALSE) return this.not(right); if (right.type() == FALSE) return this.not(left); if (left.equals(right)) return this.verum(); if (left.equals(right.negate())) return this.falsum(); final LinkedHashSet<Formula> key = new LinkedHashSet<>(Arrays.asList(left, right)); Equivalence equivalence = this.equivalences.get(key); if (equivalence == null) { equivalence = new Equivalence(left, right, this); this.equivalences.put(key, equivalence); } return equivalence; }
java
public Formula equivalence(final Formula left, final Formula right) { if (left.type() == TRUE) return right; if (right.type() == TRUE) return left; if (left.type() == FALSE) return this.not(right); if (right.type() == FALSE) return this.not(left); if (left.equals(right)) return this.verum(); if (left.equals(right.negate())) return this.falsum(); final LinkedHashSet<Formula> key = new LinkedHashSet<>(Arrays.asList(left, right)); Equivalence equivalence = this.equivalences.get(key); if (equivalence == null) { equivalence = new Equivalence(left, right, this); this.equivalences.put(key, equivalence); } return equivalence; }
[ "public", "Formula", "equivalence", "(", "final", "Formula", "left", ",", "final", "Formula", "right", ")", "{", "if", "(", "left", ".", "type", "(", ")", "==", "TRUE", ")", "return", "right", ";", "if", "(", "right", ".", "type", "(", ")", "==", "...
Creates a new equivalence. @param left the left-hand side operand @param right the right-hand side operand @return a new equivalence
[ "Creates", "a", "new", "equivalence", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L294-L314
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.and
public Formula and(final Formula... operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(operands.length); Collections.addAll(ops, operands); return this.constructAnd(ops); }
java
public Formula and(final Formula... operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(operands.length); Collections.addAll(ops, operands); return this.constructAnd(ops); }
[ "public", "Formula", "and", "(", "final", "Formula", "...", "operands", ")", "{", "final", "LinkedHashSet", "<", "Formula", ">", "ops", "=", "new", "LinkedHashSet", "<>", "(", "operands", ".", "length", ")", ";", "Collections", ".", "addAll", "(", "ops", ...
Creates a new conjunction from an array of formulas. @param operands the vector of formulas @return a new conjunction
[ "Creates", "a", "new", "conjunction", "from", "an", "array", "of", "formulas", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L394-L398
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.constructAnd
private Formula constructAnd(final LinkedHashSet<? extends Formula> operands) { And tempAnd = null; Map<LinkedHashSet<? extends Formula>, And> opAndMap = this.andsN; if (operands.size() > 1) { switch (operands.size()) { case 2: opAndMap = this.ands2; break; case 3: opAndMap = this.ands3; break; case 4: opAndMap = this.ands4; break; default: break; } tempAnd = opAndMap.get(operands); } if (tempAnd != null) return tempAnd; final LinkedHashSet<? extends Formula> condensedOperands = operands.size() < 2 ? operands : this.condenseOperandsAnd(operands); if (condensedOperands == null) return this.falsum(); if (condensedOperands.isEmpty()) return this.verum(); if (condensedOperands.size() == 1) return condensedOperands.iterator().next(); final And and; Map<LinkedHashSet<? extends Formula>, And> condAndMap = this.andsN; switch (condensedOperands.size()) { case 2: condAndMap = this.ands2; break; case 3: condAndMap = this.ands3; break; case 4: condAndMap = this.ands4; break; default: break; } and = condAndMap.get(condensedOperands); if (and == null) { tempAnd = new And(condensedOperands, this, this.cnfCheck); opAndMap.put(operands, tempAnd); condAndMap.put(condensedOperands, tempAnd); return tempAnd; } opAndMap.put(operands, and); return and; }
java
private Formula constructAnd(final LinkedHashSet<? extends Formula> operands) { And tempAnd = null; Map<LinkedHashSet<? extends Formula>, And> opAndMap = this.andsN; if (operands.size() > 1) { switch (operands.size()) { case 2: opAndMap = this.ands2; break; case 3: opAndMap = this.ands3; break; case 4: opAndMap = this.ands4; break; default: break; } tempAnd = opAndMap.get(operands); } if (tempAnd != null) return tempAnd; final LinkedHashSet<? extends Formula> condensedOperands = operands.size() < 2 ? operands : this.condenseOperandsAnd(operands); if (condensedOperands == null) return this.falsum(); if (condensedOperands.isEmpty()) return this.verum(); if (condensedOperands.size() == 1) return condensedOperands.iterator().next(); final And and; Map<LinkedHashSet<? extends Formula>, And> condAndMap = this.andsN; switch (condensedOperands.size()) { case 2: condAndMap = this.ands2; break; case 3: condAndMap = this.ands3; break; case 4: condAndMap = this.ands4; break; default: break; } and = condAndMap.get(condensedOperands); if (and == null) { tempAnd = new And(condensedOperands, this, this.cnfCheck); opAndMap.put(operands, tempAnd); condAndMap.put(condensedOperands, tempAnd); return tempAnd; } opAndMap.put(operands, and); return and; }
[ "private", "Formula", "constructAnd", "(", "final", "LinkedHashSet", "<", "?", "extends", "Formula", ">", "operands", ")", "{", "And", "tempAnd", "=", "null", ";", "Map", "<", "LinkedHashSet", "<", "?", "extends", "Formula", ">", ",", "And", ">", "opAndMap...
Creates a new conjunction. @param operands the formulas @return a new conjunction
[ "Creates", "a", "new", "conjunction", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L417-L471
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.constructCNF
private Formula constructCNF(final LinkedHashSet<? extends Formula> clauses) { if (clauses.isEmpty()) return this.verum(); if (clauses.size() == 1) return clauses.iterator().next(); Map<LinkedHashSet<? extends Formula>, And> opAndMap = this.andsN; switch (clauses.size()) { case 2: opAndMap = this.ands2; break; case 3: opAndMap = this.ands3; break; case 4: opAndMap = this.ands4; break; default: break; } And tempAnd = opAndMap.get(clauses); if (tempAnd != null) return tempAnd; tempAnd = new And(clauses, this, true); opAndMap.put(clauses, tempAnd); return tempAnd; }
java
private Formula constructCNF(final LinkedHashSet<? extends Formula> clauses) { if (clauses.isEmpty()) return this.verum(); if (clauses.size() == 1) return clauses.iterator().next(); Map<LinkedHashSet<? extends Formula>, And> opAndMap = this.andsN; switch (clauses.size()) { case 2: opAndMap = this.ands2; break; case 3: opAndMap = this.ands3; break; case 4: opAndMap = this.ands4; break; default: break; } And tempAnd = opAndMap.get(clauses); if (tempAnd != null) return tempAnd; tempAnd = new And(clauses, this, true); opAndMap.put(clauses, tempAnd); return tempAnd; }
[ "private", "Formula", "constructCNF", "(", "final", "LinkedHashSet", "<", "?", "extends", "Formula", ">", "clauses", ")", "{", "if", "(", "clauses", ".", "isEmpty", "(", ")", ")", "return", "this", ".", "verum", "(", ")", ";", "if", "(", "clauses", "."...
Creates a new CNF. @param clauses the clauses @return a new CNF
[ "Creates", "a", "new", "CNF", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L507-L532
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.or
public Formula or(final Formula... operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(operands.length); Collections.addAll(ops, operands); return this.constructOr(ops); }
java
public Formula or(final Formula... operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(operands.length); Collections.addAll(ops, operands); return this.constructOr(ops); }
[ "public", "Formula", "or", "(", "final", "Formula", "...", "operands", ")", "{", "final", "LinkedHashSet", "<", "Formula", ">", "ops", "=", "new", "LinkedHashSet", "<>", "(", "operands", ".", "length", ")", ";", "Collections", ".", "addAll", "(", "ops", ...
Creates a new disjunction from an array of formulas. @param operands the list of formulas @return a new disjunction
[ "Creates", "a", "new", "disjunction", "from", "an", "array", "of", "formulas", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L539-L543
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.constructOr
private Formula constructOr(final LinkedHashSet<? extends Formula> operands) { Or tempOr = null; Map<LinkedHashSet<? extends Formula>, Or> opOrMap = this.orsN; if (operands.size() > 1) { switch (operands.size()) { case 2: opOrMap = this.ors2; break; case 3: opOrMap = this.ors3; break; case 4: opOrMap = this.ors4; break; default: break; } tempOr = opOrMap.get(operands); } if (tempOr != null) return tempOr; final LinkedHashSet<? extends Formula> condensedOperands = operands.size() < 2 ? operands : this.condenseOperandsOr(operands); if (condensedOperands == null) return this.verum(); if (condensedOperands.isEmpty()) return this.falsum(); if (condensedOperands.size() == 1) return condensedOperands.iterator().next(); final Or or; Map<LinkedHashSet<? extends Formula>, Or> condOrMap = this.orsN; switch (condensedOperands.size()) { case 2: condOrMap = this.ors2; break; case 3: condOrMap = this.ors3; break; case 4: condOrMap = this.ors4; break; default: break; } or = condOrMap.get(condensedOperands); if (or == null) { tempOr = new Or(condensedOperands, this, this.cnfCheck); opOrMap.put(operands, tempOr); condOrMap.put(condensedOperands, tempOr); return tempOr; } opOrMap.put(operands, or); return or; }
java
private Formula constructOr(final LinkedHashSet<? extends Formula> operands) { Or tempOr = null; Map<LinkedHashSet<? extends Formula>, Or> opOrMap = this.orsN; if (operands.size() > 1) { switch (operands.size()) { case 2: opOrMap = this.ors2; break; case 3: opOrMap = this.ors3; break; case 4: opOrMap = this.ors4; break; default: break; } tempOr = opOrMap.get(operands); } if (tempOr != null) return tempOr; final LinkedHashSet<? extends Formula> condensedOperands = operands.size() < 2 ? operands : this.condenseOperandsOr(operands); if (condensedOperands == null) return this.verum(); if (condensedOperands.isEmpty()) return this.falsum(); if (condensedOperands.size() == 1) return condensedOperands.iterator().next(); final Or or; Map<LinkedHashSet<? extends Formula>, Or> condOrMap = this.orsN; switch (condensedOperands.size()) { case 2: condOrMap = this.ors2; break; case 3: condOrMap = this.ors3; break; case 4: condOrMap = this.ors4; break; default: break; } or = condOrMap.get(condensedOperands); if (or == null) { tempOr = new Or(condensedOperands, this, this.cnfCheck); opOrMap.put(operands, tempOr); condOrMap.put(condensedOperands, tempOr); return tempOr; } opOrMap.put(operands, or); return or; }
[ "private", "Formula", "constructOr", "(", "final", "LinkedHashSet", "<", "?", "extends", "Formula", ">", "operands", ")", "{", "Or", "tempOr", "=", "null", ";", "Map", "<", "LinkedHashSet", "<", "?", "extends", "Formula", ">", ",", "Or", ">", "opOrMap", ...
Creates a new disjunction. @param operands the formulas @return a new disjunction
[ "Creates", "a", "new", "disjunction", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L562-L616
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.constructClause
private Formula constructClause(final LinkedHashSet<Literal> literals) { if (literals.isEmpty()) return this.falsum(); if (literals.size() == 1) return literals.iterator().next(); Map<LinkedHashSet<? extends Formula>, Or> opOrMap = this.orsN; switch (literals.size()) { case 2: opOrMap = this.ors2; break; case 3: opOrMap = this.ors3; break; case 4: opOrMap = this.ors4; break; default: break; } Or tempOr = opOrMap.get(literals); if (tempOr != null) return tempOr; tempOr = new Or(literals, this, true); opOrMap.put(literals, tempOr); return tempOr; }
java
private Formula constructClause(final LinkedHashSet<Literal> literals) { if (literals.isEmpty()) return this.falsum(); if (literals.size() == 1) return literals.iterator().next(); Map<LinkedHashSet<? extends Formula>, Or> opOrMap = this.orsN; switch (literals.size()) { case 2: opOrMap = this.ors2; break; case 3: opOrMap = this.ors3; break; case 4: opOrMap = this.ors4; break; default: break; } Or tempOr = opOrMap.get(literals); if (tempOr != null) return tempOr; tempOr = new Or(literals, this, true); opOrMap.put(literals, tempOr); return tempOr; }
[ "private", "Formula", "constructClause", "(", "final", "LinkedHashSet", "<", "Literal", ">", "literals", ")", "{", "if", "(", "literals", ".", "isEmpty", "(", ")", ")", "return", "this", ".", "falsum", "(", ")", ";", "if", "(", "literals", ".", "size", ...
Creates a new clause. @param literals the literals @return a new clause
[ "Creates", "a", "new", "clause", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L650-L675
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.variable
public Variable variable(final String name) { Variable var = this.posLiterals.get(name); if (var == null) { var = new Variable(name, this); this.posLiterals.put(name, var); } return var; }
java
public Variable variable(final String name) { Variable var = this.posLiterals.get(name); if (var == null) { var = new Variable(name, this); this.posLiterals.put(name, var); } return var; }
[ "public", "Variable", "variable", "(", "final", "String", "name", ")", "{", "Variable", "var", "=", "this", ".", "posLiterals", ".", "get", "(", "name", ")", ";", "if", "(", "var", "==", "null", ")", "{", "var", "=", "new", "Variable", "(", "name", ...
Creates a new literal instance with a given name and positive phase. @param name the variable name @return a new literal with the given name and positive phase
[ "Creates", "a", "new", "literal", "instance", "with", "a", "given", "name", "and", "positive", "phase", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L703-L710
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.cc
public PBConstraint cc(final CType comparator, final int rhs, final Collection<Variable> variables) { final int[] coefficients = new int[variables.size()]; Arrays.fill(coefficients, 1); final Variable[] vars = new Variable[variables.size()]; int count = 0; for (final Variable var : variables) vars[count++] = var; return this.constructPBC(comparator, rhs, vars, coefficients); }
java
public PBConstraint cc(final CType comparator, final int rhs, final Collection<Variable> variables) { final int[] coefficients = new int[variables.size()]; Arrays.fill(coefficients, 1); final Variable[] vars = new Variable[variables.size()]; int count = 0; for (final Variable var : variables) vars[count++] = var; return this.constructPBC(comparator, rhs, vars, coefficients); }
[ "public", "PBConstraint", "cc", "(", "final", "CType", "comparator", ",", "final", "int", "rhs", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "final", "int", "[", "]", "coefficients", "=", "new", "int", "[", "variables", ".", ...
Creates a new cardinality constraint. @param variables the variables of the constraint @param comparator the comparator of the constraint @param rhs the right-hand side of the constraint @return the cardinality constraint @throws IllegalArgumentException if there are negative variables
[ "Creates", "a", "new", "cardinality", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L759-L767
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.condenseOperandsOr
private LinkedHashSet<Formula> condenseOperandsOr(final Collection<? extends Formula> operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(); this.cnfCheck = true; for (final Formula form : operands) if (form.type() == OR) { for (final Formula f : ((NAryOperator) form).operands) { this.addFormulaOr(ops, f); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } } else { this.addFormulaOr(ops, form); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } return ops; }
java
private LinkedHashSet<Formula> condenseOperandsOr(final Collection<? extends Formula> operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(); this.cnfCheck = true; for (final Formula form : operands) if (form.type() == OR) { for (final Formula f : ((NAryOperator) form).operands) { this.addFormulaOr(ops, f); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } } else { this.addFormulaOr(ops, form); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } return ops; }
[ "private", "LinkedHashSet", "<", "Formula", ">", "condenseOperandsOr", "(", "final", "Collection", "<", "?", "extends", "Formula", ">", "operands", ")", "{", "final", "LinkedHashSet", "<", "Formula", ">", "ops", "=", "new", "LinkedHashSet", "<>", "(", ")", "...
Returns a condensed array of operands for a given n-ary disjunction. @param operands the formulas @return a condensed array of operands
[ "Returns", "a", "condensed", "array", "of", "operands", "for", "a", "given", "n", "-", "ary", "disjunction", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L868-L888
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.condenseOperandsAnd
private LinkedHashSet<Formula> condenseOperandsAnd(final Collection<? extends Formula> operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(); this.cnfCheck = true; for (final Formula form : operands) if (form.type() == AND) { for (final Formula f : ((NAryOperator) form).operands) { this.addFormulaAnd(ops, f); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } } else { this.addFormulaAnd(ops, form); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } return ops; }
java
private LinkedHashSet<Formula> condenseOperandsAnd(final Collection<? extends Formula> operands) { final LinkedHashSet<Formula> ops = new LinkedHashSet<>(); this.cnfCheck = true; for (final Formula form : operands) if (form.type() == AND) { for (final Formula f : ((NAryOperator) form).operands) { this.addFormulaAnd(ops, f); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } } else { this.addFormulaAnd(ops, form); if (!this.formulaAdditionResult[0]) return null; if (!this.formulaAdditionResult[1]) this.cnfCheck = false; } return ops; }
[ "private", "LinkedHashSet", "<", "Formula", ">", "condenseOperandsAnd", "(", "final", "Collection", "<", "?", "extends", "Formula", ">", "operands", ")", "{", "final", "LinkedHashSet", "<", "Formula", ">", "ops", "=", "new", "LinkedHashSet", "<>", "(", ")", ...
Returns a condensed array of operands for a given n-ary conjunction. @param operands the formulas @return a condensed array of operands
[ "Returns", "a", "condensed", "array", "of", "operands", "for", "a", "given", "n", "-", "ary", "conjunction", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L895-L915
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.importFormula
public Formula importFormula(final Formula formula) { if (this.importer == null) { this.importer = new FormulaFactoryImporter(this); } final Formula imported = formula.transform(this.importer); adjustCounters(imported); return imported; }
java
public Formula importFormula(final Formula formula) { if (this.importer == null) { this.importer = new FormulaFactoryImporter(this); } final Formula imported = formula.transform(this.importer); adjustCounters(imported); return imported; }
[ "public", "Formula", "importFormula", "(", "final", "Formula", "formula", ")", "{", "if", "(", "this", ".", "importer", "==", "null", ")", "{", "this", ".", "importer", "=", "new", "FormulaFactoryImporter", "(", "this", ")", ";", "}", "final", "Formula", ...
Imports a formula from another formula factory into this factory and returns it. If the current factory of the formula is already this formula factory, the same instance will be returned. @param formula the formula to import @return the imported formula on this factory
[ "Imports", "a", "formula", "from", "another", "formula", "factory", "into", "this", "factory", "and", "returns", "it", ".", "If", "the", "current", "factory", "of", "the", "formula", "is", "already", "this", "formula", "factory", "the", "same", "instance", "...
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L997-L1004
train
logic-ng/LogicNG
src/main/java/org/logicng/formulas/FormulaFactory.java
FormulaFactory.statistics
public FormulaFactoryStatistics statistics() { final FormulaFactoryStatistics statistics = new FormulaFactoryStatistics(); statistics.name = this.name; statistics.positiveLiterals = this.posLiterals.size(); statistics.negativeLiterals = this.negLiterals.size(); statistics.negations = this.nots.size(); statistics.implications = this.implications.size(); statistics.equivalences = this.equivalences.size(); statistics.conjunctions2 = this.ands2.size(); statistics.conjunctions3 = this.ands3.size(); statistics.conjunctions4 = this.ands4.size(); statistics.conjunctionsN = this.andsN.size(); statistics.disjunctions2 = this.ors2.size(); statistics.disjunctions3 = this.ors3.size(); statistics.disjunctions4 = this.ors4.size(); statistics.disjunctionsN = this.orsN.size(); statistics.pbcs = this.pbConstraints.size(); statistics.ccCounter = this.ccCounter; statistics.pbCounter = this.pbCounter; statistics.cnfCounter = this.cnfCounter; return statistics; }
java
public FormulaFactoryStatistics statistics() { final FormulaFactoryStatistics statistics = new FormulaFactoryStatistics(); statistics.name = this.name; statistics.positiveLiterals = this.posLiterals.size(); statistics.negativeLiterals = this.negLiterals.size(); statistics.negations = this.nots.size(); statistics.implications = this.implications.size(); statistics.equivalences = this.equivalences.size(); statistics.conjunctions2 = this.ands2.size(); statistics.conjunctions3 = this.ands3.size(); statistics.conjunctions4 = this.ands4.size(); statistics.conjunctionsN = this.andsN.size(); statistics.disjunctions2 = this.ors2.size(); statistics.disjunctions3 = this.ors3.size(); statistics.disjunctions4 = this.ors4.size(); statistics.disjunctionsN = this.orsN.size(); statistics.pbcs = this.pbConstraints.size(); statistics.ccCounter = this.ccCounter; statistics.pbCounter = this.pbCounter; statistics.cnfCounter = this.cnfCounter; return statistics; }
[ "public", "FormulaFactoryStatistics", "statistics", "(", ")", "{", "final", "FormulaFactoryStatistics", "statistics", "=", "new", "FormulaFactoryStatistics", "(", ")", ";", "statistics", ".", "name", "=", "this", ".", "name", ";", "statistics", ".", "positiveLiteral...
Returns the statistics for this formula factory. @return the statistics for this formula factory
[ "Returns", "the", "statistics", "for", "this", "formula", "factory", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L1060-L1081
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.luby
protected static long luby(final long i) { long res = 0; long k; for (k = 1; res == 0 && k < 64; k++) { if (i == (1L << k) - 1) { res = 1L << (k - 1); } } k = 1; while (res == 0) { if ((1L << (k - 1)) <= i && i < (1L << k) - 1) { res = luby(i - (1L << (k - 1)) + 1); } k++; } return res; }
java
protected static long luby(final long i) { long res = 0; long k; for (k = 1; res == 0 && k < 64; k++) { if (i == (1L << k) - 1) { res = 1L << (k - 1); } } k = 1; while (res == 0) { if ((1L << (k - 1)) <= i && i < (1L << k) - 1) { res = luby(i - (1L << (k - 1)) + 1); } k++; } return res; }
[ "protected", "static", "long", "luby", "(", "final", "long", "i", ")", "{", "long", "res", "=", "0", ";", "long", "k", ";", "for", "(", "k", "=", "1", ";", "res", "==", "0", "&&", "k", "<", "64", ";", "k", "++", ")", "{", "if", "(", "i", ...
Returns the next number in the luby sequence. @param i the base value @return the next number in the luby sequence
[ "Returns", "the", "next", "number", "in", "the", "luby", "sequence", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L124-L136
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.importLit
protected void importLit(final int lit) { final int idx = Math.abs(lit); assert lit != 0; int newIdx; while (idx >= (newIdx = this.vars.size())) { this.vars.push(new CLVar()); this.vals.push((byte) 0); this.phases.push((byte) 1); this.watches.push(new LNGVector<CLWatch>()); this.watches.push(new LNGVector<CLWatch>()); if (newIdx == 0) { continue; } this.decisions.push(newIdx); } }
java
protected void importLit(final int lit) { final int idx = Math.abs(lit); assert lit != 0; int newIdx; while (idx >= (newIdx = this.vars.size())) { this.vars.push(new CLVar()); this.vals.push((byte) 0); this.phases.push((byte) 1); this.watches.push(new LNGVector<CLWatch>()); this.watches.push(new LNGVector<CLWatch>()); if (newIdx == 0) { continue; } this.decisions.push(newIdx); } }
[ "protected", "void", "importLit", "(", "final", "int", "lit", ")", "{", "final", "int", "idx", "=", "Math", ".", "abs", "(", "lit", ")", ";", "assert", "lit", "!=", "0", ";", "int", "newIdx", ";", "while", "(", "idx", ">=", "(", "newIdx", "=", "t...
Imports a given literal. @param lit the literal
[ "Imports", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L206-L219
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.var
protected CLVar var(final int lit) { final int idx = Math.abs(lit); assert 0 < idx && idx < this.vars.size(); return this.vars.get(idx); }
java
protected CLVar var(final int lit) { final int idx = Math.abs(lit); assert 0 < idx && idx < this.vars.size(); return this.vars.get(idx); }
[ "protected", "CLVar", "var", "(", "final", "int", "lit", ")", "{", "final", "int", "idx", "=", "Math", ".", "abs", "(", "lit", ")", ";", "assert", "0", "<", "idx", "&&", "idx", "<", "this", ".", "vars", ".", "size", "(", ")", ";", "return", "th...
Returns the variable for a given literal. @param lit the literal @return the variable for the literal
[ "Returns", "the", "variable", "for", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L277-L281
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.val
protected byte val(final int lit) { byte res = this.vals.get(Math.abs(lit)); if (lit < 0) { res = (byte) -res; } return res; }
java
protected byte val(final int lit) { byte res = this.vals.get(Math.abs(lit)); if (lit < 0) { res = (byte) -res; } return res; }
[ "protected", "byte", "val", "(", "final", "int", "lit", ")", "{", "byte", "res", "=", "this", ".", "vals", ".", "get", "(", "Math", ".", "abs", "(", "lit", ")", ")", ";", "if", "(", "lit", "<", "0", ")", "{", "res", "=", "(", "byte", ")", "...
Returns the value for a given literal. @param lit the literal @return the value as byte (-1 = false, 1 = true)
[ "Returns", "the", "value", "for", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L288-L292
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.mark
protected void mark(final int lit) { final CLVar v = var(lit); assert v.mark() == 0; v.setMark(sign(lit)); this.seen.push(lit); }
java
protected void mark(final int lit) { final CLVar v = var(lit); assert v.mark() == 0; v.setMark(sign(lit)); this.seen.push(lit); }
[ "protected", "void", "mark", "(", "final", "int", "lit", ")", "{", "final", "CLVar", "v", "=", "var", "(", "lit", ")", ";", "assert", "v", ".", "mark", "(", ")", "==", "0", ";", "v", ".", "setMark", "(", "sign", "(", "lit", ")", ")", ";", "th...
Marks a given literal. @param lit the literal
[ "Marks", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L308-L313
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.unmark
protected void unmark(final int level) { assert level <= this.seen.size(); while (level < this.seen.size()) { final int lit = this.seen.back(); this.seen.pop(); final CLVar v = var(lit); assert v.mark() == sign(lit); v.setMark(0); } }
java
protected void unmark(final int level) { assert level <= this.seen.size(); while (level < this.seen.size()) { final int lit = this.seen.back(); this.seen.pop(); final CLVar v = var(lit); assert v.mark() == sign(lit); v.setMark(0); } }
[ "protected", "void", "unmark", "(", "final", "int", "level", ")", "{", "assert", "level", "<=", "this", ".", "seen", ".", "size", "(", ")", ";", "while", "(", "level", "<", "this", ".", "seen", ".", "size", "(", ")", ")", "{", "final", "int", "li...
Unmarks all variables up to a given level @param level the level
[ "Unmarks", "all", "variables", "up", "to", "a", "given", "level" ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L326-L335
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.addWatch
protected void addWatch(final int lit, final int blit, final boolean binary, final CLClause clause) { watches(lit).push(new CLWatch(blit, binary, clause)); }
java
protected void addWatch(final int lit, final int blit, final boolean binary, final CLClause clause) { watches(lit).push(new CLWatch(blit, binary, clause)); }
[ "protected", "void", "addWatch", "(", "final", "int", "lit", ",", "final", "int", "blit", ",", "final", "boolean", "binary", ",", "final", "CLClause", "clause", ")", "{", "watches", "(", "lit", ")", ".", "push", "(", "new", "CLWatch", "(", "blit", ",",...
Adds a new watcher for a given literal. @param lit the literal @param blit the blocking literal @param binary indicates whether it is a binary clause or not @param clause the watched clause
[ "Adds", "a", "new", "watcher", "for", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L353-L355
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.markFrame
protected boolean markFrame(final int lit) { final int currentlevel = var(lit).level(); final CLFrame frame = this.control.get(currentlevel); if (frame.mark()) { return false; } frame.setMark(true); this.frames.push(currentlevel); return true; }
java
protected boolean markFrame(final int lit) { final int currentlevel = var(lit).level(); final CLFrame frame = this.control.get(currentlevel); if (frame.mark()) { return false; } frame.setMark(true); this.frames.push(currentlevel); return true; }
[ "protected", "boolean", "markFrame", "(", "final", "int", "lit", ")", "{", "final", "int", "currentlevel", "=", "var", "(", "lit", ")", ".", "level", "(", ")", ";", "final", "CLFrame", "frame", "=", "this", ".", "control", ".", "get", "(", "currentleve...
Marks the frame for a given literal's decision level. @param lit the literal @return {@code true} if the frame was newly marked, {@code false} if the frame was already marked
[ "Marks", "the", "frame", "for", "a", "given", "literal", "s", "decision", "level", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L362-L369
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.unmarkFrames
protected int unmarkFrames() { final int res = this.frames.size(); while (!this.frames.empty()) { final CLFrame f = this.control.get(this.frames.back()); this.frames.pop(); assert f.mark(); f.setMark(false); } return res; }
java
protected int unmarkFrames() { final int res = this.frames.size(); while (!this.frames.empty()) { final CLFrame f = this.control.get(this.frames.back()); this.frames.pop(); assert f.mark(); f.setMark(false); } return res; }
[ "protected", "int", "unmarkFrames", "(", ")", "{", "final", "int", "res", "=", "this", ".", "frames", ".", "size", "(", ")", ";", "while", "(", "!", "this", ".", "frames", ".", "empty", "(", ")", ")", "{", "final", "CLFrame", "f", "=", "this", "....
Unmarks all frames. @return the number of unmarked frames
[ "Unmarks", "all", "frames", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L375-L384
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.backtrack
protected void backtrack(final int newLevel) { assert 0 <= newLevel && newLevel <= this.level; if (newLevel == this.level) { return; } CLFrame f = this.control.back(); while (f.level() > newLevel) { assert f.level() == this.level; assert f.trail() < this.trail.size(); while (f.trail() < this.trail.size()) { final int lit = this.trail.back(); assert var(lit).level() == f.level(); this.trail.pop(); unassign(lit); } assert this.level > 0; this.level--; this.trail.shrinkTo(f.trail()); this.next = f.trail(); this.control.pop(); f = this.control.back(); } assert newLevel == this.level; }
java
protected void backtrack(final int newLevel) { assert 0 <= newLevel && newLevel <= this.level; if (newLevel == this.level) { return; } CLFrame f = this.control.back(); while (f.level() > newLevel) { assert f.level() == this.level; assert f.trail() < this.trail.size(); while (f.trail() < this.trail.size()) { final int lit = this.trail.back(); assert var(lit).level() == f.level(); this.trail.pop(); unassign(lit); } assert this.level > 0; this.level--; this.trail.shrinkTo(f.trail()); this.next = f.trail(); this.control.pop(); f = this.control.back(); } assert newLevel == this.level; }
[ "protected", "void", "backtrack", "(", "final", "int", "newLevel", ")", "{", "assert", "0", "<=", "newLevel", "&&", "newLevel", "<=", "this", ".", "level", ";", "if", "(", "newLevel", "==", "this", ".", "level", ")", "{", "return", ";", "}", "CLFrame",...
Backtracks to a given level @param newLevel the level
[ "Backtracks", "to", "a", "given", "level" ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L397-L418
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.rescore
protected void rescore() { double maxScore = this.scoreIncrement; for (int idx = 1; idx < this.vars.size(); idx++) { final double p = this.decisions.priority(idx); if (p > maxScore) { maxScore = p; } } final double factor = 1 / maxScore; this.decisions.rescore(factor); this.scoreIncrement *= factor; }
java
protected void rescore() { double maxScore = this.scoreIncrement; for (int idx = 1; idx < this.vars.size(); idx++) { final double p = this.decisions.priority(idx); if (p > maxScore) { maxScore = p; } } final double factor = 1 / maxScore; this.decisions.rescore(factor); this.scoreIncrement *= factor; }
[ "protected", "void", "rescore", "(", ")", "{", "double", "maxScore", "=", "this", ".", "scoreIncrement", ";", "for", "(", "int", "idx", "=", "1", ";", "idx", "<", "this", ".", "vars", ".", "size", "(", ")", ";", "idx", "++", ")", "{", "final", "d...
Rescores all variables.
[ "Rescores", "all", "variables", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L444-L453
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.bumpLit
protected void bumpLit(final int lit) { final double maxPriority = 1e300; final int idx = Math.abs(lit); double oldPriority; if (this.scoreIncrement > maxPriority || (oldPriority = this.decisions.priority(idx)) > maxPriority) { rescore(); oldPriority = this.decisions.priority(idx); } final double newPriority = oldPriority + this.scoreIncrement; this.decisions.update(idx, newPriority); }
java
protected void bumpLit(final int lit) { final double maxPriority = 1e300; final int idx = Math.abs(lit); double oldPriority; if (this.scoreIncrement > maxPriority || (oldPriority = this.decisions.priority(idx)) > maxPriority) { rescore(); oldPriority = this.decisions.priority(idx); } final double newPriority = oldPriority + this.scoreIncrement; this.decisions.update(idx, newPriority); }
[ "protected", "void", "bumpLit", "(", "final", "int", "lit", ")", "{", "final", "double", "maxPriority", "=", "1e300", ";", "final", "int", "idx", "=", "Math", ".", "abs", "(", "lit", ")", ";", "double", "oldPriority", ";", "if", "(", "this", ".", "sc...
Bump a literal's activity. @param lit the literal
[ "Bump", "a", "literal", "s", "activity", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L459-L469
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.pullLit
protected boolean pullLit(final int lit) { if (val(lit) == VALUE_TRUE) { return false; } if (marked(lit) != 0) { return false; } mark(lit); bumpLit(lit); if (var(lit).level() == this.level) { return true; } markFrame(lit); this.addedlits.push(lit); return false; }
java
protected boolean pullLit(final int lit) { if (val(lit) == VALUE_TRUE) { return false; } if (marked(lit) != 0) { return false; } mark(lit); bumpLit(lit); if (var(lit).level() == this.level) { return true; } markFrame(lit); this.addedlits.push(lit); return false; }
[ "protected", "boolean", "pullLit", "(", "final", "int", "lit", ")", "{", "if", "(", "val", "(", "lit", ")", "==", "VALUE_TRUE", ")", "{", "return", "false", ";", "}", "if", "(", "marked", "(", "lit", ")", "!=", "0", ")", "{", "return", "false", "...
Analyzes a given literal. @param lit the literal @return the result of the analysis
[ "Analyzes", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L476-L485
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.minimizeLit
protected boolean minimizeLit(final int root) { assert marked(root) != 0; CLClause reason = var(root).reason(); if (reason == null) { return false; } final int oldSeenSize = this.seen.size(); int nextSeen = oldSeenSize; boolean res = true; int lit = root; while (true) { int other; for (int p = 0; res && p < reason.lits().size(); p++) { other = reason.lits().get(p); if (other == lit) { continue; } assert val(other) == VALUE_FALSE; if (marked(other) != 0) { continue; } final CLVar v = var(other); if (v.reason() == null) { res = false; } else if (!this.control.get(v.level()).mark()) { res = false; } else { mark(other); } } if (!res || nextSeen == this.seen.size()) { break; } lit = -this.seen.get(nextSeen++); reason = var(lit).reason(); assert reason != null; } if (!res) { unmark(oldSeenSize); } return res; }
java
protected boolean minimizeLit(final int root) { assert marked(root) != 0; CLClause reason = var(root).reason(); if (reason == null) { return false; } final int oldSeenSize = this.seen.size(); int nextSeen = oldSeenSize; boolean res = true; int lit = root; while (true) { int other; for (int p = 0; res && p < reason.lits().size(); p++) { other = reason.lits().get(p); if (other == lit) { continue; } assert val(other) == VALUE_FALSE; if (marked(other) != 0) { continue; } final CLVar v = var(other); if (v.reason() == null) { res = false; } else if (!this.control.get(v.level()).mark()) { res = false; } else { mark(other); } } if (!res || nextSeen == this.seen.size()) { break; } lit = -this.seen.get(nextSeen++); reason = var(lit).reason(); assert reason != null; } if (!res) { unmark(oldSeenSize); } return res; }
[ "protected", "boolean", "minimizeLit", "(", "final", "int", "root", ")", "{", "assert", "marked", "(", "root", ")", "!=", "0", ";", "CLClause", "reason", "=", "var", "(", "root", ")", ".", "reason", "(", ")", ";", "if", "(", "reason", "==", "null", ...
Minimize the first UIP clause by trying to remove a given literal. @param root the literal @return {@code true} if the literal can be removed, {@code false} otherwise
[ "Minimize", "the", "first", "UIP", "clause", "by", "trying", "to", "remove", "a", "given", "literal", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L492-L519
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.newRestartLimit
protected void newRestartLimit() { final long newInterval = this.config.restartint * luby(this.stats.restartsCount + 1); if (newInterval > this.limits.maxRestartInterval) { this.limits.maxRestartInterval = newInterval; } this.limits.restart = this.stats.conflicts + newInterval; }
java
protected void newRestartLimit() { final long newInterval = this.config.restartint * luby(this.stats.restartsCount + 1); if (newInterval > this.limits.maxRestartInterval) { this.limits.maxRestartInterval = newInterval; } this.limits.restart = this.stats.conflicts + newInterval; }
[ "protected", "void", "newRestartLimit", "(", ")", "{", "final", "long", "newInterval", "=", "this", ".", "config", ".", "restartint", "*", "luby", "(", "this", ".", "stats", ".", "restartsCount", "+", "1", ")", ";", "if", "(", "newInterval", ">", "this",...
Computes a new restart limit.
[ "Computes", "a", "new", "restart", "limit", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L524-L528
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.assume
protected void assume(final int decision) { assert propagated(); this.level++; final int height = this.trail.size(); this.control.push(new CLFrame(decision, this.level, height)); assert this.level + 1 == this.control.size(); assign(decision, null); }
java
protected void assume(final int decision) { assert propagated(); this.level++; final int height = this.trail.size(); this.control.push(new CLFrame(decision, this.level, height)); assert this.level + 1 == this.control.size(); assign(decision, null); }
[ "protected", "void", "assume", "(", "final", "int", "decision", ")", "{", "assert", "propagated", "(", ")", ";", "this", ".", "level", "++", ";", "final", "int", "height", "=", "this", ".", "trail", ".", "size", "(", ")", ";", "this", ".", "control",...
Assumes a given decision. @param decision the decision
[ "Assumes", "a", "given", "decision", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L534-L541
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.decide
protected boolean decide() { assert propagated(); int decision = 0; while (decision == 0 && !this.decisions.empty()) { final int lit = this.decisions.top(); this.decisions.pop(lit); if (val(lit) == 0) { decision = lit; } } if (decision == 0) { return false; } assert decision > 0; if (this.phases.get(decision) < 0) { decision = -decision; } this.stats.decisions++; this.stats.levels += this.level; assume(decision); return true; }
java
protected boolean decide() { assert propagated(); int decision = 0; while (decision == 0 && !this.decisions.empty()) { final int lit = this.decisions.top(); this.decisions.pop(lit); if (val(lit) == 0) { decision = lit; } } if (decision == 0) { return false; } assert decision > 0; if (this.phases.get(decision) < 0) { decision = -decision; } this.stats.decisions++; this.stats.levels += this.level; assume(decision); return true; }
[ "protected", "boolean", "decide", "(", ")", "{", "assert", "propagated", "(", ")", ";", "int", "decision", "=", "0", ";", "while", "(", "decision", "==", "0", "&&", "!", "this", ".", "decisions", ".", "empty", "(", ")", ")", "{", "final", "int", "l...
Checks if there are unassigned literals left. @return {@code false} if all literals are assigned, {@code true} otherwise
[ "Checks", "if", "there", "are", "unassigned", "literals", "left", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L547-L562
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java
CleaneLingStyleSolver.upZeroLiterals
public LNGIntVector upZeroLiterals() { final LNGIntVector upZeroLiterals = new LNGIntVector(); for (int i = 0; i < this.trail.size(); ++i) { final int lit = this.trail.get(i); if (var(lit).level() > 0) { break; } else { upZeroLiterals.push(lit); } } return upZeroLiterals; }
java
public LNGIntVector upZeroLiterals() { final LNGIntVector upZeroLiterals = new LNGIntVector(); for (int i = 0; i < this.trail.size(); ++i) { final int lit = this.trail.get(i); if (var(lit).level() > 0) { break; } else { upZeroLiterals.push(lit); } } return upZeroLiterals; }
[ "public", "LNGIntVector", "upZeroLiterals", "(", ")", "{", "final", "LNGIntVector", "upZeroLiterals", "=", "new", "LNGIntVector", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "trail", ".", "size", "(", ")", ";", "++", ...
Returns the unit propagated literals on level zero. @return unit propagated literal on level zero
[ "Returns", "the", "unit", "propagated", "literals", "on", "level", "zero", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/sat/CleaneLingStyleSolver.java#L679-L690
train
logic-ng/LogicNG
src/main/java/org/logicng/bdds/io/BDDDotFileWriter.java
BDDDotFileWriter.write
public static void write(final String fileName, final BDD bdd) throws IOException { write(new File(fileName.endsWith(".dot") ? fileName : fileName + ".dot"), bdd); }
java
public static void write(final String fileName, final BDD bdd) throws IOException { write(new File(fileName.endsWith(".dot") ? fileName : fileName + ".dot"), bdd); }
[ "public", "static", "void", "write", "(", "final", "String", "fileName", ",", "final", "BDD", "bdd", ")", "throws", "IOException", "{", "write", "(", "new", "File", "(", "fileName", ".", "endsWith", "(", "\".dot\"", ")", "?", "fileName", ":", "fileName", ...
Writes a given BDD as a dot file. @param fileName the file name of the dot file to write @param bdd the BDD @throws IOException if there was a problem writing the file
[ "Writes", "a", "given", "BDD", "as", "a", "dot", "file", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/bdds/io/BDDDotFileWriter.java#L61-L63
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/maxsat/encodings/ModularTotalizer.java
ModularTotalizer.encode
public void encode(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) { assert lits.size() > 0; hasEncoding = false; this.cardinalityUpoutlits.clear(); this.cardinalityLwoutlits.clear(); if (rhs == 0) { for (int i = 0; i < lits.size(); i++) addUnitClause(s, not(lits.get(i))); return; } assert rhs >= 1 && rhs <= lits.size(); if (rhs == lits.size()) return; hasEncoding = true; int mod = (int) Math.ceil(Math.sqrt(rhs + 1.0)); if (this.modulo == -1) this.modulo = mod; else mod = this.modulo; for (int i = 0; i < lits.size() / mod; i++) { final int p = mkLit(s.nVars(), false); MaxSAT.newSATVariable(s); this.cardinalityUpoutlits.push(p); } for (int i = 0; i < mod - 1; i++) { int p = mkLit(s.nVars(), false); MaxSAT.newSATVariable(s); this.cardinalityLwoutlits.push(p); } this.cardinalityInlits = new LNGIntVector(lits); this.currentCardinalityRhs = rhs + 1; if (this.cardinalityUpoutlits.size() == 0) this.cardinalityUpoutlits.push(this.h0); this.toCNF(s, mod, this.cardinalityUpoutlits, this.cardinalityLwoutlits, lits.size()); assert this.cardinalityInlits.size() == 0; this.update(s, rhs); }
java
public void encode(final MiniSatStyleSolver s, final LNGIntVector lits, int rhs) { assert lits.size() > 0; hasEncoding = false; this.cardinalityUpoutlits.clear(); this.cardinalityLwoutlits.clear(); if (rhs == 0) { for (int i = 0; i < lits.size(); i++) addUnitClause(s, not(lits.get(i))); return; } assert rhs >= 1 && rhs <= lits.size(); if (rhs == lits.size()) return; hasEncoding = true; int mod = (int) Math.ceil(Math.sqrt(rhs + 1.0)); if (this.modulo == -1) this.modulo = mod; else mod = this.modulo; for (int i = 0; i < lits.size() / mod; i++) { final int p = mkLit(s.nVars(), false); MaxSAT.newSATVariable(s); this.cardinalityUpoutlits.push(p); } for (int i = 0; i < mod - 1; i++) { int p = mkLit(s.nVars(), false); MaxSAT.newSATVariable(s); this.cardinalityLwoutlits.push(p); } this.cardinalityInlits = new LNGIntVector(lits); this.currentCardinalityRhs = rhs + 1; if (this.cardinalityUpoutlits.size() == 0) this.cardinalityUpoutlits.push(this.h0); this.toCNF(s, mod, this.cardinalityUpoutlits, this.cardinalityLwoutlits, lits.size()); assert this.cardinalityInlits.size() == 0; this.update(s, rhs); }
[ "public", "void", "encode", "(", "final", "MiniSatStyleSolver", "s", ",", "final", "LNGIntVector", "lits", ",", "int", "rhs", ")", "{", "assert", "lits", ".", "size", "(", ")", ">", "0", ";", "hasEncoding", "=", "false", ";", "this", ".", "cardinalityUpo...
Encodes a cardinality constraint. @param s the solver @param lits the literals of the constraint @param rhs the right hand side of the constraint
[ "Encodes", "a", "cardinality", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/ModularTotalizer.java#L111-L147
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/maxsat/encodings/ModularTotalizer.java
ModularTotalizer.update
public void update(final MiniSatStyleSolver s, int rhs) { assert this.currentCardinalityRhs != -1; assert hasEncoding; this.encodeOutput(s, rhs); this.currentCardinalityRhs = rhs + 1; }
java
public void update(final MiniSatStyleSolver s, int rhs) { assert this.currentCardinalityRhs != -1; assert hasEncoding; this.encodeOutput(s, rhs); this.currentCardinalityRhs = rhs + 1; }
[ "public", "void", "update", "(", "final", "MiniSatStyleSolver", "s", ",", "int", "rhs", ")", "{", "assert", "this", ".", "currentCardinalityRhs", "!=", "-", "1", ";", "assert", "hasEncoding", ";", "this", ".", "encodeOutput", "(", "s", ",", "rhs", ")", "...
Updates the right hand side of the current constraint. @param s the solver @param rhs the new right hand side
[ "Updates", "the", "right", "hand", "side", "of", "the", "current", "constraint", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/maxsat/encodings/ModularTotalizer.java#L154-L159
train
logic-ng/LogicNG
src/main/java/org/logicng/solvers/datastructures/LNGBoundedLongQueue.java
LNGBoundedLongQueue.push
public void push(long x) { if (this.queueSize == this.maxSize) { assert this.last == this.first; this.sumOfQueue -= this.elems.get(this.last); if ((++this.last) == this.maxSize) this.last = 0; } else this.queueSize++; this.sumOfQueue += x; this.elems.set(this.first, x); if ((++this.first) == this.maxSize) { this.first = 0; this.last = 0; } }
java
public void push(long x) { if (this.queueSize == this.maxSize) { assert this.last == this.first; this.sumOfQueue -= this.elems.get(this.last); if ((++this.last) == this.maxSize) this.last = 0; } else this.queueSize++; this.sumOfQueue += x; this.elems.set(this.first, x); if ((++this.first) == this.maxSize) { this.first = 0; this.last = 0; } }
[ "public", "void", "push", "(", "long", "x", ")", "{", "if", "(", "this", ".", "queueSize", "==", "this", ".", "maxSize", ")", "{", "assert", "this", ".", "last", "==", "this", ".", "first", ";", "this", ".", "sumOfQueue", "-=", "this", ".", "elems"...
Pushes a new element to the queue. @param x the new element
[ "Pushes", "a", "new", "element", "to", "the", "queue", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/datastructures/LNGBoundedLongQueue.java#L119-L133
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Collection<Formula> formulas, final Collection<Variable> variables, final BackboneType type) { solver.reset(); solver.add(formulas); return solver.compute(variables, type); }
java
public static Backbone compute(final Collection<Formula> formulas, final Collection<Variable> variables, final BackboneType type) { solver.reset(); solver.add(formulas); return solver.compute(variables, type); }
[ "public", "static", "Backbone", "compute", "(", "final", "Collection", "<", "Formula", ">", "formulas", ",", "final", "Collection", "<", "Variable", ">", "variables", ",", "final", "BackboneType", "type", ")", "{", "solver", ".", "reset", "(", ")", ";", "s...
Computes the backbone for a given collection of formulas w.r.t. a collection of variables and a backbone type. @param formulas the given collection of formulas @param variables the given collection of relevant variables for the backbone computation @param type the type of backbone variables that should be computed @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "backbone", "for", "a", "given", "collection", "of", "formulas", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "and", "a", "backbone", "type", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L83-L87
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Collection<Formula> formulas, final Collection<Variable> variables) { return compute(formulas, variables, BackboneType.POSITIVE_AND_NEGATIVE); }
java
public static Backbone compute(final Collection<Formula> formulas, final Collection<Variable> variables) { return compute(formulas, variables, BackboneType.POSITIVE_AND_NEGATIVE); }
[ "public", "static", "Backbone", "compute", "(", "final", "Collection", "<", "Formula", ">", "formulas", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "return", "compute", "(", "formulas", ",", "variables", ",", "BackboneType", ".", ...
Computes the complete backbone for a given collection of formulas w.r.t. a collection of variables and a backbone type. @param formulas the given collection of formulas @param variables the given collection of relevant variables for the backbone computation @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "complete", "backbone", "for", "a", "given", "collection", "of", "formulas", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "and", "a", "backbone", "type", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L95-L97
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Collection<Formula> formulas, final BackboneType type) { return compute(formulas, allVariablesInFormulas(formulas), type); }
java
public static Backbone compute(final Collection<Formula> formulas, final BackboneType type) { return compute(formulas, allVariablesInFormulas(formulas), type); }
[ "public", "static", "Backbone", "compute", "(", "final", "Collection", "<", "Formula", ">", "formulas", ",", "final", "BackboneType", "type", ")", "{", "return", "compute", "(", "formulas", ",", "allVariablesInFormulas", "(", "formulas", ")", ",", "type", ")",...
Computes the backbone for a given collection of formulas w.r.t. a given backbone type. @param formulas the given collection of formulas @param type the type of backbone variables that should be computed @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "backbone", "for", "a", "given", "collection", "of", "formulas", "w", ".", "r", ".", "t", ".", "a", "given", "backbone", "type", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L105-L107
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Collection<Formula> formulas) { return compute(formulas, allVariablesInFormulas(formulas), BackboneType.POSITIVE_AND_NEGATIVE); }
java
public static Backbone compute(final Collection<Formula> formulas) { return compute(formulas, allVariablesInFormulas(formulas), BackboneType.POSITIVE_AND_NEGATIVE); }
[ "public", "static", "Backbone", "compute", "(", "final", "Collection", "<", "Formula", ">", "formulas", ")", "{", "return", "compute", "(", "formulas", ",", "allVariablesInFormulas", "(", "formulas", ")", ",", "BackboneType", ".", "POSITIVE_AND_NEGATIVE", ")", "...
Computes the complete backbone for a given collection of formulas. @param formulas the given collection of formulas @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "complete", "backbone", "for", "a", "given", "collection", "of", "formulas", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L114-L116
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Formula formula, final Collection<Variable> variables, final BackboneType type) { return compute(Collections.singletonList(formula), variables, type); }
java
public static Backbone compute(final Formula formula, final Collection<Variable> variables, final BackboneType type) { return compute(Collections.singletonList(formula), variables, type); }
[ "public", "static", "Backbone", "compute", "(", "final", "Formula", "formula", ",", "final", "Collection", "<", "Variable", ">", "variables", ",", "final", "BackboneType", "type", ")", "{", "return", "compute", "(", "Collections", ".", "singletonList", "(", "f...
Computes the backbone for a given formula w.r.t. a collection of variables and a backbone type. @param formula the given formula @param variables the given collection of relevant variables for the backbone computation @param type the type of backbone variables that should be computed @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "backbone", "for", "a", "given", "formula", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "and", "a", "backbone", "type", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L125-L127
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Formula formula, final Collection<Variable> variables) { return compute(formula, variables, BackboneType.POSITIVE_AND_NEGATIVE); }
java
public static Backbone compute(final Formula formula, final Collection<Variable> variables) { return compute(formula, variables, BackboneType.POSITIVE_AND_NEGATIVE); }
[ "public", "static", "Backbone", "compute", "(", "final", "Formula", "formula", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "return", "compute", "(", "formula", ",", "variables", ",", "BackboneType", ".", "POSITIVE_AND_NEGATIVE", ")",...
Computes the complete backbone for a given formula w.r.t. a collection of variables and a backbone type. @param formula the given formula @param variables the given collection of relevant variables for the backbone computation @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "complete", "backbone", "for", "a", "given", "formula", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "and", "a", "backbone", "type", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L135-L137
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Formula formula, final BackboneType type) { return compute(formula, formula.variables(), type); }
java
public static Backbone compute(final Formula formula, final BackboneType type) { return compute(formula, formula.variables(), type); }
[ "public", "static", "Backbone", "compute", "(", "final", "Formula", "formula", ",", "final", "BackboneType", "type", ")", "{", "return", "compute", "(", "formula", ",", "formula", ".", "variables", "(", ")", ",", "type", ")", ";", "}" ]
Computes the backbone for a given formula w.r.t. a given backbone type. @param formula the given formula @param type the type of backbone variables that should be computed @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "backbone", "for", "a", "given", "formula", "w", ".", "r", ".", "t", ".", "a", "given", "backbone", "type", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L145-L147
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.compute
public static Backbone compute(final Formula formula) { return compute(formula, formula.variables(), BackboneType.POSITIVE_AND_NEGATIVE); }
java
public static Backbone compute(final Formula formula) { return compute(formula, formula.variables(), BackboneType.POSITIVE_AND_NEGATIVE); }
[ "public", "static", "Backbone", "compute", "(", "final", "Formula", "formula", ")", "{", "return", "compute", "(", "formula", ",", "formula", ".", "variables", "(", ")", ",", "BackboneType", ".", "POSITIVE_AND_NEGATIVE", ")", ";", "}" ]
Computes the complete backbone for a given formula. @param formula the given formula @return the backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "complete", "backbone", "for", "a", "given", "formula", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L154-L156
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computePositive
public static Backbone computePositive(final Collection<Formula> formulas, final Collection<Variable> variables) { return compute(formulas, variables, BackboneType.ONLY_POSITIVE); }
java
public static Backbone computePositive(final Collection<Formula> formulas, final Collection<Variable> variables) { return compute(formulas, variables, BackboneType.ONLY_POSITIVE); }
[ "public", "static", "Backbone", "computePositive", "(", "final", "Collection", "<", "Formula", ">", "formulas", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "return", "compute", "(", "formulas", ",", "variables", ",", "BackboneType", ...
Computes the positive backbone variables for a given collection of formulas w.r.t. a collection of variables. @param formulas the given collection of formulas @param variables the given collection of relevant variables for the backbone computation @return the positive backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "positive", "backbone", "variables", "for", "a", "given", "collection", "of", "formulas", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L164-L166
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computePositive
public static Backbone computePositive(final Collection<Formula> formulas) { return compute(formulas, allVariablesInFormulas(formulas), BackboneType.ONLY_POSITIVE); }
java
public static Backbone computePositive(final Collection<Formula> formulas) { return compute(formulas, allVariablesInFormulas(formulas), BackboneType.ONLY_POSITIVE); }
[ "public", "static", "Backbone", "computePositive", "(", "final", "Collection", "<", "Formula", ">", "formulas", ")", "{", "return", "compute", "(", "formulas", ",", "allVariablesInFormulas", "(", "formulas", ")", ",", "BackboneType", ".", "ONLY_POSITIVE", ")", "...
Computes the positive backbone variables for a given collection of formulas. @param formulas the given collection of formulas @return the positive backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "positive", "backbone", "variables", "for", "a", "given", "collection", "of", "formulas", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L173-L175
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computePositive
public static Backbone computePositive(final Formula formula, final Collection<Variable> variables) { return compute(formula, variables, BackboneType.ONLY_POSITIVE); }
java
public static Backbone computePositive(final Formula formula, final Collection<Variable> variables) { return compute(formula, variables, BackboneType.ONLY_POSITIVE); }
[ "public", "static", "Backbone", "computePositive", "(", "final", "Formula", "formula", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "return", "compute", "(", "formula", ",", "variables", ",", "BackboneType", ".", "ONLY_POSITIVE", ")",...
Computes the positive backbone allVariablesInFormulas for a given formula w.r.t. a collection of variables. @param formula the given formula @param variables the given collection of relevant variables for the backbone computation @return the positive backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "positive", "backbone", "allVariablesInFormulas", "for", "a", "given", "formula", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L183-L185
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computePositive
public static Backbone computePositive(final Formula formula) { return compute(formula, formula.variables(), BackboneType.ONLY_POSITIVE); }
java
public static Backbone computePositive(final Formula formula) { return compute(formula, formula.variables(), BackboneType.ONLY_POSITIVE); }
[ "public", "static", "Backbone", "computePositive", "(", "final", "Formula", "formula", ")", "{", "return", "compute", "(", "formula", ",", "formula", ".", "variables", "(", ")", ",", "BackboneType", ".", "ONLY_POSITIVE", ")", ";", "}" ]
Computes the positive backbone variables for a given formula. @param formula the given formula @return the positive backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "positive", "backbone", "variables", "for", "a", "given", "formula", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L192-L194
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computeNegative
public static Backbone computeNegative(final Collection<Formula> formulas, final Collection<Variable> variables) { return compute(formulas, variables, BackboneType.ONLY_NEGATIVE); }
java
public static Backbone computeNegative(final Collection<Formula> formulas, final Collection<Variable> variables) { return compute(formulas, variables, BackboneType.ONLY_NEGATIVE); }
[ "public", "static", "Backbone", "computeNegative", "(", "final", "Collection", "<", "Formula", ">", "formulas", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "return", "compute", "(", "formulas", ",", "variables", ",", "BackboneType", ...
Computes the negative backbone variables for a given collection of formulas w.r.t. a collection of variables. @param formulas the given collection of formulas @param variables the given collection of relevant variables for the backbone computation @return the negative backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "negative", "backbone", "variables", "for", "a", "given", "collection", "of", "formulas", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L202-L204
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computeNegative
public static Backbone computeNegative(final Collection<Formula> formulas) { return compute(formulas, allVariablesInFormulas(formulas), BackboneType.ONLY_NEGATIVE); }
java
public static Backbone computeNegative(final Collection<Formula> formulas) { return compute(formulas, allVariablesInFormulas(formulas), BackboneType.ONLY_NEGATIVE); }
[ "public", "static", "Backbone", "computeNegative", "(", "final", "Collection", "<", "Formula", ">", "formulas", ")", "{", "return", "compute", "(", "formulas", ",", "allVariablesInFormulas", "(", "formulas", ")", ",", "BackboneType", ".", "ONLY_NEGATIVE", ")", "...
Computes the negative backbone variables for a given collection of formulas. @param formulas the given collection of formulas @return the negative backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "negative", "backbone", "variables", "for", "a", "given", "collection", "of", "formulas", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L211-L213
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computeNegative
public static Backbone computeNegative(final Formula formula, final Collection<Variable> variables) { return compute(formula, variables, BackboneType.ONLY_NEGATIVE); }
java
public static Backbone computeNegative(final Formula formula, final Collection<Variable> variables) { return compute(formula, variables, BackboneType.ONLY_NEGATIVE); }
[ "public", "static", "Backbone", "computeNegative", "(", "final", "Formula", "formula", ",", "final", "Collection", "<", "Variable", ">", "variables", ")", "{", "return", "compute", "(", "formula", ",", "variables", ",", "BackboneType", ".", "ONLY_NEGATIVE", ")",...
Computes the negative backbone variables for a given formula w.r.t. a collection of variables. @param formula the given formula @param variables the given collection of relevant variables for the backbone computation @return the negative backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "negative", "backbone", "variables", "for", "a", "given", "formula", "w", ".", "r", ".", "t", ".", "a", "collection", "of", "variables", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L221-L223
train
logic-ng/LogicNG
src/main/java/org/logicng/backbones/BackboneGeneration.java
BackboneGeneration.computeNegative
public static Backbone computeNegative(final Formula formula) { return compute(formula, formula.variables(), BackboneType.ONLY_NEGATIVE); }
java
public static Backbone computeNegative(final Formula formula) { return compute(formula, formula.variables(), BackboneType.ONLY_NEGATIVE); }
[ "public", "static", "Backbone", "computeNegative", "(", "final", "Formula", "formula", ")", "{", "return", "compute", "(", "formula", ",", "formula", ".", "variables", "(", ")", ",", "BackboneType", ".", "ONLY_NEGATIVE", ")", ";", "}" ]
Computes the negative backbone variables for a given formula. @param formula the given formula @return the negative backbone or {@code null} if the formula is UNSAT
[ "Computes", "the", "negative", "backbone", "variables", "for", "a", "given", "formula", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L230-L232
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGVector.java
LNGVector.push
public void push(final T element) { int newSize = this.size + 1; this.ensure(newSize); this.elements[this.size++] = element; }
java
public void push(final T element) { int newSize = this.size + 1; this.ensure(newSize); this.elements[this.size++] = element; }
[ "public", "void", "push", "(", "final", "T", "element", ")", "{", "int", "newSize", "=", "this", ".", "size", "+", "1", ";", "this", ".", "ensure", "(", "newSize", ")", ";", "this", ".", "elements", "[", "this", ".", "size", "++", "]", "=", "elem...
Pushes an element at the end of the vector. @param element the element
[ "Pushes", "an", "element", "at", "the", "end", "of", "the", "vector", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGVector.java#L127-L131
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGVector.java
LNGVector.shrinkTo
public void shrinkTo(int newSize) { if (newSize < this.size) { for (int i = this.size; i > newSize; i--) this.elements[i - 1] = null; this.size = newSize; } }
java
public void shrinkTo(int newSize) { if (newSize < this.size) { for (int i = this.size; i > newSize; i--) this.elements[i - 1] = null; this.size = newSize; } }
[ "public", "void", "shrinkTo", "(", "int", "newSize", ")", "{", "if", "(", "newSize", "<", "this", ".", "size", ")", "{", "for", "(", "int", "i", "=", "this", ".", "size", ";", "i", ">", "newSize", ";", "i", "--", ")", "this", ".", "elements", "...
Shrinks the vector to a given size if the new size is less then the current size. Otherwise the size remains the same. @param newSize the new size
[ "Shrinks", "the", "vector", "to", "a", "given", "size", "if", "the", "new", "size", "is", "less", "then", "the", "current", "size", ".", "Otherwise", "the", "size", "remains", "the", "same", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGVector.java#L174-L180
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGVector.java
LNGVector.replaceInplace
@SuppressWarnings("unchecked") public void replaceInplace(final LNGVector<? extends T> other) { if (this == other) throw new IllegalArgumentException("cannot replace a vector in-place with itself"); this.elements = (T[]) new Object[other.size()]; for (int i = 0; i < other.size(); i++) this.elements[i] = other.get(i); this.size = other.size; }
java
@SuppressWarnings("unchecked") public void replaceInplace(final LNGVector<? extends T> other) { if (this == other) throw new IllegalArgumentException("cannot replace a vector in-place with itself"); this.elements = (T[]) new Object[other.size()]; for (int i = 0; i < other.size(); i++) this.elements[i] = other.get(i); this.size = other.size; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "replaceInplace", "(", "final", "LNGVector", "<", "?", "extends", "T", ">", "other", ")", "{", "if", "(", "this", "==", "other", ")", "throw", "new", "IllegalArgumentException", "(", "\"ca...
Replaces the contents of this vector with the contents of another vector in-place. @param other the other vector @throws IllegalArgumentException if you try to replace a vector with itself
[ "Replaces", "the", "contents", "of", "this", "vector", "with", "the", "contents", "of", "another", "vector", "in", "-", "place", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGVector.java#L238-L246
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGVector.java
LNGVector.selectionSort
private void selectionSort(final T[] array, int start, int end, Comparator<T> lt) { int i; int j; int bestI; T tmp; for (i = start; i < end; i++) { bestI = i; for (j = i + 1; j < end; j++) { if (lt.compare(array[j], array[bestI]) < 0) bestI = j; } tmp = array[i]; array[i] = array[bestI]; array[bestI] = tmp; } }
java
private void selectionSort(final T[] array, int start, int end, Comparator<T> lt) { int i; int j; int bestI; T tmp; for (i = start; i < end; i++) { bestI = i; for (j = i + 1; j < end; j++) { if (lt.compare(array[j], array[bestI]) < 0) bestI = j; } tmp = array[i]; array[i] = array[bestI]; array[bestI] = tmp; } }
[ "private", "void", "selectionSort", "(", "final", "T", "[", "]", "array", ",", "int", "start", ",", "int", "end", ",", "Comparator", "<", "T", ">", "lt", ")", "{", "int", "i", ";", "int", "j", ";", "int", "bestI", ";", "T", "tmp", ";", "for", "...
Selection sort implementation for a given array. @param array the array @param start the start index for sorting @param end the end index for sorting @param lt the comparator for elements of the array
[ "Selection", "sort", "implementation", "for", "a", "given", "array", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGVector.java#L288-L303
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGVector.java
LNGVector.sort
private void sort(final T[] array, int start, int end, Comparator<T> lt) { if (start == end) return; if ((end - start) <= 15) this.selectionSort(array, start, end, lt); else { final T pivot = array[start + ((end - start) / 2)]; T tmp; int i = start - 1; int j = end; while (true) { do i++; while (lt.compare(array[i], pivot) < 0); do j--; while (lt.compare(pivot, array[j]) < 0); if (i >= j) break; tmp = array[i]; array[i] = array[j]; array[j] = tmp; } this.sort(array, start, i, lt); this.sort(array, i, end, lt); } }
java
private void sort(final T[] array, int start, int end, Comparator<T> lt) { if (start == end) return; if ((end - start) <= 15) this.selectionSort(array, start, end, lt); else { final T pivot = array[start + ((end - start) / 2)]; T tmp; int i = start - 1; int j = end; while (true) { do i++; while (lt.compare(array[i], pivot) < 0); do j--; while (lt.compare(pivot, array[j]) < 0); if (i >= j) break; tmp = array[i]; array[i] = array[j]; array[j] = tmp; } this.sort(array, start, i, lt); this.sort(array, i, end, lt); } }
[ "private", "void", "sort", "(", "final", "T", "[", "]", "array", ",", "int", "start", ",", "int", "end", ",", "Comparator", "<", "T", ">", "lt", ")", "{", "if", "(", "start", "==", "end", ")", "return", ";", "if", "(", "(", "end", "-", "start",...
Merge sort implementation for a given array. @param array the array @param start the start index for sorting @param end the end index for sorting @param lt the comparator for elements of the array
[ "Merge", "sort", "implementation", "for", "a", "given", "array", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGVector.java#L312-L338
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGBooleanVector.java
LNGBooleanVector.growTo
public void growTo(int size, boolean pad) { if (this.size >= size) return; this.ensure(size); for (int i = this.size; i < size; i++) this.elements[i] = pad; this.size = size; }
java
public void growTo(int size, boolean pad) { if (this.size >= size) return; this.ensure(size); for (int i = this.size; i < size; i++) this.elements[i] = pad; this.size = size; }
[ "public", "void", "growTo", "(", "int", "size", ",", "boolean", "pad", ")", "{", "if", "(", "this", ".", "size", ">=", "size", ")", "return", ";", "this", ".", "ensure", "(", "size", ")", ";", "for", "(", "int", "i", "=", "this", ".", "size", "...
Grows the vector to a new size and initializes the new elements with a given value. @param size the new size @param pad the value for new elements
[ "Grows", "the", "vector", "to", "a", "new", "size", "and", "initializes", "the", "new", "elements", "with", "a", "given", "value", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGBooleanVector.java#L176-L183
train
logic-ng/LogicNG
src/main/java/org/logicng/collections/LNGBooleanVector.java
LNGBooleanVector.reverseInplace
public void reverseInplace() { for (int i = 0; i < this.size / 2; i++) { boolean temp = this.elements[i]; this.elements[i] = this.elements[this.size - i - 1]; this.elements[this.size() - i - 1] = temp; } }
java
public void reverseInplace() { for (int i = 0; i < this.size / 2; i++) { boolean temp = this.elements[i]; this.elements[i] = this.elements[this.size - i - 1]; this.elements[this.size() - i - 1] = temp; } }
[ "public", "void", "reverseInplace", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "size", "/", "2", ";", "i", "++", ")", "{", "boolean", "temp", "=", "this", ".", "elements", "[", "i", "]", ";", "this", ".", "el...
Reverses the content of this vector in-place.
[ "Reverses", "the", "content", "of", "this", "vector", "in", "-", "place", "." ]
bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e
https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGBooleanVector.java#L199-L205
train
svenkubiak/embedded-mongodb
src/main/java/de/svenkubiak/embeddedmongodb/EmbeddedMongoDB.java
EmbeddedMongoDB.withVersion
public EmbeddedMongoDB withVersion(Version.Main version) { Objects.requireNonNull(version, "version can not be null"); this.version = version; return this; }
java
public EmbeddedMongoDB withVersion(Version.Main version) { Objects.requireNonNull(version, "version can not be null"); this.version = version; return this; }
[ "public", "EmbeddedMongoDB", "withVersion", "(", "Version", ".", "Main", "version", ")", "{", "Objects", ".", "requireNonNull", "(", "version", ",", "\"version can not be null\"", ")", ";", "this", ".", "version", "=", "version", ";", "return", "this", ";", "}...
Sets the version for the EmbeddedMongoDB instance Default is Version.Main.PRODUCTION @param version The version to set @return EmbeddedMongoDB instance
[ "Sets", "the", "version", "for", "the", "EmbeddedMongoDB", "instance" ]
c4394065bdce5917491a6537efdc808675047629
https://github.com/svenkubiak/embedded-mongodb/blob/c4394065bdce5917491a6537efdc808675047629/src/main/java/de/svenkubiak/embeddedmongodb/EmbeddedMongoDB.java#L73-L78
train