Beispiel #1
0
        static void Main(string[] args)
        {
            //Simple Simulation
            //Samples.SimpleSimulation ss = new Samples.SimpleSimulation();
            //ss.run();
            /////////
            //Simple Decide
            //Samples.SimpleDecide sd = new Samples.SimpleDecide();
            //sd.run();
            /////////
            //Simple Shared Queue
            //Samples.SimpleSharedQueue ssd = new Samples.SimpleSharedQueue();
            //for (int i = 0; i <= 20;i++ )
            //    ssd.run();
            //Able and Baker
            //Samples.AbleBaker ab = new Samples.AbleBaker();
            //ab.run();
            ///////
            //Chain Maybe
            //Samples.Chain chain = new Samples.Chain();
            //chain.run();
            ///////
            //Inventory Sample
            //Samples.InventorySample inv = new Samples.InventorySample();
            //Dictionary<string, int> dict = new Dictionary<string, int>();
            //for (int i = 0; i < 15; i++)
            //    dict.Add((20 * i).ToString() + "-" + (20 * (i + 1)).ToString(), 0);
            //List<string> keys = dict.Keys.ToList();
            //double sum = 0;
            //for (int i = 0; i < 400; i++)
            //{
            //    double a = inv.run();
            //    sum += a;
            //    int j = (int)a / 20;
            //    dict[keys[j]] = dict[keys[j]] + 1;

            //}
            //sum = sum / 400;
            //Samples.SimpleProbShare sps = new Samples.SimpleProbShare();
            //sps.run();
            //Console.Read();
            //
            for (int i = 0; i <= 20; i++)
            {
                Uniform un = new Uniform(0.86, 1.56);
                Console.WriteLine(un.NextDouble());
            }
            Console.ReadLine();
        }
Beispiel #2
0
 public Discrete(List<long> values, List<double> cumulative_probabilities, int seed)
     : base(seed)
 {
     if (values.Count != cumulative_probabilities.Count)
         throw new Exception("Values and Probabilities sizes are different");
     Probabilitieslong = new List<Tuple<long, double>>();
     double last_prob = 0;
     for (int i = 0; i < values.Count; i++)
     {
         if (cumulative_probabilities[i] <= last_prob)
             throw new Exception("Probabilities are not in correct format");
         Probabilitieslong.Add(new Tuple<long, double>(values[i], cumulative_probabilities[i]));
     }
     Uni_Rand = new Uniform(0, 1, seed);
 }