コード例 #1
0
        public void OnClock_OnePosEdge_T1()
        {
            var counter = new CycleCounter();

            counter.OnClock(DigitalLevel.PosEdge);

            counter.CycleName.Should().Be(CycleNames.T1);
            counter.MachineCycle.Should().Be(MachineCycleNames.M1);
        }
コード例 #2
0
 private void initIndexCounter()
 {
     // index counter is really only important for sets, because it tells which one of the elements should be enabled
     if (this.modeCounter.Value == RhsEntitySelector.SelectionEnum.Individuals)
     {
         this.indexCounter = CycleCounter.Create(this.entity.Count);
     }
     else
     {
         this.indexCounter = CycleCounter.Create(-1, 0); // keep the value such it will never match the index of the element
     }
 }
コード例 #3
0
        public void OnClock_TwoPosTwoNegEdges_T2()
        {
            var counter = new CycleCounter();

            counter.OnClock(DigitalLevel.PosEdge);
            counter.OnClock(DigitalLevel.NegEdge);
            counter.OnClock(DigitalLevel.PosEdge);
            counter.OnClock(DigitalLevel.NegEdge);

            counter.CycleName.Should().Be(CycleNames.T2);
            counter.MachineCycle.Should().Be(MachineCycleNames.M1);
        }
コード例 #4
0
        private static IEnumerable <IEnumerable <SYMBOL_ENUM> > unAliasProductionRhs(SYMBOL_ENUM symbol,
                                                                                     SYMBOL_ENUM[] expansion,
                                                                                     Production <SYMBOL_ENUM, TREE_NODE> production,
                                                                                     SYMBOL_ENUM startSymbol,
                                                                                     SYMBOL_ENUM syntaxErrorSymbol,
                                                                                     ref UnAliasing change)
        {
            if (production.RhsSymbols.All(it => !it.Equals(symbol)))
            {
                return new[] { production.RhsSymbols }
            }
            ;

            // todo: remove this condition when recovery points will be improved
            if (expansion.Length > 1 &&
                (production.LhsNonTerminal.Equals(startSymbol) || production.RhsSymbols.Any(it => it.Equals(syntaxErrorSymbol))))
            {
                change = UnAliasing.Forbidden;

                return(new[] { production.RhsSymbols });
            }

            change = UnAliasing.Expansion;

            // a lot of memory allocation, but code is much simpler than otherwise

            // for aliased symbol use its expansions, for others -- just the given symbol
            SYMBOL_ENUM[][] replacements = production.RhsSymbols.Select(it => it.Equals(symbol) ? expansion : new[] { it }).ToArray();
            CycleCounter[]  counters     = replacements.Select(it => CycleCounter.Create(it.Length)).ToArray();

            var result = new List <IEnumerable <SYMBOL_ENUM> >();

            do
            {
                // has to pin down collection to avoid local capture
                result.Add(replacements.SyncZip(counters).Select(it => it.Item1[it.Item2.Value]).ToArray());
            }while (counters.Iterate());

            return(result);
        }
コード例 #5
0
ファイル: Simulation.cs プロジェクト: rzeznikm/Kolejki
        public void StartQLearningSimulation(float beta, float gamma, NetworkType type)
        {
            this.beta  = beta;
            this.gamma = gamma;
            int CycleCounter;


            if (type == NetworkType.QLearning)
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter("SimpleQ.csv");
                string header = "beta;gamma;cycle;clients";
                file.WriteLine(header);

                CycleCounter = SimulateQNetworkForParam(beta, gamma);
                List <string> data = new List <string>();
                data.Add(beta.ToString());
                data.Add(gamma.ToString());
                data.Add(CycleCounter.ToString());
                data.Add(maxClient.ToString());
                file.WriteLine(string.Join(";", data.ToArray()) + ";" + QNetwork.getNodeTotalSummary());

                file.Close();
            }
            else
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter("Random.csv");
                string header = "cycle;clients";
                file.WriteLine(header);
                for (int i = 0; i < 100; i++)
                {
                    CycleCounter = SimulateRNetworkForParam();
                    List <string> data = new List <string>();
                    data.Add(CycleCounter.ToString());
                    data.Add(maxClient.ToString());
                    file.WriteLine(string.Join(";", data.ToArray()) + ";" + RNetwork.getNodeTotalSummary());
                }
                file.Close();
            }
        }