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 ( ) . incremental ( false ) . build ( ) ) ; default : throw new IllegalStateException ( "Unknown solver type: " + this . solverType ) ; } } | 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 . MAX_VALUE && softClauses . get ( i ) . weight ( ) != weight ) { unsatisfied = false ; continue ; } assert var ( softClauses . get ( i ) . clause ( ) . get ( j ) ) < currentModel . size ( ) ; if ( ( sign ( softClauses . get ( i ) . clause ( ) . get ( j ) ) && ! currentModel . get ( var ( softClauses . get ( i ) . clause ( ) . get ( j ) ) ) ) || ( ! sign ( softClauses . get ( i ) . clause ( ) . get ( j ) ) && currentModel . get ( var ( softClauses . get ( i ) . clause ( ) . get ( j ) ) ) ) ) { unsatisfied = false ; break ; } } if ( unsatisfied ) currentCost += softClauses . get ( i ) . weight ( ) ; } return currentCost ; } | 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 = softClauses . get ( i ) . weight ( ) ; partitionWeights . add ( weight ) ; final Integer foundNB = nbPartitionWeights . get ( weight ) ; if ( foundNB == null ) nbPartitionWeights . put ( weight , 1 ) ; else nbPartitionWeights . put ( weight , foundNB + 1 ) ; } for ( final int i : partitionWeights ) orderWeights . push ( i ) ; orderWeights . sortReverse ( ) ; long totalWeights = 0 ; for ( int i = 0 ; i < orderWeights . size ( ) ; i ++ ) totalWeights += orderWeights . get ( i ) * nbPartitionWeights . get ( orderWeights . get ( i ) ) ; for ( int i = 0 ; i < orderWeights . size ( ) ; i ++ ) { totalWeights -= orderWeights . get ( i ) * nbPartitionWeights . get ( orderWeights . get ( i ) ) ; if ( orderWeights . get ( i ) < totalWeights ) { bmo = false ; break ; } } if ( ! cache ) orderWeights . clear ( ) ; return bmo ; } | 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 " + 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 ( ) ; } } | 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 . 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 ( ) ; } } | 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 . 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 ) ; } | 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." ) ; 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 ( ) ; } | 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 . 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 ( ) ; } | 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 < > ( 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 ) ; } } | 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 . heap . get ( this . pos . get ( element ) ) == element ; this . up ( element ) ; } | 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 ( element ) ; if ( q < priority ) this . up ( element ) ; } | 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 . heap . set ( i , last ) ; this . up ( last ) ; this . down ( last ) ; } | 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 = ppos ; } this . pos . set ( element , epos ) ; } | 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 ( 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 ) ; } | 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 ( br . readLine ( ) ) ) ; return parser . factory ( ) . and ( ops ) ; } } | 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_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 ) ; } } | 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" ) ; this . addCNF ( formula . cnf ( ) , weight ) ; } | 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 = 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 ) ; } } | 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 . result = this . solver . search ( handler ) ; return this . result ; } | 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 . clause . clear ( ) ; } | 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 ( cardinalityOutvars , rhs , Bound . UPPER ) ; assert this . cardinalityInvars . size ( ) == 0 ; for ( int i = rhs ; i < cardinalityOutvars . size ( ) ; i ++ ) this . result . addClause ( cardinalityOutvars . get ( i ) . negate ( ) ) ; } | 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 . toCNF ( cardinalityOutvars , rhs , Bound . LOWER ) ; assert this . cardinalityInvars . size ( ) == 0 ; for ( int i = 0 ; i < rhs ; i ++ ) this . result . addClause ( cardinalityOutvars . get ( i ) ) ; } | 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 ++ ) this . result . addClause ( cardinalityOutvars . get ( i ) ) ; for ( int i = rhs ; i < cardinalityOutvars . size ( ) ; i ++ ) this . result . addClause ( cardinalityOutvars . get ( i ) . negate ( ) ) ; } | 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 ( final Variable var : vars ) { this . cardinalityInvars . push ( var ) ; cardinalityOutvars . push ( this . result . newVariable ( ) ) ; } return cardinalityOutvars ; } | 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 PLAIN_INSERTION : return insertion . computeMUS ( propositions , f , config ) ; case DELETION : default : return deletion . computeMUS ( propositions , f , config ) ; } } | 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 : 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" ) ; } } | 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 ( node != null ) { node . setEndSet ( set ) ; } } | 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 allSets ; } | 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 < > ( ) ; 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 ; } | 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 operator: " + type ) ; } } | 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 ( ) ; 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 ; } | 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 ) ) 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 ; } | 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 . 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 ; } | 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 ( ) ) { 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 ; } | 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 ; 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 ; } | 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 ( ) ) { 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 ; } | 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 : variables ) vars [ count ++ ] = var ; return this . constructPBC ( comparator , rhs , vars , coefficients ) ; } | 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 ) . 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 ; } | 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 ) . 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 ; } | 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 . 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 ; } | 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 res ; } | 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 < CLWatch > ( ) ) ; this . watches . push ( new LNGVector < CLWatch > ( ) ) ; if ( newIdx == 0 ) { continue ; } this . decisions . push ( newIdx ) ; } } | 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 . 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 ; } | 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 . scoreIncrement *= factor ; } | 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 ) ; } final double newPriority = oldPriority + this . scoreIncrement ; this . decisions . update ( idx , newPriority ) ; } | 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 ( 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 ; } | 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 ; if ( this . phases . get ( decision ) < 0 ) { decision = - decision ; } this . stats . decisions ++ ; this . stats . levels += this . level ; assume ( decision ) ; return true ; } | 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 . 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 ) ; } | 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 , x ) ; if ( ( ++ this . first ) == this . maxSize ) { this . first = 0 ; this . last = 0 ; } } | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.