@ Override protected String pbLhs ( final Literal [ ] operands , final int [ ] coefficients ) { assert operands . length == coefficients . length ; final List < Literal > sortedOperands = new ArrayList <> ( ) ; final List < Integer > sortedCoefficients = new ArrayList <> ( ) ; final List < Literal > givenOperands = Arrays . asList ( operands ) ; for ( final Variable v : this . varOrder ) { final int index = givenOperands . indexOf ( v ) ; if ( index != - 1 ) { sortedOperands . add ( v ) ; sortedCoefficients . add ( coefficients [ index ] ) ; } } for ( final Literal givenOperand : givenOperands ) { if ( ! sortedOperands . contains ( givenOperand ) ) { sortedOperands . add ( givenOperand ) ; sortedCoefficients . add ( coefficients [ givenOperands . indexOf ( givenOperand ) ] ) ; } } final StringBuilder sb = new StringBuilder ( ) ; final String mul = pbMul ( ) ; final String add = pbAdd ( ) ; for ( int i = 0 ; i < sortedOperands . size ( ) - 1 ; i ++ ) { if ( sortedCoefficients . get ( i ) != 1 ) { sb . append ( sortedCoefficients . get ( i ) ) . append ( mul ) . append ( sortedOperands . get ( i ) ) . append ( add ) ; } else { sb . append ( sortedOperands . get ( i ) ) . append ( add ) ; } } if ( sortedOperands . size ( ) > 0 ) { if ( sortedCoefficients . get ( sortedOperands . size ( ) - 1 ) != 1 ) { sb . append ( sortedCoefficients . get ( sortedOperands . size ( ) - 1 ) ) . append ( mul ) . append ( sortedOperands . get ( sortedOperands . size ( ) - 1 ) ) ; } else { sb . append ( sortedOperands . get ( sortedOperands . size ( ) - 1 ) ) ; } } return sb . toString ( ) ; }
Returns the sorted string representation of the left - hand side of a pseudo - Boolean constraint .