示例#1
0
        /// <summary>
        /// Is Dominated
        /// </summary>
        public bool IsDominated(ObjectiveItem <T> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(false);
            }
            else if (null == other)
            {
                return(false);
            }
            else if (!ReferenceEquals(Owner, other.Owner))
            {
                return(false);
            }

            foreach (var description in Owner.ObjectiveDescriptions)
            {
                double v1 = this.ObjectiveValue(description);
                double v2 = other.ObjectiveValue(description);

                if (v2 > v1 && description.Goal == ObjectiveGoal.Min)
                {
                    return(false);
                }

                if (v2 < v1 && description.Goal == ObjectiveGoal.Max)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Dominance:
        ///  +1: left dominates right
        ///   0: left and right are not comparable
        ///  -1: right dominates left
        /// </summary>
        public static int Dominance(ObjectiveItem <T> left, ObjectiveItem <T> right)
        {
            if (ReferenceEquals(left, right))
            {
                return(0);
            }
            else if (null == left)
            {
                return(-1);
            }
            else if (null == right)
            {
                return(1);
            }
            else if (!ReferenceEquals(left.Owner, right.Owner))
            {
                return(0);
            }

            bool canBeBetter = true;
            bool canBeWorse  = true;

            foreach (var description in left.Owner.ObjectiveDescriptions)
            {
                double v1 = left.ObjectiveValue(description);
                double v2 = right.ObjectiveValue(description);

                if (v1 > v2 && description.Goal == ObjectiveGoal.Min)
                {
                    canBeBetter = false;
                }
                else if (v1 < v2 && description.Goal == ObjectiveGoal.Max)
                {
                    canBeBetter = false;
                }

                if (v2 > v1 && description.Goal == ObjectiveGoal.Min)
                {
                    canBeWorse = false;
                }
                else if (v2 < v1 && description.Goal == ObjectiveGoal.Max)
                {
                    canBeWorse = false;
                }

                if (!canBeBetter && !canBeWorse)
                {
                    return(0);
                }
            }

            if (canBeBetter)
            {
                return(1);
            }
            else if (canBeWorse)
            {
                return(-1);
            }

            return(0);
        }