code: private void amk(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) // there is no constraint
        return;
      if (rhs == 0) { // no variable can be true
        for (final Variable var : vars)
          result.addClause(var.negate());
        return;
      }
      switch (this.config().amkEncoder) {
        case TOTALIZER:
          if (this.amkTotalizer == null)
            this.amkTotalizer = new CCAMKTotalizer();
          this.amkTotalizer.build(result, vars, rhs);
          break;
        case MODULAR_TOTALIZER:
          if (this.amkModularTotalizer == null)
            this.amkModularTotalizer = new CCAMKModularTotalizer(this.f);
          this.amkModularTotalizer.build(result, vars, rhs);
          break;
        case CARDINALITY_NETWORK:
          if (this.amkCardinalityNetwork == null)
            this.amkCardinalityNetwork = new CCAMKCardinalityNetwork();
          this.amkCardinalityNetwork.build(result, vars, rhs);
          break;
        case BEST:
          this.bestAMK(vars.length).build(result, vars, rhs);
          break;
        default:
          throw new IllegalStateException("Unknown at-most-k encoder: " + this.config().amkEncoder);
      }
    }
docs: Encodes an at-most-k constraint.
  @param result the result
  @param vars   the variables of the constraint
  @param rhs    the right hand side of the constraint