code: private void exk(final EncodingResult result, final Variable[] vars, int rhs) {
      if (rhs < 0)
        throw new IllegalArgumentException("Invalid right hand side of cardinality constraint: " + rhs);
      if (rhs > vars.length) {
        result.addClause();
        return;
      }
      if (rhs == 0) {
        for (final Variable var : vars)
          result.addClause(var.negate());
        return;
      }
      if (rhs == vars.length) {
        for (final Variable var : vars)
          result.addClause(var);
        return;
      }
      switch (this.config().exkEncoder) {
        case TOTALIZER:
          if (this.exkTotalizer == null)
            this.exkTotalizer = new CCEXKTotalizer();
          this.exkTotalizer.build(result, vars, rhs);
          break;
        case CARDINALITY_NETWORK:
          if (this.exkCardinalityNetwork == null)
            this.exkCardinalityNetwork = new CCEXKCardinalityNetwork();
          this.exkCardinalityNetwork.build(result, vars, rhs);
          break;
        case BEST:
          this.bestEXK(vars.length).build(result, vars, rhs);
          break;
        default:
          throw new IllegalStateException("Unknown exactly-k encoder: " + this.config().exkEncoder);
      }
    }
docs: Encodes an exactly-k constraint.
  @param result the result
  @param vars   the variables of the constraint
  @param rhs    the right hand side of the constraint