private static bool ConstraintCheck(EquationNode en, object constraint, out object output)
        {
            output = null;
            var eqGoal = constraint as EqGoal;

            if (eqGoal == null)
            {
                return(false);
            }
            var variable = eqGoal.Lhs as Var;

            if (variable != null && en.Satisfy(variable))
            {
                var lst = new List <Tuple <object, object> >();


                var equation = en.Equation;
                Debug.Assert(equation != null);

                equation.Reify(eqGoal);
                for (int i = 0; i < equation.CachedEntities.Count; i++)
                {
                    var cachedEq = equation.CachedEntities.ToList()[i] as Equation;
                    if (cachedEq == null)
                    {
                        continue;
                    }

                    object obj1;
                    bool   tempResult = cachedEq.IsEqGoal(out obj1);
                    if (tempResult)
                    {
                        var gGoal = obj1 as EqGoal;
                        Debug.Assert(gGoal != null);
                        lst.Add(new Tuple <object, object>(en, gGoal));
                    }
                }

                lst.Add(new Tuple <object, object>(constraint, en));
                //output = en.Equation;
                output = lst;
                return(true);
            }
            return(false);
        }
示例#2
0
        public static bool Satisfy(this EquationNode eqNode, string variable)
        {
            var newVar = new Var(variable);

            return(eqNode.Satisfy(newVar));
        }
        private static bool ConstraintCheck(EquationNode en, object constraint, out object output)
        {
            output = null;
            var eqGoal = constraint as EqGoal;
            if (eqGoal == null) return false;
            var variable = eqGoal.Lhs as Var;
            if (variable != null && en.Satisfy(variable))
            {
                var lst = new List<Tuple<object, object>>();
                

                var equation = en.Equation;
                Debug.Assert(equation != null);

                equation.Reify(eqGoal);
                for (int i = 0; i < equation.CachedEntities.Count; i++)
                {
                    var cachedEq = equation.CachedEntities.ToList()[i] as Equation;
                    if (cachedEq == null) continue;

                    object obj1;
                    bool tempResult = cachedEq.IsEqGoal(out obj1);
                    if (tempResult)
                    {
                        var gGoal = obj1 as EqGoal;
                        Debug.Assert(gGoal != null);
                        lst.Add(new Tuple<object, object>(en, gGoal));
                    }
                }

                lst.Add(new Tuple<object, object>(constraint, en));
                //output = en.Equation;
                output = lst;
                return true;
            }
            return false;
        }