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 ( this . literals [ i ] ) ; normCs . push ( this . coefficients [ i ] ) ; } normRhs = this . rhs ; final Formula f1 = this . normalize ( normPs , normCs , normRhs ) ; normPs . clear ( ) ; normCs . clear ( ) ; for ( int i = 0 ; i < this . literals . length ; i ++ ) { normPs . push ( this . literals [ i ] ) ; normCs . push ( - this . coefficients [ i ] ) ; } normRhs = - this . rhs ; final Formula f2 = this . normalize ( normPs , normCs , normRhs ) ; return this . f . and ( f1 , f2 ) ; case LT : case LE : for ( int i = 0 ; i < this . literals . length ; i ++ ) { normPs . push ( this . literals [ i ] ) ; normCs . push ( this . coefficients [ i ] ) ; } normRhs = this . comparator == CType . LE ? this . rhs : this . rhs - 1 ; return this . normalize ( normPs , normCs , normRhs ) ; case GT : case GE : for ( int i = 0 ; i < this . literals . length ; i ++ ) { normPs . push ( this . literals [ i ] ) ; normCs . push ( - this . coefficients [ i ] ) ; } normRhs = this . comparator == CType . GE ? - this . rhs : - this . rhs - 1 ; return this . normalize ( normPs , normCs , normRhs ) ; default : throw new IllegalStateException ( "Unknown pseudo-Boolean comparator: " + this . comparator ) ; } }
Normalizes this constraint s . t . it can be converted to CNF .