Exemple #1
0
        public static List <GenericInstantiator.EdgeAggregator> InstantiateEquation(GroundedClause clause)
        {
            List <GenericInstantiator.EdgeAggregator> newGrounded = new List <GenericInstantiator.EdgeAggregator>();

            if (!(clause is SegmentEquation))
            {
                return(newGrounded);
            }

            Equation original = clause as Equation;

            Equation     copyEq    = (Equation)original.DeepCopy();
            FlatEquation flattened = new FlatEquation(copyEq.lhs.CollectTerms(), copyEq.rhs.CollectTerms());

            if (flattened.lhsExps.Count != 1 || flattened.rhsExps.Count != 1)
            {
                return(newGrounded);
            }

            KeyValuePair <int, int> ratio = Utilities.RationalRatio(flattened.lhsExps[0].multiplier, flattened.rhsExps[0].multiplier);

            if (ratio.Key != -1)
            {
                if (ratio.Key <= 2 && ratio.Value <= 2)
                {
                    SegmentRatio prop = new SegmentRatio((Segment)flattened.lhsExps[0].DeepCopy(),
                                                         (Segment)flattened.rhsExps[0].DeepCopy());
                    prop.MakeProportionValueKnown();

                    List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(original);
                    newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, prop, atomAnnotation));
                }
            }

            return(newGrounded);
        }
Exemple #2
0
        public static List<GenericInstantiator.EdgeAggregator> InstantiateEquation(GroundedClause clause)
        {
            List<GenericInstantiator.EdgeAggregator> newGrounded = new List<GenericInstantiator.EdgeAggregator>();

            if (!(clause is SegmentEquation)) return newGrounded;

            Equation original = clause as Equation;

            Equation copyEq = (Equation)original.DeepCopy();
            FlatEquation flattened = new FlatEquation(copyEq.lhs.CollectTerms(), copyEq.rhs.CollectTerms());

            if (flattened.lhsExps.Count != 1 || flattened.rhsExps.Count != 1) return newGrounded;

            KeyValuePair<int, int> ratio = Utilities.RationalRatio(flattened.lhsExps[0].multiplier, flattened.rhsExps[0].multiplier);
            if (ratio.Key != -1)
            {
                if (ratio.Key <= 2 && ratio.Value <= 2)
                {
                    SegmentRatio prop = new SegmentRatio((Segment)flattened.lhsExps[0].DeepCopy(),
                                                         (Segment)flattened.rhsExps[0].DeepCopy());
                    prop.MakeProportionValueKnown();

                    List<GroundedClause> antecedent = Utilities.MakeList<GroundedClause>(original);
                    newGrounded.Add(new GenericInstantiator.EdgeAggregator(antecedent, prop, atomAnnotation));
                }
            }

            return newGrounded;
        }