示例#1
0
        public CustomSumConstraint(String op, String var, CPInstance i)

        {
            varI = var.Trim();
            opI  = op.Trim();


            Variable output = null;

            if (i.variableExists(var))
            {
                isVar  = true;
                output = i.getVarByName(varI);
            }
            else
            {
                isVar = false;
            }

            base.variables = new List <Variable>();

            if (output != null)
            {
                variables.Add(output);
                base.involvedVariables().Add(output);
                output.usedInConstraint(this);
            }

            last_varI  = varI;
            last_opI   = opI;
            last_isVar = isVar;
        }
示例#2
0
        public static Constraint fromSerialization(string s, CPInstance i)
        {
            AllDifferentConstraint c = new AllDifferentConstraint();

            String[] values = s.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            List <Variable> involvedV = new List <Variable>();

            for (int index = 1; index < values.Length; index++)
            {
                Variable v = i.getVarByName(values[index]);
                if (v != null)
                {
                    involvedV.Add(v);
                }
            }

            c.addVariables(involvedV);

            return(c);
        }
示例#3
0
 internal static Variable loadVar(CPInstance i, string v)
 {
     String[] data = v.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
     return(i.getVarByName(data[0]));
 }