コード例 #1
0
        public CountXYConstraint(String selectedVar, String countedVar, String operatorVar, CPInstance i)
        {
            this.selectedVar = selectedVar;
            this.countedVar  = countedVar;
            this.operatorVar = operatorVar;

            lastVar   = selectedVar;
            lastCount = countedVar;
            lastOP    = operatorVar;

            Variable output = null;

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

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

            if (output != null)
            {
                variables.Add(output);
                base.involvedVariables().Add(output);
                output.usedInConstraint(this);
            }
        }
コード例 #2
0
        public RouteConstraint(string lengthVar, int[][] distances, List <int> domain, CPInstance i)

        {
            this.lengthVar = lengthVar;
            this.distances = distances;
            this.domain    = domain;


            lastLengthVar = lengthVar;
            lastDistances = distances;
            lastDomain    = domain;

            Variable output = null;

            if (i.variableExists(lengthVar.Trim()))
            {
                lastWasVar = true;
                output     = i.getVarByName(lengthVar.Trim());
            }
            else
            {
                lastWasVar = false;
            }

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

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