Beispiel #1
0
        /**
         * <summary>
         * Adds <c> ForbiddenAssignments(variables)</c>.
         * </summary>
         *
         * <remarks>A ForbiddenAssignments constraint is a constraint on an array of variables where the list of
         * impossible combinations is provided in the tuples list.
         * </remarks>
         *
         * <param name="vars"> a list of variables</param>
         * <returns> an instance of the TableConstraint class without any tuples. Tuples can be added
         * directly to the table constraint
         * </returns>
         */
        public TableConstraint AddForbiddenAssignments(IEnumerable <IntVar> vars)
        {
            TableConstraint ct = AddAllowedAssignments(vars);

            ct.Proto.Table.Negated = true;
            return(ct);
        }
Beispiel #2
0
        /**
         * <summary>
         * Adds <c> AllowedAssignments(variables)</c>.
         * </summary>
         *
         * <remarks>An AllowedAssignments constraint is a constraint on an array of variables that forces, when
         * all variables are fixed to a single value, that the corresponding list of values is equal to
         * one of the tuples of the tupleList.
         * </remarks>
         *
         * <param name="vars"> a list of variables</param>
         * <returns> an instance of the TableConstraint class without any tuples. Tuples can be added
         * directly to the table constraint
         * </returns>
         */
        public TableConstraint AddAllowedAssignments(IEnumerable <IntVar> vars)
        {
            TableConstraintProto table = new TableConstraintProto();

            table.Vars.TrySetCapacity(vars);
            foreach (IntVar var in vars)
            {
                table.Vars.Add(var.Index);
            }

            TableConstraint ct = new TableConstraint(model_);

            ct.Proto.Table = table;
            return(ct);
        }