Ejemplo n.º 1
0
 public TransitionOrderMap(TransitionOrderCollection orders)
 {
     foreach (TransitionOrder t in orders)
     {
         this.AddTransitionOrder(t);
     }
 }
Ejemplo n.º 2
0
        private void AddTransitionOrder(TransitionOrder order)
        {
            TransitionOrderCollection l = this.m_Map.GetItemExact(order.Iteration, order.Timestep);

            if (l == null)
            {
                l = new TransitionOrderCollection();
                this.m_Map.AddItem(order.Iteration, order.Timestep, l);
            }

            l.Add(order);

            this.m_HasItems = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reorders the list of shufflable transition groups
        /// </summary>
        /// <param name="iteration"></param>
        /// <param name="timestep"></param>
        /// <param name="groups"></param>
        /// <remarks></remarks>
        private void ReorderShufflableTransitionGroups(int iteration, int timestep)
        {
            TransitionOrderCollection orders = this.m_TransitionOrderMap.GetTransitionOrders(iteration, timestep);

            if (orders == null)
            {
                ShuffleUtilities.ShuffleList(this.m_ShufflableTransitionGroups, this.m_RandomGenerator.Random);
            }
            else
            {
                this.ReorderShufflableTransitionGroups(orders);
            }

#if DEBUG
            this.VALIDATE_SHUFFLABLE_GROUPS();
#endif
        }
Ejemplo n.º 4
0
        public TransitionOrderCollection GetTransitionOrders(int iteration, int timestep)
        {
            if (!this.m_HasItems)
            {
                return(null);
            }

            TransitionOrderCollection l = this.m_Map.GetItem(iteration, timestep);

            if (l == null)
            {
                return(null);
            }

            Debug.Assert(l.Count > 0);
            return(l);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reorders the list of shufflable transition groups
        /// </summary>
        /// <param name="orders"></param>
        /// <remarks></remarks>
        private void ReorderShufflableTransitionGroups(TransitionOrderCollection orders)
        {
            //If there are less than two transition groups there is no reason to continue

            if (this.m_ShufflableTransitionGroups.Count <= 1)
            {
                return;
            }

            //Reset all transition group order values

            foreach (TransitionGroup tg in this.m_ShufflableTransitionGroups)
            {
                tg.Order = Constants.DEFAULT_TRANSITION_ORDER;
            }

            //Apply the new ordering from the order collection

            Debug.Assert(this.m_TransitionGroups.Count == this.m_ShufflableTransitionGroups.Count);

            foreach (TransitionOrder order in orders)
            {
                if (this.m_TransitionGroups.Contains(order.TransitionGroupId))
                {
                    Debug.Assert(this.m_ShufflableTransitionGroups.Contains(this.m_TransitionGroups[order.TransitionGroupId]));
                    this.m_TransitionGroups[order.TransitionGroupId].Order = order.Order;
                }
            }

            //Sort by the transition groups by the order value

            this.m_ShufflableTransitionGroups.Sort((TransitionGroup t1, TransitionGroup t2) =>
            {
                return(t1.Order.CompareTo(t2.Order));
            });

            //Find the number of times each order appears.  If it appears more than
            //once then shuffle the subset of transtion groups with this order.

            Dictionary <double, int> OrderCounts = new Dictionary <double, int>();

            foreach (TransitionOrder o in orders)
            {
                if (!OrderCounts.ContainsKey(o.Order))
                {
                    OrderCounts.Add(o.Order, 1);
                }
                else
                {
                    OrderCounts[o.Order] += 1;
                }
            }

            //If any order appears more than once then it is a subset
            //that we need to shuffle.  Note that there may be a subset
            //for the default order.

            foreach (double d in OrderCounts.Keys)
            {
                if (OrderCounts[d] > 1)
                {
                    ShuffleUtilities.ShuffleSubList(
                        this.m_ShufflableTransitionGroups,
                        this.GetMinOrderIndex(d),
                        this.GetMaxOrderIndex(d),
                        this.m_RandomGenerator.Random);
                }
            }

            if (this.DefaultOrderHasSubset())
            {
                ShuffleUtilities.ShuffleSubList(
                    this.m_ShufflableTransitionGroups,
                    this.GetMinOrderIndex(Constants.DEFAULT_TRANSITION_ORDER),
                    this.GetMaxOrderIndex(Constants.DEFAULT_TRANSITION_ORDER),
                    this.m_RandomGenerator.Random);
            }
        }