idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
7,400
public < T > T apply ( final FormulaFunction < T > function , final boolean cache ) { return function . apply ( this , cache ) ; }
Applies a given function on this formula and returns the result .
7,401
public Tristate predicateCacheEntry ( final CacheEntry key ) { final Tristate tristate = this . predicateCache . get ( key ) ; if ( tristate == null ) { return Tristate . UNDEF ; } return tristate ; }
Returns an entry of the predicate cache of this formula .
7,402
public void setPredicateCacheEntry ( final CacheEntry key , final boolean value ) { this . predicateCache . put ( key , Tristate . fromBool ( value ) ) ; }
Sets an entry in the predicate cache of this formula
7,403
static Tristate evaluateCoeffs ( final int minValue , final int maxValue , final int rhs , final CType comparator ) { int status = 0 ; if ( rhs >= minValue ) status ++ ; if ( rhs > minValue ) status ++ ; if ( rhs >= maxValue ) status ++ ; if ( rhs > maxValue ) status ++ ; switch ( comparator ) { case EQ : return ( stat...
Internal helper for checking if a given coefficient - sum min - and max - value can comply with a given right - hand - side according to this PBConstraint s comparator .
7,404
public Formula normalize ( ) { final LNGVector < Literal > normPs = new LNGVector < > ( this . literals . length ) ; final LNGIntVector normCs = new LNGIntVector ( this . literals . length ) ; int normRhs ; switch ( this . comparator ) { case EQ : for ( int i = 0 ; i < this . literals . length ; i ++ ) { normPs . push ...
Normalizes this constraint s . t . it can be converted to CNF .
7,405
private int evaluateLHS ( final Assignment assignment ) { int lhs = 0 ; for ( int i = 0 ; i < this . literals . length ; i ++ ) if ( this . literals [ i ] . evaluate ( assignment ) ) lhs += this . coefficients [ i ] ; return lhs ; }
Returns the evaluation of the left - hand side of this constraint .
7,406
private boolean evaluateComparator ( final int lhs ) { switch ( this . comparator ) { case EQ : return lhs == this . rhs ; case LE : return lhs <= this . rhs ; case LT : return lhs < this . rhs ; case GE : return lhs >= this . rhs ; case GT : return lhs > this . rhs ; default : throw new IllegalStateException ( "Unknow...
Computes the result of evaluating the comparator with a given left - hand side .
7,407
public static < T > void write ( final String fileName , Graph < T > g , boolean writeMapping ) throws IOException { File file = new File ( fileName . endsWith ( ".col" ) ? fileName : fileName + ".col" ) ; Map < Node < T > , Long > node2id = new LinkedHashMap < > ( ) ; long i = 1 ; for ( Node < T > node : g . nodes ( )...
Writes a given graph s internal data structure as a dimacs file .
7,408
public static CleaneLing minimalistic ( final FormulaFactory f ) { return new CleaneLing ( f , SolverStyle . MINIMALISTIC , new CleaneLingConfig . Builder ( ) . build ( ) ) ; }
Returns a new minimalistic CleaneLing solver .
7,409
public static CleaneLing minimalistic ( final FormulaFactory f , final CleaneLingConfig config ) { return new CleaneLing ( f , SolverStyle . MINIMALISTIC , config ) ; }
Returns a new minimalistic CleaneLing solver with a given configuration .
7,410
public static CleaneLing full ( final FormulaFactory f ) { return new CleaneLing ( f , SolverStyle . FULL , new CleaneLingConfig . Builder ( ) . build ( ) ) ; }
Returns a new full CleaneLing solver .
7,411
public static CleaneLing full ( final FormulaFactory f , final CleaneLingConfig config ) { return new CleaneLing ( f , SolverStyle . FULL , config ) ; }
Returns a new full CleaneLing solver with a given configuration .
7,412
private void addClause ( final Collection < Literal > literals ) { for ( final Literal lit : literals ) { Integer index = this . name2idx . get ( lit . variable ( ) . name ( ) ) ; if ( index == null ) { index = this . name2idx . size ( ) + 1 ; this . name2idx . put ( lit . variable ( ) . name ( ) , index ) ; this . idx...
Adds a collection of literals to the solver .
7,413
public int getOrCreateVarIndex ( final Variable var ) { Integer index = this . name2idx . get ( var . name ( ) ) ; if ( index == null ) { index = this . name2idx . size ( ) + 1 ; this . name2idx . put ( var . name ( ) , index ) ; this . idx2name . put ( index , var . name ( ) ) ; } return index ; }
Returns the existing internal solver index for a variable or creates a new one if the variable is yet unknown .
7,414
public String createNewVariableOnSolver ( final String prefix ) { final int index = this . name2idx . size ( ) + 1 ; final String varName = prefix + "_" + index ; this . name2idx . put ( varName , index ) ; this . idx2name . put ( index , varName ) ; return varName ; }
Creates a new variable on the solver and returns its name .
7,415
private LinkedHashSet < Formula > gatherAppliedOperands ( final NAryOperator operator ) { final LinkedHashSet < Formula > applied = new LinkedHashSet < > ( ) ; for ( final Formula operand : operator ) { applied . add ( apply ( operand , false ) ) ; } return applied ; }
Gather the operands of an n - ary operator and returns its applied operands .
7,416
public void setNumberOfVars ( final int num ) { if ( this . varnum != 0 ) throw new UnsupportedOperationException ( "Variable number is already set. Resetting it is not supported" ) ; if ( num < 1 || num > MAXVAR ) throw new IllegalArgumentException ( "Invalid variable number: " + num ) ; this . vars = new int [ num * ...
Sets the number of variables to use . It may be called more than one time but only to increase the number of variables .
7,417
private void delRef ( final int root ) { if ( root < 2 ) return ; if ( root >= this . nodesize ) throw new IllegalStateException ( "Cannot dereference a variable > varnum" ) ; if ( this . low ( root ) == - 1 ) throw new IllegalStateException ( "Cannot dereference variable -1" ) ; if ( ! this . hasref ( root ) ) throw n...
Deletes a reference for a given node .
7,418
public List < byte [ ] > allSat ( final int r ) { final byte [ ] allsatProfile = new byte [ this . varnum ] ; for ( int v = level ( r ) - 1 ; v >= 0 ; -- v ) allsatProfile [ this . level2var [ v ] ] = - 1 ; initRef ( ) ; final List < byte [ ] > allSat = new LinkedList < > ( ) ; allSatRec ( r , allSat , allsatProfile ) ...
Returns all models for a given BDD .
7,419
private void initializeGlucose ( ) { this . initializeGlucoseConfig ( ) ; this . watchesBin = new LNGVector < > ( ) ; this . permDiff = new LNGIntVector ( ) ; this . lastDecisionLevel = new LNGIntVector ( ) ; this . lbdQueue = new LNGBoundedLongQueue ( ) ; this . trailQueue = new LNGBoundedIntQueue ( ) ; this . assump ...
Initializes the additional parameters .
7,420
private void initializeGlucoseConfig ( ) { this . lbLBDMinimizingClause = glucoseConfig . lbLBDMinimizingClause ; this . lbLBDFrozenClause = glucoseConfig . lbLBDFrozenClause ; this . lbSizeMinimizingClause = glucoseConfig . lbSizeMinimizingClause ; this . firstReduceDB = glucoseConfig . firstReduceDB ; this . specialI...
Initializes the glucose configuration .
7,421
private long computeLBD ( final LNGIntVector lits , int e ) { int end = e ; long nblevels = 0 ; myflag ++ ; if ( incremental ) { if ( end == - 1 ) end = lits . size ( ) ; long nbDone = 0 ; for ( int i = 0 ; i < lits . size ( ) ; i ++ ) { if ( nbDone >= end ) break ; if ( isSelector ( var ( lits . get ( i ) ) ) ) contin...
Computes the LBD for a given vector of literals .
7,422
private long computeLBD ( final MSClause c ) { long nblevels = 0 ; myflag ++ ; if ( incremental ) { long nbDone = 0 ; for ( int i = 0 ; i < c . size ( ) ; i ++ ) { if ( nbDone >= c . sizeWithoutSelectors ( ) ) break ; if ( isSelector ( var ( c . get ( i ) ) ) ) continue ; nbDone ++ ; int l = v ( c . get ( i ) ) . level...
Computes the LBD for a given clause
7,423
private void minimisationWithBinaryResolution ( final LNGIntVector outLearnt ) { long lbd = computeLBD ( outLearnt , - 1 ) ; int p = not ( outLearnt . get ( 0 ) ) ; if ( lbd <= lbLBDMinimizingClause ) { myflag ++ ; for ( int i = 1 ; i < outLearnt . size ( ) ; i ++ ) permDiff . set ( var ( outLearnt . get ( i ) ) , myfl...
A special clause minimization by binary resolution for small clauses .
7,424
private int buildRec ( final Formula formula ) { switch ( formula . type ( ) ) { case FALSE : return BDDKernel . BDD_FALSE ; case TRUE : return BDDKernel . BDD_TRUE ; case LITERAL : final Literal lit = ( Literal ) formula ; Integer idx = this . var2idx . get ( lit . variable ( ) ) ; if ( idx == null ) { idx = this . va...
Recursive build procedure for the BDD .
7,425
public void setVariableOrder ( final Variable ... varOrder ) { this . kernel . setNumberOfVars ( varOrder . length ) ; for ( final Variable lit : varOrder ) { final int idx = this . var2idx . size ( ) ; this . var2idx . put ( lit . variable ( ) , idx ) ; this . idx2var . put ( idx , lit . variable ( ) ) ; } }
Sets the variable order for this factory manually . In this case the number of variables has not to be set manually .
7,426
public BigDecimal modelCount ( final BDD bdd , final int unimportantVars ) { return modelCount ( bdd ) . divide ( BigDecimal . valueOf ( ( int ) Math . pow ( 2 , unimportantVars ) ) ) ; }
Returns the model count of a given BDD with a given number of unimportant variables .
7,427
public List < Assignment > enumerateAllModels ( final BDD bdd , final Collection < Variable > variables ) { final Set < Assignment > res = new HashSet < > ( ) ; final List < byte [ ] > models = this . kernel . allSat ( bdd . index ( ) ) ; final SortedSet < Integer > temp ; if ( variables == null ) temp = new TreeSet < ...
Enumerates all models of a given BDD wrt . a given set of variables .
7,428
public Formula cnf ( final BDD bdd ) { final List < byte [ ] > unsatPaths = this . kernel . allUnsat ( bdd . index ( ) ) ; final List < Formula > clauses = new LinkedList < > ( ) ; List < Formula > literals ; for ( final byte [ ] path : unsatPaths ) { literals = new LinkedList < > ( ) ; for ( int i = 0 ; i < path . len...
Returns a CNF formula for a given BDD .
7,429
public Formula dnf ( final BDD bdd ) { final List < Formula > ops = new LinkedList < > ( ) ; for ( final Assignment ass : this . enumerateAllModels ( bdd ) ) ops . add ( ass . formula ( this . f ) ) ; return ops . isEmpty ( ) ? this . f . falsum ( ) : this . f . or ( ops ) ; }
Returns a DNF formula for a given BDD .
7,430
public SortedSet < Variable > support ( final BDD bdd ) { final int supportBDD = this . kernel . support ( bdd . index ( ) ) ; final Assignment assignment = createAssignment ( supportBDD ) ; assert assignment == null || assignment . negativeLiterals ( ) . isEmpty ( ) ; return assignment == null ? new TreeSet < Variable...
Returns all the variables that a given BDD depends on .
7,431
private Assignment createAssignment ( final int modelBDD ) { if ( modelBDD == BDDKernel . BDD_FALSE ) return null ; if ( modelBDD == BDDKernel . BDD_TRUE ) return new Assignment ( ) ; final List < int [ ] > nodes = this . kernel . allNodes ( modelBDD ) ; final Assignment assignment = new Assignment ( ) ; for ( final in...
Creates an assignment from a BDD .
7,432
public SortedMap < Variable , Integer > variableProfile ( final BDD bdd ) { final int [ ] varProfile = this . kernel . varProfile ( bdd . index ( ) ) ; final SortedMap < Variable , Integer > profile = new TreeMap < > ( ) ; for ( int i = 0 ; i < varProfile . length ; i ++ ) { profile . put ( this . idx2var . get ( i ) ,...
Returns how often each variable occurs in the given BDD .
7,433
public BDDNode toLngBdd ( final int bdd ) { final BDDConstant falseNode = BDDConstant . getFalsumNode ( this . f ) ; final BDDConstant trueNode = BDDConstant . getVerumNode ( this . f ) ; if ( bdd == BDDKernel . BDD_FALSE ) return falseNode ; if ( bdd == BDDKernel . BDD_TRUE ) return trueNode ; final List < int [ ] > n...
Returns a LogicNG internal BDD data structure of a given BDD .
7,434
public Formula formula ( final FormulaFactory f ) { if ( this . operator != FType . AND && this . operator != FType . OR ) throw new IllegalStateException ( "Illegal operator for formula list formula construction: " + this . operator ) ; if ( this . formula == null ) { if ( this . operator == FType . AND ) this . formu...
Returns this formula list as a formula if there is an operator .
7,435
public Formula get ( final int i ) { if ( i < 0 || i >= this . formulas . length ) throw new IllegalArgumentException ( "Illegal formula index: " + i ) ; return this . formulas [ i ] ; }
Returns the i - th formula of this formula list .
7,436
public SortedSet < Variable > variables ( ) { if ( this . variables == null ) { this . variables = new TreeSet < > ( ) ; for ( final Formula f : this . formulas ) this . variables . addAll ( f . variables ( ) ) ; } return this . variables ; }
Returns all variables occurring in this formula list .
7,437
public SortedSet < Literal > getCompleteBackbone ( ) { final SortedSet < Literal > completeBackbone = new TreeSet < > ( ) ; if ( hasPositiveBackboneResult ( ) ) { completeBackbone . addAll ( this . positiveBackbone ) ; } if ( hasNegativeBackboneResult ( ) ) { for ( final Variable var : this . negativeBackbone ) { compl...
Returns all literals of the backbone . Positive backbone variables have positive polarity negative backbone variables have negative polarity .
7,438
public Node < T > node ( T content ) { final Node < T > search = nodes . get ( content ) ; if ( search != null ) return search ; final Node < T > n = new Node < > ( content , this ) ; nodes . put ( content , n ) ; return n ; }
Returns the node with a given content . If such a node does not exist it is created and added to the graph .
7,439
public void encodeAMO ( final MiniSatStyleSolver s , final LNGIntVector lits ) { switch ( this . amoEncoding ) { case LADDER : this . ladder . encode ( s , lits ) ; break ; default : throw new IllegalStateException ( "Unknown AMO encoding: " + this . amoEncoding ) ; } }
Encodes an AMO constraint in the given solver .
7,440
public void encodeCardinality ( final MiniSatStyleSolver s , final LNGIntVector lits , int rhs ) { switch ( this . cardinalityEncoding ) { case TOTALIZER : this . totalizer . build ( s , lits , rhs ) ; if ( this . totalizer . hasCreatedEncoding ( ) ) this . totalizer . update ( s , rhs ) ; break ; case MTOTALIZER : thi...
Encodes a cardinality constraint in the given solver .
7,441
public void updateCardinality ( final MiniSatStyleSolver s , int rhs ) { switch ( this . cardinalityEncoding ) { case TOTALIZER : this . totalizer . update ( s , rhs ) ; break ; case MTOTALIZER : this . mtotalizer . update ( s , rhs ) ; break ; default : throw new IllegalStateException ( "Unknown cardinality encoding: ...
Updates the cardinality constraint .
7,442
public void buildCardinality ( final MiniSatStyleSolver s , final LNGIntVector lits , int rhs ) { assert this . incrementalStrategy != IncrementalStrategy . NONE ; switch ( this . cardinalityEncoding ) { case TOTALIZER : this . totalizer . build ( s , lits , rhs ) ; break ; default : throw new IllegalStateException ( "...
Manages the building of cardinality encodings . Currently is only used for incremental solving .
7,443
public void incUpdateCardinality ( final MiniSatStyleSolver s , final LNGIntVector join , final LNGIntVector lits , int rhs , final LNGIntVector assumptions ) { assert this . incrementalStrategy == IncrementalStrategy . ITERATIVE ; switch ( this . cardinalityEncoding ) { case TOTALIZER : if ( join . size ( ) > 0 ) this...
Manages the incremental update of cardinality constraints .
7,444
public void encodePB ( final MiniSatStyleSolver s , final LNGIntVector lits , final LNGIntVector coeffs , int rhs ) { switch ( this . pbEncoding ) { case SWC : this . swc . encode ( s , lits , coeffs , rhs ) ; break ; default : throw new IllegalStateException ( "Unknown pseudo-Boolean encoding: " + this . pbEncoding ) ...
Encodes a pseudo - Boolean constraint .
7,445
public void updatePB ( final MiniSatStyleSolver s , int rhs ) { switch ( this . pbEncoding ) { case SWC : this . swc . update ( s , rhs ) ; break ; default : throw new IllegalStateException ( "Unknown pseudo-Boolean encoding: " + this . pbEncoding ) ; } }
Updates a pseudo - Boolean encoding .
7,446
public void incEncodePB ( final MiniSatStyleSolver s , final LNGIntVector lits , final LNGIntVector coeffs , int rhs , final LNGIntVector assumptions , int size ) { assert this . incrementalStrategy == IncrementalStrategy . ITERATIVE ; switch ( this . pbEncoding ) { case SWC : this . swc . encode ( s , lits , coeffs , ...
Incrementally encodes a pseudo - Boolean constraint .
7,447
public void incUpdatePB ( final MiniSatStyleSolver s , final LNGIntVector lits , final LNGIntVector coeffs , int rhs ) { assert this . incrementalStrategy == IncrementalStrategy . ITERATIVE ; switch ( this . pbEncoding ) { case SWC : this . swc . updateInc ( s , rhs ) ; this . swc . join ( s , lits , coeffs ) ; break ;...
Manages the incremental update of pseudo - Boolean encodings .
7,448
public void incUpdatePBAssumptions ( final LNGIntVector assumptions ) { assert this . incrementalStrategy == IncrementalStrategy . ITERATIVE ; switch ( this . pbEncoding ) { case SWC : this . swc . updateAssumptions ( assumptions ) ; break ; default : throw new IllegalStateException ( "Unknown pseudo-Boolean encoding: ...
Manages the incremental update of assumptions .
7,449
private void growTo ( int size ) { this . elems . growTo ( size , 0 ) ; this . first = 0 ; this . maxSize = size ; this . queueSize = 0 ; this . last = 0 ; }
Grows this queue to a given size .
7,450
void setLexerAndParser ( final Lexer lexer , final ParserWithFormula parser ) { this . lexer = lexer ; this . parser = parser ; this . parser . setFormulaFactory ( this . f ) ; this . lexer . removeErrorListeners ( ) ; this . parser . removeErrorListeners ( ) ; this . parser . setErrorHandler ( new BailErrorStrategy ( ...
Sets the internal lexer and the parser .
7,451
public Formula parse ( final InputStream inputStream ) throws ParserException { if ( inputStream == null ) { return this . f . verum ( ) ; } try { final CharStream input = CharStreams . fromStream ( inputStream ) ; this . lexer . setInputStream ( input ) ; final CommonTokenStream tokens = new CommonTokenStream ( this ....
Parses and returns a given input stream .
7,452
public Formula parse ( final String in ) throws ParserException { if ( in == null || in . isEmpty ( ) ) { return this . f . verum ( ) ; } try { final CharStream input = CharStreams . fromString ( in ) ; this . lexer . setInputStream ( input ) ; final CommonTokenStream tokens = new CommonTokenStream ( this . lexer ) ; t...
Parses and returns a given string .
7,453
private void encodeNonRecursive ( final LNGVector < Literal > literals ) { if ( literals . size ( ) > 1 ) for ( int i = 0 ; i < literals . size ( ) ; i ++ ) for ( int j = i + 1 ; j < literals . size ( ) ; j ++ ) this . result . addClause ( literals . get ( i ) . negate ( ) , literals . get ( j ) . negate ( ) ) ; }
Internal non recursive encoding .
7,454
public void update ( final MiniSatStyleSolver s , int rhs ) { final LNGIntVector assumptions = new LNGIntVector ( ) ; this . update ( s , rhs , assumptions ) ; }
Updates the right hand side .
7,455
void join ( final MiniSatStyleSolver s , final LNGIntVector lits , int rhs ) { assert this . incrementalStrategy == MaxSATConfig . IncrementalStrategy . ITERATIVE ; final LNGIntVector leftCardinalityOutlits = new LNGIntVector ( this . cardinalityOutlits ) ; int oldCardinality = this . currentCardinalityRhs ; if ( lits ...
Joins two constraints . The given constraint is added to the current one .
7,456
public Formula encode ( final Formula formula ) { switch ( this . config ( ) . algorithm ) { case FACTORIZATION : if ( this . factorization == null ) this . factorization = new CNFFactorization ( ) ; return formula . transform ( this . factorization ) ; case TSEITIN : if ( this . tseitin == null || this . currentAtomBo...
Encodes a formula to CNF .
7,457
private Formula advancedEncoding ( final Formula formula ) { if ( formula . type ( ) == FType . AND ) { final List < Formula > operands = new ArrayList < > ( formula . numberOfOperands ( ) ) ; for ( final Formula op : formula ) operands . add ( singleAdvancedEncoding ( op ) ) ; return this . f . and ( operands ) ; } re...
Encodes the given formula to CNF by first trying to use Factorization for the single sub - formulas . When certain user - provided boundaries are met the method is switched to Tseitin or Plaisted & Greenbaum .
7,458
private static Map < Literal , Integer > nonCachingLiteralProfile ( final Formula formula ) { final SortedMap < Literal , Integer > map = new TreeMap < > ( ) ; nonCachingRecursion ( formula , map ) ; return map ; }
The non - caching implementation of the literal profile computation . In this case the result map is only constructed once and results are just added to it .
7,459
public void printSolverState ( final PrintStream output ) { output . println ( "level=" + this . level ) ; output . println ( "next=" + this . next ) ; output . println ( "ignore=" + this . ignore ) ; output . println ( "empty=" + this . empty ) ; output . println ( "vars=" + this . vars ) ; output . println ( "vals=" ...
Prints the current solver state to a given output stream .
7,460
public void add ( final Formula formula ) { final Formula cnf = formula . cnf ( ) ; switch ( cnf . type ( ) ) { case TRUE : break ; case FALSE : case LITERAL : case OR : this . addClause ( generateClauseVector ( cnf ) , null ) ; break ; case AND : for ( final Formula op : cnf ) { this . addClause ( generateClauseVector...
Adds an arbitrary formula to the solver .
7,461
private List < Integer > getRelevantVarIndices ( final Collection < Variable > variables ) { final List < Integer > relevantVarIndices = new ArrayList < > ( variables . size ( ) ) ; for ( final Variable var : variables ) { final Integer idx = this . name2idx . get ( var . name ( ) ) ; if ( idx != null ) { relevantVarIn...
Returns a list of relevant variable indices . A relevant variable is known by the solver .
7,462
private Backbone buildBackbone ( final Collection < Variable > variables ) { final SortedSet < Variable > posBackboneVars = isBothOrPositiveType ( ) ? new TreeSet < Variable > ( ) : null ; final SortedSet < Variable > negBackboneVars = isBothOrNegativeType ( ) ? new TreeSet < Variable > ( ) : null ; final SortedSet < V...
Builds the backbone object from the computed backbone literals .
7,463
public Backbone compute ( final Collection < Variable > variables , final BackboneType type ) { final boolean sat = solve ( null ) == Tristate . TRUE ; Backbone backbone = null ; if ( sat ) { final List < Integer > relevantVarIndices = getRelevantVarIndices ( variables ) ; init ( relevantVarIndices , type ) ; compute (...
Computes the backbone of the given variables with respect to the formulas added to the solver .
7,464
private boolean isUnit ( final int lit , final MSClause clause ) { for ( int i = 0 ; i < clause . size ( ) ; ++ i ) { final int clauseLit = clause . get ( i ) ; if ( lit != clauseLit && this . model . get ( var ( clauseLit ) ) != sign ( clauseLit ) ) { return false ; } } return true ; }
Tests the given literal whether it is unit in the given clause .
7,465
private boolean isRotatable ( final int lit ) { if ( v ( var ( lit ) ) . reason ( ) != null ) { return false ; } for ( final MSWatcher watcher : this . watches . get ( not ( lit ) ) ) { if ( isUnit ( lit , watcher . clause ( ) ) ) { return false ; } } return true ; }
Tests the given literal whether it is rotatable in the current model .
7,466
private void addBackboneLiteral ( final int lit ) { this . backboneMap . put ( var ( lit ) , sign ( lit ) ? Tristate . FALSE : Tristate . TRUE ) ; this . assumptions . push ( lit ) ; }
Adds the given literal to the backbone result and optionally adds the literal to the solver .
7,467
private Stack < Integer > createInitialCandidates ( final List < Integer > variables ) { for ( final Integer var : variables ) { if ( isUPZeroLit ( var ) ) { final int backboneLit = mkLit ( var , ! this . model . get ( var ) ) ; addBackboneLiteral ( backboneLit ) ; } else { final boolean modelPhase = this . model . get...
Creates the initial candidate literals for the backbone computation .
7,468
private boolean solve ( final int lit ) { this . assumptions . push ( not ( lit ) ) ; final boolean sat = solve ( null , this . assumptions ) == Tristate . TRUE ; this . assumptions . pop ( ) ; return sat ; }
Tests the given literal with the formula on the solver for satisfiability .
7,469
private void compute ( final List < Integer > variables ) { final Stack < Integer > candidates = createInitialCandidates ( variables ) ; while ( candidates . size ( ) > 0 ) { final int lit = candidates . pop ( ) ; if ( solve ( lit ) ) { refineUpperBound ( ) ; } else { addBackboneLiteral ( lit ) ; } } }
Computes the backbone for the given variables .
7,470
private LNGIntVector generateClauseVector ( final Formula clause ) { final LNGIntVector clauseVec = new LNGIntVector ( clause . numberOfOperands ( ) ) ; for ( final Literal lit : clause . literals ( ) ) { int index = this . idxForName ( lit . name ( ) ) ; if ( index == - 1 ) { index = this . newVar ( false , true ) ; t...
Generates a solver vector of a clause .
7,471
private void biasPhases ( ) { final double [ ] score = new double [ 2 * ( maxvar ( ) + 1 ) ] ; for ( final CLClause c : this . clauses ) { if ( c . redundant ( ) || c . satisfied ( ) ) { continue ; } double inc = 1 ; for ( int size = c . size ( ) ; size > 0 ; size -- ) { inc /= 2.0 ; } for ( int i = 0 ; i < c . lits ( ...
Initializes the initial phases of literals .
7,472
private void touch ( final int l ) { int lit = l ; if ( lit < 0 ) { lit = - lit ; } final long newPriority = ( long ) occs ( lit ) . count ( ) + occs ( - lit ) . count ( ) ; if ( ! var ( lit ) . free ( ) ) { return ; } final LNGLongPriorityQueue queue = currentCands ( ) ; queue . update ( lit , - newPriority ) ; if ( t...
Updates and pushes a literal as candidate to simplify .
7,473
private void touchFixed ( ) { assert this . dense ; assert this . level == 0 ; assert this . schedule ; while ( this . touched < this . trail . size ( ) ) { final int lit = this . trail . get ( this . touched ++ ) ; assert val ( lit ) > 0 ; assert var ( lit ) . level ( ) == 0 ; final CLOccs os = occs ( lit ) ; for ( fi...
Touches literals in newly top - level satisfied clauses using the literals not touched yet .
7,474
private void addOcc ( final int lit , final CLClause c ) { assert this . dense ; occs ( lit ) . add ( c ) ; touch ( lit ) ; }
Adds a clause to a literal s occurrence list .
7,475
private void connectOccs ( final CLClause c ) { assert this . dense ; for ( int i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { addOcc ( c . lits ( ) . get ( i ) , c ) ; } }
Connects a clause through a full occurrence list .
7,476
private void connectOccs ( ) { assert ! this . dense ; this . dense = true ; for ( final CLClause c : this . clauses ) { if ( ! c . redundant ( ) ) { connectOccs ( c ) ; } } }
Connects all clauses through full occurrence lists .
7,477
private void updateGlue ( final CLClause c ) { if ( ! this . config . glueupdate ) { return ; } if ( ! this . config . gluered ) { assert c . glue ( ) == 0 ; return ; } assert this . frames . empty ( ) ; for ( int i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { markFrame ( c . lits ( ) . get ( i ) ) ; } final int newGlu...
Updates the glue value for a given clause .
7,478
private void dumpClause ( final CLClause c ) { if ( c . dumped ( ) ) { return ; } if ( c . redundant ( ) ) { assert this . stats . clausesRedundant > 0 ; this . stats . clausesRedundant -- ; } else { assert this . stats . clausesIrredundant > 0 ; this . stats . clausesIrredundant -- ; if ( this . dense ) { for ( int i ...
Dumps a given clause .
7,479
private void bumpClause ( final CLClause c ) { switch ( this . config . cbump ) { case INC : c . setActivity ( c . activity ( ) + 1 ) ; break ; case LRU : c . setActivity ( this . stats . conflicts ) ; break ; case AVG : c . setActivity ( ( this . stats . conflicts + c . activity ( ) ) / 2 ) ; break ; case NONE : defau...
Bumps a clause and increments it s activity .
7,480
private void reduce ( ) { this . stats . reductions ++ ; final LNGVector < CLClause > candidates = new LNGVector < > ( ) ; for ( final CLClause c : this . clauses ) { if ( c . redundant ( ) && ! c . important ( ) && ! c . forcing ( ) ) { candidates . push ( c ) ; } } final int keep = candidates . size ( ) / 2 ; candida...
Reduces the number of redundant clauses .
7,481
private int remainingVars ( ) { int res = maxvar ( ) ; res -= this . stats . varsFixed ; res -= this . stats . varsEquivalent ; res -= this . stats . varsEliminated ; return res ; }
Returns the number of remaining variables without fixed and eliminated .
7,482
private void strengthen ( final CLClause c , final int remove ) { if ( c . dumped ( ) || satisfied ( c ) ) { return ; } assert this . addedlits . empty ( ) ; for ( int i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { final int lit = c . lits ( ) . get ( i ) ; if ( lit != remove && val ( lit ) == 0 ) { this . addedlits . ...
Removes a literal in a clause .
7,483
private int sizePenalty ( ) { long numClauses = ( long ) this . stats . clausesIrredundant / this . config . sizepen ; int logres = 0 ; while ( numClauses != 0 && logres < this . config . sizemaxpen ) { numClauses >>= 1 ; logres ++ ; } return 1 << logres ; }
Reduces simplification steps for large formulas .
7,484
private void backward ( final CLClause c , final int ignore ) { int minlit = 0 ; int minoccs = Integer . MAX_VALUE ; int litoccs ; this . stats . steps ++ ; for ( int i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { final int lit = c . lits ( ) . get ( i ) ; if ( lit == ignore ) { continue ; } if ( val ( lit ) < 0 ) { co...
Backward subsumes from clause .
7,485
private void backward ( final int lit ) { assert this . level == 0 ; assert this . dense ; assert this . tostrengthen . empty ( ) ; final CLOccs os = occs ( lit ) ; for ( final CLClause c : os ) { assert ! c . redundant ( ) ; this . stats . steps ++ ; if ( c . dumped ( ) ) { continue ; } if ( c . size ( ) >= this . con...
Backward subsumes from clauses in the occurrence list of a given literal .
7,486
private boolean tryElim ( final int cand ) { assert var ( cand ) . free ( ) ; final CLOccs p = occs ( cand ) ; final CLOccs n = occs ( - cand ) ; long limit = ( long ) p . count ( ) + n . count ( ) ; for ( int i = 0 ; limit >= 0 && i < p . clauses ( ) . size ( ) ; i ++ ) { final CLClause c = p . clauses ( ) . get ( i )...
Tries bounded variable elimination on a candidate literal .
7,487
private void doResolve ( final CLClause c , final int pivot , final CLClause d ) { assert ! c . dumped ( ) && ! c . satisfied ( ) ; assert ! d . dumped ( ) && ! d . satisfied ( ) ; assert this . addedlits . empty ( ) ; this . stats . steps ++ ; for ( int i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { final int lit = c ...
Performs resolution on two given clauses and a pivot literal .
7,488
private void pushExtension ( final CLClause c , final int blit ) { pushExtension ( 0 ) ; for ( int i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { final int lit = c . lits ( ) . get ( i ) ; if ( lit != blit ) { pushExtension ( lit ) ; } } pushExtension ( blit ) ; }
Pushes and logs a clause and its blocking literal to the extension .
7,489
private void doElim ( final int cand ) { assert this . schedule ; assert var ( cand ) . free ( ) ; final CLOccs p = occs ( cand ) ; final CLOccs n = occs ( - cand ) ; for ( final CLClause c : p ) { this . stats . steps ++ ; if ( c . dumped ( ) || satisfied ( c ) ) { continue ; } for ( final CLClause d : n ) { this . st...
Performs blocking variable elimination on a candidate .
7,490
private void dumpEliminatedRedundant ( ) { for ( final CLClause c : this . clauses ) { if ( ! c . redundant ( ) || c . satisfied ( ) || c . dumped ( ) ) { continue ; } if ( containsEliminated ( c ) ) { dumpClause ( c ) ; } } }
Dumps redundant clauses with eliminated variables .
7,491
private void updateCands ( ) { if ( ! this . dense ) { connectOccs ( ) ; } assert ! this . schedule ; this . schedule = true ; if ( this . schedule = currentCands ( ) . empty ( ) ) { for ( int idx = 1 ; idx <= maxvar ( ) ; idx ++ ) { touch ( idx ) ; } } this . schedule = true ; touchFixed ( ) ; }
Updates the candidates priority queue for new rounds of simplification .
7,492
private void blockLit ( final int blit ) { final CLOccs os = occs ( blit ) ; for ( final CLClause c : os ) { assert ! c . redundant ( ) ; if ( ! blockClause ( c , blit ) ) { continue ; } this . stats . clausesBlocked ++ ; pushExtension ( c , blit ) ; dumpClause ( c ) ; } }
Finds and removes all blocked clauses blocked on a given blocking literal .
7,493
private void block ( ) { final long steps = this . limits . simpSteps ; assert this . level == 0 ; assert ! this . config . plain ; if ( ! this . config . block ) { return ; } if ( this . config . blkwait >= this . stats . simplifications ) { return ; } assert this . simplifier == Simplifier . TOPSIMP ; this . simplifi...
Blocked Clause Elimination .
7,494
private void disconnectClauses ( ) { this . limits . reduceImportant = 0 ; for ( int idx = 1 ; idx <= maxvar ( ) ; idx ++ ) { for ( int sign = - 1 ; sign <= 1 ; sign += 2 ) { final int lit = sign * idx ; watches ( lit ) . release ( ) ; occs ( lit ) . release ( ) ; } } this . dense = false ; }
Disconnects all clauses .
7,495
private CLClause reduceClause ( final CLClause c ) { int lit ; int i ; for ( i = 0 ; i < c . lits ( ) . size ( ) ; i ++ ) { lit = c . lits ( ) . get ( i ) ; if ( val ( lit ) < 0 ) { break ; } } if ( i == c . lits ( ) . size ( ) ) { return c ; } assert this . addedlits . empty ( ) ; for ( i = 0 ; i < c . lits ( ) . size...
Removes false literals from a given clause .
7,496
private Tristate simplify ( ) { assert this . simplifier == Simplifier . NOSIMP ; this . simplifier = Simplifier . TOPSIMP ; this . stats . simplifications ++ ; backtrack ( ) ; final int varsBefore = remainingVars ( ) ; if ( ! this . config . plain ) { if ( this . empty == null ) { distill ( ) ; } if ( this . empty == ...
Performs bounded inprocessing .
7,497
private void extend ( ) { while ( ! this . extension . empty ( ) ) { final int lit = this . extension . back ( ) ; int other ; boolean satisfied = false ; while ( ( other = this . extension . back ( ) ) != 0 ) { this . extension . pop ( ) ; if ( val ( other ) == VALUE_TRUE ) { satisfied = true ; } } this . extension . ...
Extends a partial to a full assignment .
7,498
public static < T > Set < Set < Node < T > > > compute ( final Graph < T > graph ) { final Set < Set < Node < T > > > connectedComponents = new LinkedHashSet < > ( ) ; final Set < Node < T > > unmarkedNodes = new LinkedHashSet < > ( graph . nodes ( ) ) ; while ( ! unmarkedNodes . isEmpty ( ) ) { Set < Node < T > > conn...
Computes the set of connected components of a graph where each component is represented by a set of nodes .
7,499
private void resize ( final int ns ) { final int size = BDDPrime . primeGTE ( ns ) ; this . table = new BDDCacheEntry [ size ] ; for ( int n = 0 ; n < size ; n ++ ) this . table [ n ] = new BDDCacheEntry ( ) ; }
Resizes the cache to a new number of entries . The old cache entries are removed in this process .