Ejemplo n.º 1
0
        private void CreateIntervalStartEndConstraint()
        {
            GKOAttribute     startAttr     = this.KnowledgeBase.Attributes[8];
            GKOAttribute     endAttr       = this.KnowledgeBase.Attributes[9];
            DomainConstraint domConstraint = DomainConstraint.IntervalStartBeforeEndConstraint(startAttr, endAttr, false);

            this.DomainConstraints.Add(domConstraint);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a domain constraint restricting an attribute to be greater than the MetricDomain max value - 1
        /// </summary>
        /// <returns></returns>
        public static DomainConstraint MaxValueConstraint(GKOAttribute attribute, GKOIntDomain metricDomain)
        {
            BinaryRelation   lessOrEquals  = StructuralRelationsManager.GetRelation(RelationFamilyNames.MetricRelationsName, MetricRelationNames.LessOrEqualsN);
            DomainConstraint maxConstraint = new DomainConstraint("Metric max value constraint", lessOrEquals, false);

            maxConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(new ComponentFilter(), attribute));
            maxConstraint.DomainRelationParts.Add(new MetricDomainRelationPart(metricDomain.MaxValue, metricDomain));

            return(maxConstraint);
        }
Ejemplo n.º 3
0
        public Node(GKOComponent component, GKOAttribute attribute)
        {
            if (component == null)
            {
                throw new ArgumentNullException("The component must be set!");
            }
            if (attribute != null && !component.AttributeValues.ContainsKey(attribute))
            {
                throw new InvalidOperationException("The component does not have this attribute!");
            }

            this.Component = component;
            this.Attribute = attribute;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a domain constraint restricting the start of an interval to be before (or equal) to its end
        /// </summary>
        /// <param name="startAttribute">The start of interval attribute </param>
        /// <param name="endAttribute">The end of interval attribute </param>
        /// <param name="allowZeroIntervals">Specifies whether to use "Less than" or "Less or equals" relations, which enables/disables the generation of zero-length intervals</param>
        /// <returns></returns>
        public static DomainConstraint IntervalStartBeforeEndConstraint(GKOAttribute startAttribute, GKOAttribute endAttribute, bool allowZeroIntervals)
        {
            BinaryRelation   relation           = StructuralRelationsManager.GetRelation(RelationFamilyNames.MetricRelationsName, allowZeroIntervals ? MetricRelationNames.LessOrEquals : MetricRelationNames.LessThan);
            DomainConstraint intervalConstraint = new DomainConstraint("Interval start/end constraint", relation, false);

            intervalConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(new ComponentFilter(), startAttribute));
            intervalConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(
                                                           new ComponentFilter()
            {
                SameAsDomainRelationPartNr = 1
            },
                                                           endAttribute));

            return(intervalConstraint);
        }
        /// <summary>
        /// Finds the AttributeDomainRelationPart for a specific attribute and IRelationPart
        /// </summary>
        /// <param name="relPart">The relation part for which to generate the attribute rel part</param>
        /// <param name="attribute">The attribute to apply</param>
        /// <returns></returns>
        private AttributeDomainRelationPart GenerateRelationPart(IDomainRelationPart relPart, GKOAttribute attribute)
        {
            AttributeDomainRelationPart attributePart;

            if (relPart is ComponentDomainRelationPart)
            {
                attributePart = new AttributeDomainRelationPart((relPart as ComponentDomainRelationPart).Filter, attribute);
            }
            else if (relPart is AttributeDomainRelationPart)
            {
                attributePart           = (relPart as AttributeDomainRelationPart);
                attributePart.Attribute = attribute;
            }
            else
            {
                throw new InvalidOperationException(string.Format("The Interval Algebra to metric domain constraint '{0}' has invalid relation parts", this.Name));
            }

            return(attributePart);
        }
        /// <summary>
        /// Cretes a new domain constraint which constraints which requires a relation between the matched components.
        /// </summary>
        /// <param name="name">The unique name of the domain constraint.</param>
        /// <param name="requiredRelation">The relation between the matched components.</param>
        /// <param name="canBeViolated">Set to true for soft constraint, false for hard constraint</param>
        /// <param name="comp1IntervalStart">The attribute for the start of the first interval</param>
        /// <param name="comp1IntervalEnd">The attribute for the end of the first interval</param>
        /// <param name="comp2IntervalStart">The attribute for the start of the second interval</param>
        /// <param name="comp2IntervalEnd">The attribute for the end of the second interval</param>
        public IaToMetricDomainConstraint(string name, BinaryRelation requiredRelation, bool canBeViolated, GKOAttribute comp1IntervalStart, GKOAttribute comp1IntervalEnd, GKOAttribute comp2IntervalStart, GKOAttribute comp2IntervalEnd)
            : base(name, requiredRelation, canBeViolated)
        {
            if (requiredRelation.RelationFamily != StructuralRelationsManager.IntervalAlgebra)
            {
                throw new ArgumentNullException("The required relation has to be from the Interval Algebra!");
            }
            if (comp1IntervalStart == null || comp2IntervalStart == null || comp1IntervalEnd == null || comp2IntervalEnd == null)
            {
                throw new ArgumentNullException("All interval attributes should be set!");
            }

            this.Comp1IntervalStart = comp1IntervalStart;
            this.Comp1IntervalEnd   = comp1IntervalEnd;
            this.Comp2IntervalStart = comp2IntervalStart;
            this.Comp2IntervalEnd   = comp2IntervalEnd;
        }
 public AttributeFilter(GKOAttribute attribute, List <string> allowedValues)
 {
     this.Attribute     = attribute;
     this.AllowedValues = allowedValues;
 }