예제 #1
0
        public void AddCouplet(int?stockTypeId, int flowTypeId)
        {
#if DEBUG
            if (stockTypeId.HasValue)
            {
                Debug.Assert(stockTypeId.Value > 0);
            }

            Debug.Assert(flowTypeId > 0);
#endif
            string Key = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", LookupKeyUtilities.GetOutputCollectionKey(stockTypeId), flowTypeId);

            if (!this.m_LookAside.ContainsKey(Key))
            {
                LateralFlowCouplet couplet = new LateralFlowCouplet();

                couplet.StockTypeId = stockTypeId;
                couplet.FlowTypeId  = flowTypeId;

                this.m_Couplets.Add(couplet);
                this.m_LookAside.Add(Key, couplet);
            }

            Debug.Assert(this.m_Couplets.Count == this.m_LookAside.Count);
        }
예제 #2
0
 protected override FiveIntegerLookupKey GetKeyForItem(OutputStock item)
 {
     return(new FiveIntegerLookupKey(
                item.StratumId,
                LookupKeyUtilities.GetOutputCollectionKey(item.SecondaryStratumId),
                LookupKeyUtilities.GetOutputCollectionKey(item.TertiaryStratumId),
                item.StateClassId,
                item.StockGroupId));
 }
 internal int GetSecondaryStratumIdKey(int?value)
 {
     if (this.m_SummaryOmitSecondaryStrata)
     {
         return(Constants.OUTPUT_COLLECTION_WILDCARD_KEY);
     }
     else
     {
         return(LookupKeyUtilities.GetOutputCollectionKey(value));
     }
 }
예제 #4
0
 protected override FifteenIntegerLookupKey GetKeyForItem(OutputFlow item)
 {
     return(new FifteenIntegerLookupKey(
                item.FromStratumId,
                LookupKeyUtilities.GetOutputCollectionKey(item.FromSecondaryStratumId),
                LookupKeyUtilities.GetOutputCollectionKey(item.FromTertiaryStratumId),
                item.FromStateClassId,
                LookupKeyUtilities.GetOutputCollectionKey(item.FromStockTypeId),
                LookupKeyUtilities.GetOutputCollectionKey(item.TransitionTypeId),
                item.ToStratumId,
                item.ToStateClassId,
                LookupKeyUtilities.GetOutputCollectionKey(item.ToStockTypeId),
                item.FlowGroupId,
                LookupKeyUtilities.GetOutputCollectionKey(item.TransferToStratumId),
                LookupKeyUtilities.GetOutputCollectionKey(item.TransferToSecondaryStratumId),
                LookupKeyUtilities.GetOutputCollectionKey(item.TransferToTertiaryStratumId),
                LookupKeyUtilities.GetOutputCollectionKey(item.TransferToStateClassId),
                LookupKeyUtilities.GetOutputCollectionKey(item.TransferToMinimumAge)));
 }
        private void RecordSummaryFlowOutputData(
            int timestep,
            Cell cell,
            DeterministicTransition deterministicPathway,
            Transition probabilisticPathway,
            FlowPathway flowPathway,
            double flowAmount)
        {
            int?TransitionTypeId = null;
            int StratumIdDest    = cell.StratumId;
            int StateClassIdDest = cell.StateClassId;

            if (probabilisticPathway != null)
            {
                TransitionTypeId = probabilisticPathway.TransitionTypeId;

                if (probabilisticPathway.StratumIdDestination.HasValue)
                {
                    StratumIdDest = probabilisticPathway.StratumIdDestination.Value;
                }

                if (probabilisticPathway.StateClassIdDestination.HasValue)
                {
                    StateClassIdDest = probabilisticPathway.StateClassIdDestination.Value;
                }
            }
            else
            {
                if (deterministicPathway != null)
                {
                    if (deterministicPathway.StratumIdDestination.HasValue)
                    {
                        StratumIdDest = deterministicPathway.StratumIdDestination.Value;
                    }

                    if (deterministicPathway.StateClassIdDestination.HasValue)
                    {
                        StateClassIdDest = deterministicPathway.StateClassIdDestination.Value;
                    }
                }
            }

            if (this.m_STSimTransformer.IsOutputTimestep(
                    timestep,
                    this.m_SummaryFlowOutputTimesteps,
                    this.m_CreateSummaryFlowOutput))
            {
                FlowType t = this.m_FlowTypes[flowPathway.FlowTypeId];

                foreach (FlowGroupLinkage l in t.FlowGroupLinkages)
                {
                    if (!l.FlowGroup.OutputFilter.HasFlag(Constants.OutputFilter.Tabular))
                    {
                        continue;
                    }

                    FifteenIntegerLookupKey k = new FifteenIntegerLookupKey(
                        cell.StratumId,
                        GetSecondaryStratumIdKey(cell),
                        GetTertiaryStratumIdKey(cell),
                        cell.StateClassId,
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.FromStockTypeId),
                        LookupKeyUtilities.GetOutputCollectionKey(TransitionTypeId),
                        StratumIdDest,
                        StateClassIdDest,
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.ToStockTypeId),
                        l.FlowGroup.Id,
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToStratumId),
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToSecondaryStratumId),
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToTertiaryStratumId),
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToStateClassId),
                        LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToMinimumAge));

                    if (this.m_SummaryOutputFlowRecords.Contains(k))
                    {
                        OutputFlow r = this.m_SummaryOutputFlowRecords[k];
                        r.Amount += (flowAmount * l.Value);
                    }
                    else
                    {
                        OutputFlow r = new OutputFlow(
                            cell.StratumId,
                            GetSecondaryStratumIdValue(cell),
                            GetTertiaryStratumIdValue(cell),
                            cell.StateClassId,
                            flowPathway.FromStockTypeId,
                            TransitionTypeId,
                            StratumIdDest,
                            StateClassIdDest,
                            flowPathway.ToStockTypeId,
                            l.FlowGroup.Id,
                            flowPathway.TransferToStratumId,
                            flowPathway.TransferToSecondaryStratumId,
                            flowPathway.TransferToTertiaryStratumId,
                            flowPathway.TransferToStateClassId,
                            flowPathway.TransferToMinimumAge,
                            flowAmount * l.Value);

                        this.m_SummaryOutputFlowRecords.Add(r);
                    }
                }
            }
        }