idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
7,500
public static Tristate searchSATSolver ( final MiniSatStyleSolver s , final SATHandler handler , final LNGIntVector assumptions ) { return s . solve ( handler , assumptions ) ; }
Solves the formula that is currently loaded in the SAT solver with a set of assumptions .
7,501
public final MaxSATResult search ( final MaxSATHandler handler ) { this . handler = handler ; if ( handler != null ) handler . startedSolving ( ) ; final MaxSATResult result = search ( ) ; if ( handler != null ) handler . finishedSolving ( ) ; this . handler = null ; return result ; }
The main MaxSAT solving method .
7,502
public void addSoftClause ( int weight , final LNGIntVector lits ) { final LNGIntVector rVars = new LNGIntVector ( ) ; this . softClauses . push ( new MSSoftClause ( lits , weight , LIT_UNDEF , rVars ) ) ; this . nbSoft ++ ; }
Adds a new soft clause to the soft clause database .
7,503
public MiniSatStyleSolver newSATSolver ( ) { switch ( this . solverType ) { case GLUCOSE : return new GlucoseSyrup ( new MiniSatConfig . Builder ( ) . incremental ( true ) . build ( ) , new GlucoseConfig . Builder ( ) . build ( ) ) ; case MINISAT : return new MiniSat2Solver ( new MiniSatConfig . Builder ( ) . increment...
Creates an empty SAT Solver .
7,504
public void saveModel ( final LNGBooleanVector currentModel ) { assert nbInitialVariables != 0 ; assert currentModel . size ( ) != 0 ; this . model . clear ( ) ; for ( int i = 0 ; i < nbInitialVariables ; i ++ ) this . model . push ( currentModel . get ( i ) ) ; }
Saves the current model found by the SAT solver .
7,505
public int computeCostModel ( final LNGBooleanVector currentModel , int weight ) { assert currentModel . size ( ) != 0 ; int currentCost = 0 ; for ( int i = 0 ; i < nSoft ( ) ; i ++ ) { boolean unsatisfied = true ; for ( int j = 0 ; j < softClauses . get ( i ) . clause ( ) . size ( ) ; j ++ ) { if ( weight != Integer ....
Computes the cost of a given model . The cost of a model is the sum of the weights of the unsatisfied soft clauses . If a weight is specified then it only considers the sum of the weights of the unsatisfied soft clauses with the specified weight .
7,506
public boolean isBMO ( boolean cache ) { assert orderWeights . size ( ) == 0 ; boolean bmo = true ; final SortedSet < Integer > partitionWeights = new TreeSet < > ( ) ; final SortedMap < Integer , Integer > nbPartitionWeights = new TreeMap < > ( ) ; for ( int i = 0 ; i < nSoft ( ) ; i ++ ) { final int weight = softClau...
Tests if the MaxSAT formula has lexicographical optimization criterion .
7,507
private static String utf8Name ( final String name ) { final Matcher matcher = pattern . matcher ( name ) ; if ( ! matcher . matches ( ) ) return name ; if ( matcher . group ( 2 ) . isEmpty ( ) ) return matcher . group ( 1 ) ; return matcher . group ( 1 ) + getSubscript ( matcher . group ( 2 ) ) ; }
Returns the UTF8 string for a variable name
7,508
public List < Formula > newUpperBound ( int rhs ) { this . result . reset ( ) ; this . computeUBConstraint ( this . result , rhs ) ; return this . result . result ( ) ; }
Tightens the upper bound of an at - most - k constraint and returns the resulting formula .
7,509
public List < Formula > newLowerBound ( int rhs ) { this . result . reset ( ) ; this . computeLBConstraint ( this . result , rhs ) ; return this . result . result ( ) ; }
Tightens the lower bound of an at - least - k constraint and returns the resulting formula .
7,510
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 " + ...
Shrinks a given map to a given size
7,511
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 . si...
Shrinks a given set to a given size
7,512
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...
Saves the FormulaFactoryState to be loaded later .
7,513
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....
Loads a previously saved FormulaFactoryState . All formula factory states saved after the loaded one become invalid .
7,514
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 ....
Clears the caches of every cached Formula .
7,515
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 < > ( formu...
Writes a given formula s internal data structure as a dimacs file . Must only be called with a formula which is in CNF .
7,516
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 .
7,517
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 . ...
Pushes a new positive element to the queue .
7,518
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 ( ele...
Updated the priority of a given element .
7,519
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 . hea...
Removes a given element from the priority queue . Its priority is kept as is .
7,520
public void rescore ( double factor ) { for ( int i = 0 ; i < this . prior . size ( ) ; i ++ ) this . prior . set ( i , this . prior . get ( i ) * factor ) ; }
Rescores all priorities by multiplying them with the same factor .
7,521
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 = p...
Bubbles a given element up .
7,522
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 ( ele...
Bubbles a given element down .
7,523
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 ( b...
Internal read function .
7,524
public static MaxSATSolver linearSU ( ) { return new MaxSATSolver ( new MaxSATConfig . Builder ( ) . cardinality ( MaxSATConfig . CardinalityEncoding . MTOTALIZER ) . build ( ) , Algorithm . LINEAR_SU ) ; }
Returns a new MaxSAT solver using LinearSU as algorithm with the default configuration .
7,525
public static MaxSATSolver wmsu3 ( ) { return new MaxSATSolver ( new MaxSATConfig . Builder ( ) . incremental ( MaxSATConfig . IncrementalStrategy . ITERATIVE ) . build ( ) , Algorithm . WMSU3 ) ; }
Returns a new MaxSAT solver using weighted MSU3 as algorithm with the default configuration .
7,526
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_S...
Resets the solver .
7,527
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"...
Adds a new soft formula to the solver .
7,528
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 = ...
Adds a clause to the solver .
7,529
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 . ...
Solves the formula on the solver and returns the result .
7,530
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 ; }
Returns the model of the current result .
7,531
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...
Adds a unit clause to the given SAT solver .
7,532
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 .
7,533
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 .
7,534
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 ( cardina...
Builds an at - most - k constraint .
7,535
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 ....
Builds an at - least - k constraint .
7,536
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...
Builds an exactly - k constraint .
7,537
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 ( fin...
Initializes the constraint .
7,538
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 ) + "}" ; }
Returns the latex string for a variable name
7,539
public < T extends Proposition > UNSATCore < T > computeMUS ( final List < T > propositions , final FormulaFactory f ) { return this . computeMUS ( propositions , f , new MUSConfig . Builder ( ) . build ( ) ) ; }
Computes a MUS for the given propositions with the default algorithm and the default configuration .
7,540
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 PLAI...
Computes a MUS for the given propositions and the given configuration of the MUS generation .
7,541
public void reset ( ) { this . state = State . FREE ; this . level = Integer . MAX_VALUE ; this . mark = 0 ; this . reason = null ; }
Resets this variable s members .
7,542
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 : retu...
Encodes a pseudo - Boolean constraint and returns its CNF encoding .
7,543
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 ( no...
Adds a set of comparable objects to this UBTree .
7,544
public SortedSet < T > firstSubset ( SortedSet < T > set ) { if ( this . rootNodes . isEmpty ( ) || set == null || set . isEmpty ( ) ) { return null ; } return firstSubset ( set , this . rootNodes ) ; }
Returns the first subset of a given set in this UBTree .
7,545
public Set < SortedSet < T > > allSubsets ( final SortedSet < T > set ) { final Set < SortedSet < T > > subsets = new LinkedHashSet < > ( ) ; allSubsets ( set , this . rootNodes , subsets ) ; return subsets ; }
Returns all subsets of a given set in this UBTree .
7,546
public Set < SortedSet < T > > allSupersets ( final SortedSet < T > set ) { final Set < SortedSet < T > > supersets = new LinkedHashSet < > ( ) ; allSupersets ( set , this . rootNodes , supersets ) ; return supersets ; }
Returns all supersets of a given set in this UBTree .
7,547
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 allSe...
Returns all sets in this UBTree .
7,548
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 < > ( ) ;...
Removes all formulas from the factory cache .
7,549
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 operato...
Creates a new binary operator with a given type and two operands .
7,550
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 (...
Creates a new implication .
7,551
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 ) )...
Creates a new equivalence .
7,552
public Formula and ( final Formula ... operands ) { final LinkedHashSet < Formula > ops = new LinkedHashSet < > ( operands . length ) ; Collections . addAll ( ops , operands ) ; return this . constructAnd ( ops ) ; }
Creates a new conjunction from an array of formulas .
7,553
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 . a...
Creates a new conjunction .
7,554
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 ( ) ) ...
Creates a new CNF .
7,555
public Formula or ( final Formula ... operands ) { final LinkedHashSet < Formula > ops = new LinkedHashSet < > ( operands . length ) ; Collections . addAll ( ops , operands ) ; return this . constructOr ( ops ) ; }
Creates a new disjunction from an array of formulas .
7,556
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 ; bre...
Creates a new disjunction .
7,557
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 ( ) ) { ca...
Creates a new clause .
7,558
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 ; }
Creates a new literal instance with a given name and positive phase .
7,559
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 : ...
Creates a new cardinality constraint .
7,560
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 ) . o...
Returns a condensed array of operands for a given n - ary disjunction .
7,561
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 ) ....
Returns a condensed array of operands for a given n - ary conjunction .
7,562
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 ; }
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 .
7,563
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 ...
Returns the statistics for this formula factory .
7,564
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...
Returns the next number in the luby sequence .
7,565
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 <...
Imports a given literal .
7,566
protected CLVar var ( final int lit ) { final int idx = Math . abs ( lit ) ; assert 0 < idx && idx < this . vars . size ( ) ; return this . vars . get ( idx ) ; }
Returns the variable for a given literal .
7,567
protected byte val ( final int lit ) { byte res = this . vals . get ( Math . abs ( lit ) ) ; if ( lit < 0 ) { res = ( byte ) - res ; } return res ; }
Returns the value for a given literal .
7,568
protected void mark ( final int lit ) { final CLVar v = var ( lit ) ; assert v . mark ( ) == 0 ; v . setMark ( sign ( lit ) ) ; this . seen . push ( lit ) ; }
Marks a given literal .
7,569
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 ) ; } }
Unmarks all variables up to a given level
7,570
protected void addWatch ( final int lit , final int blit , final boolean binary , final CLClause clause ) { watches ( lit ) . push ( new CLWatch ( blit , binary , clause ) ) ; }
Adds a new watcher for a given literal .
7,571
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 ; }
Marks the frame for a given literal s decision level .
7,572
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 ; }
Unmarks all frames .
7,573
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...
Backtracks to a given level
7,574
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 . scoreIn...
Rescores all variables .
7,575
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 ) ; } ...
Bump a literal s activity .
7,576
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 ; }
Analyzes a given literal .
7,577
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 ( i...
Minimize the first UIP clause by trying to remove a given literal .
7,578
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 ; }
Computes a new restart limit .
7,579
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 ) ; }
Assumes a given decision .
7,580
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 ;...
Checks if there are unassigned literals left .
7,581
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 ; }
Returns the unit propagated literals on level zero .
7,582
public static void write ( final String fileName , final BDD bdd ) throws IOException { write ( new File ( fileName . endsWith ( ".dot" ) ? fileName : fileName + ".dot" ) , bdd ) ; }
Writes a given BDD as a dot file .
7,583
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 ....
Encodes a cardinality constraint .
7,584
public void update ( final MiniSatStyleSolver s , int rhs ) { assert this . currentCardinalityRhs != - 1 ; assert hasEncoding ; this . encodeOutput ( s , rhs ) ; this . currentCardinalityRhs = rhs + 1 ; }
Updates the right hand side of the current constraint .
7,585
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 ,...
Pushes a new element to the queue .
7,586
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 ) ; }
Computes the backbone for a given collection of formulas w . r . t . a collection of variables and a backbone type .
7,587
public static Backbone compute ( final Collection < Formula > formulas , final Collection < Variable > variables ) { return compute ( formulas , variables , BackboneType . POSITIVE_AND_NEGATIVE ) ; }
Computes the complete backbone for a given collection of formulas w . r . t . a collection of variables and a backbone type .
7,588
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 .
7,589
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 .
7,590
public static Backbone compute ( final Formula formula , final Collection < Variable > variables , final BackboneType type ) { return compute ( Collections . singletonList ( formula ) , variables , type ) ; }
Computes the backbone for a given formula w . r . t . a collection of variables and a backbone type .
7,591
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 .
7,592
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 .
7,593
public static Backbone compute ( final Formula formula ) { return compute ( formula , formula . variables ( ) , BackboneType . POSITIVE_AND_NEGATIVE ) ; }
Computes the complete backbone for a given formula .
7,594
public static Backbone computePositive ( final Collection < Formula > formulas , final Collection < Variable > variables ) { return compute ( formulas , variables , BackboneType . ONLY_POSITIVE ) ; }
Computes the positive backbone variables for a given collection of formulas w . r . t . a collection of variables .
7,595
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 .
7,596
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 .
7,597
public static Backbone computePositive ( final Formula formula ) { return compute ( formula , formula . variables ( ) , BackboneType . ONLY_POSITIVE ) ; }
Computes the positive backbone variables for a given formula .
7,598
public static Backbone computeNegative ( final Collection < Formula > formulas , final Collection < Variable > variables ) { return compute ( formulas , variables , BackboneType . ONLY_NEGATIVE ) ; }
Computes the negative backbone variables for a given collection of formulas w . r . t . a collection of variables .
7,599
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 .