for ( int i=0; i<m ; i++)
{
poslits [ i ] = v [ i ] [ j ] . **getPosLit** ( ) ; neglits [ i ] = v [ i ] [ j ] . **getNegLit** ( ) ;
}
p . addConstraint ( makeLeq ( coeffs , **poslits** , 1 ) ) ;
p . addConstraint ( makeLeq ( coeffs , **neglits** , m−1) ) ;
}
4. Create the capacity constraints and assign them the tag 2.

setTags ( 2 ) ;
for ( int i=0; i<m ; i++)
{
Literal [ ] lits = new **Literal** [ n ] ;
for ( int j=0; j<n ; j++)
lits [ j ] = v [ i ] [ j ] . **getPosLit** ( ) ;
p . addConstraint ( makeLeq ( weights , lits , **capacities** [ i ] ) ) ;
}

5. Create the output problem.
OutputProblem out = new **CNFProblem** ( ) ;

6. Create the two encoders that will be used to translate the input constraints: the bdd **encoder will be**
used to translate the unicity constraints (tagged with 1), and the bargraph encoder will be used to translate the capacity constraints (tagged with 2).

Encoder2cnf bdd = new **CNFbddEncoder** ( ) ;
Encoder2cnf bg = new **CNFbargraphEncoder** ( ) ;
out . **assignEncoder** ( 1 , bdd ) ; out . **assignEncoder** ( 2 , bg ) ;
7. Read the input model, which runs the translation process, **and print the result as a string.**
out . **read** ( p ) ;
System . out . println ( out . **getOutput** ( ) ) ;

## 5 Perspectives

The following evolutions are planned.

## Predicting The Size Of The Input Formulae

The size of the formula resulting from the translation of each input constraint is a critical parameter for the choice of the encodings. The interface Encoder **will include a method providing this information.**

## Automatic Choice Of The Encoders

Assigning a dedicated tag to any constraint will ensure that **the encoder to use for translating this constraint**
will be automatically selected accordingly to both the size **of the output formula and the inference power of** unit propagation on this formula.

## Clauses As Input Constraints

It will be allowed to add clauses as input constraints. These **clauses will be directly added to the output**
problem, in a way to allow to deal with input problems that are **specified with both clauses and pseudoBoolean formulae.**