示例#1
0
 public Constraint AddAllDifferent(IEnumerable<IntVar> vars)
 {
   Constraint ct = new Constraint(model_);
   AllDifferentConstraintProto alldiff = new AllDifferentConstraintProto();
   foreach (IntVar var in vars)
   {
     alldiff.Vars.Add(var.Index);
   }
   ct.Proto.AllDiff = alldiff;
   return ct;
 }
示例#2
0
        public Constraint AddAllDifferent(IEnumerable <IntVar> vars)
        {
            Constraint ct = new Constraint(model_);
            AllDifferentConstraintProto alldiff = new AllDifferentConstraintProto();

            foreach (IntVar var in vars)
            {
                alldiff.Exprs.Add(GetLinearExpressionProto(var));
            }
            ct.Proto.AllDiff = alldiff;
            return(ct);
        }
示例#3
0
        /**
         * <summary>
         * Adds the constraint <c>AllDifferent(exprs)</c>.
         * </summary>
         */
        public Constraint AddAllDifferent(IEnumerable <LinearExpr> exprs)
        {
            AllDifferentConstraintProto alldiff = new AllDifferentConstraintProto();

            alldiff.Exprs.TrySetCapacity(exprs);
            foreach (LinearExpr expr in exprs)
            {
                alldiff.Exprs.Add(GetLinearExpressionProto(expr));
            }

            Constraint ct = new Constraint(model_);

            ct.Proto.AllDiff = alldiff;
            return(ct);
        }