Esempio n. 1
0
 static void Main(string[] args)
 {
     using (var qsim = new QuantumSimulator())
     {
         HelloQ.Run(qsim).Wait();
     }
 }
        static void Main(string[] args)
        {
            var qsim = new SumOverPathsSimulator();

            HelloQ.Run(qsim).Wait();
            Console.WriteLine("Hello World!");
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Aircraft Loading Optimization");
            Console.WriteLine("Container volumes: [1, 4, 2, 2, 2]");
            Console.WriteLine("Container weights: [2, 4, 3, 3, 3]");
            Console.WriteLine("Max volume: 6 ([0, 0, 1, 1, 0] in binary)");
            Console.WriteLine("Max weight: 10 ([0, 1, 0, 1, 0] in binary)");
            Console.WriteLine($"Running {TestCount} times");
            Console.WriteLine();

            var results = new Results();

            for (int i = 0; i < TestCount; i++)
            {
                using (var qsim = new QuantumSimulator())
                {
                    var bits     = HelloQ.Run(qsim).Result.Cast <int>().ToArray();
                    var ancillas = bits.Take(4).ToArray();
                    var volume   = Binary.ToBase10(bits.Skip(4).Take(5).ToArray());
                    var part1    = bits.Skip(9).Take(2).ToArray();
                    var part2    = bits.Skip(18).Take(3).ToArray();
                    var oracle   = bits.Skip(21).First();

                    results.Add(string.Join("", part1) + string.Join("", part2));
                }
            }

            Console.WriteLine(results);
            Console.WriteLine("Finished.");
            Console.ReadLine();
        }
Esempio n. 4
0
 static async Task Main(string[] args)
 {
     using (var qsim = new QuantumSimulator())
     {
         await HelloQ.Run(qsim);
     }
 }
Esempio n. 5
0
 static void Main(string[] args)
 {
     using (var qsim = new QuantumSimulator())
     {
         // Run Hello World and wait for finish
         HelloQ.Run(qsim).Wait();
     }
 }
Esempio n. 6
0
 private static void Main()
 {
     using (var qsim = new QuantumSimulator())
     {
         Clear();
         HelloQ.Run(qsim).Wait();
         // prova i valori iniziali
         Result[] initials = new Result[] { Result.Zero, Result.One };
         foreach (Result initial in initials)
         {
             var res = BellTest.Run(qsim, 1000, initial).Result;
             var(numZeros, numOnes, agree) = res;
             WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}");
         }
     }
     ReadKey();
 }
Esempio n. 7
0
        static void Main(string[] args)
        {
            for (int i = 0; i < TestCount; i++)
            {
                using (var qsim = new QuantumSimulator())
                {
                    var bits   = HelloQ.Run(qsim).Result.Cast <int>().ToArray();
                    var result = ToBase10Nodes(bits.Take(8).ToArray());

                    AddResult(string.Join("", result));// + "_" +
                    //string.Join("", bits.Skip(8).ToArray()));
                    //Console.WriteLine(string.Join("", result));
                }
            }

            PrintResults();

            Console.WriteLine("Finished.");
            Console.ReadLine();
        }
Esempio n. 8
0
        static async Task Entanglement()
        {
            double eq = 0, count = 10000;

            using QuantumSimulator sim = new QuantumSimulator();
            await HelloQ.Run(sim);

            for (int i = 0; i < count; i++)
            {
                (Result, Result)x = await EntryPoint.Run(sim, 2);

                var val1 = x.Item1;
                var val2 = x.Item2;

                if (val1 == val2)
                {
                    eq++;
                }
            }
            Console.WriteLine($"Quantum Entanglement Testing \n%age Same = {100 * (eq / count)}; %age Different = {100 * (1 -(eq / count))}.");
            //await PrintMessage.Run(sim, input);
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            int nbExperiments = 10000;
            int oneCount      = 0;

            using (var qsim = new QuantumSimulator())
            {
                for (int i = 0; i < nbExperiments; i++)
                {
                    var r = HelloQ.Run(qsim).Result;
                    if (r.ToString() == "One")
                    {
                        Console.Write("X");
                        oneCount++;
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine(string.Format("\n\nProbability of 1s: {0:P2}", oneCount * 1.0 / nbExperiments));
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            using (var qsim = new QuantumSimulator())
            {
                Client Alice = new Client();
                Client Bob   = new Client();
                Console.WriteLine("Creating Secret Basis Measurement Pattern Between Alice and Bob...");

                IQArray <bool> AlicePattern = new QArray <bool>();
                IQArray <bool> BobPattern   = new QArray <bool>();
                //create secret pattern
                (AlicePattern, BobPattern)     = createBasisMeasurementPatternFromSender.Run(qsim).Result;
                Alice.basisMeassurementPattern = AlicePattern.ToArray();
                Bob.basisMeassurementPattern   = BobPattern.ToArray();
                Console.WriteLine("Representing Alice Pattern");
                Alice.representPattern();

                Console.WriteLine("Representing Bob Pattern");
                Bob.representPattern();
                Console.WriteLine("Both Patterns Should Match");

                Console.WriteLine("Now And Bob Share Secret Pattern!, Alice want to send Bob a secret message using BMP");
                Console.WriteLine("Suggest any message!");

                Alice.message = Console.ReadLine();
                Alice.convertMessageToBitString();
                //running the basis code
                Alice.encode();
                Bob.decode(Alice.encodedMessage);
                Random rnd = new Random();
                int    r   = 0;
                for (int k = 0; k < (Alice.messageInBits.Length / 8); ++k)
                {
                    r = rnd.Next(1, 13);
                    if (k % 2 == 1)
                    {
                        Console.WriteLine("after sending the " + k + "th character the controller pair of qubits entangled with  Bob measuered in 1 the pattern become");
                        for (int l = 0; l < 8; l++)
                        {
                            if (Alice.basisMeassurementPattern[l] == true)
                            {
                                Alice.basisMeassurementPattern[l] = false;
                            }
                            else
                            {
                                Alice.basisMeassurementPattern[l] = true;
                            }
                            Bob.basisMeassurementPattern[l] = Alice.basisMeassurementPattern[l];
                        }
                        Console.WriteLine("new pattern for Alice and Bob!");
                        Alice.representPattern();
                        Bob.representPattern();
                    }
                }

                if (r % 2 == 1)
                {
                    //flipp
                    Console.Out.Write("The pattern will be flipped");
                }

                Console.WriteLine("Decoded Message From Bob Is");
                Console.WriteLine(Bob.decodedMessage);
                HelloQ.Run(qsim).Wait();
                var estimator = new ResourcesEstimator();
                //System.Console.WriteLine(estimator.ToTSV());
                System.Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the number to search");
            int oc = Convert.ToInt32(Console.ReadLine());

            using (var qsim = new QuantumSimulator())
            {
                switch (oc)
                {
                case 0:
                    Oracle0000.Run(qsim).Wait();
                    break;

                case 1:
                    Oracle0001.Run(qsim).Wait();
                    break;

                case 2:
                    Oracle0010.Run(qsim).Wait();
                    break;

                case 3:
                    Oracle0011.Run(qsim).Wait();
                    break;

                case 4:
                    Oracle0100.Run(qsim).Wait();
                    break;

                case 5:
                    Oracle0101.Run(qsim).Wait();
                    break;

                case 6:
                    Oracle0110.Run(qsim).Wait();
                    break;

                case 7:
                    Oracle0111.Run(qsim).Wait();
                    break;

                case 8:
                    Oracle1000.Run(qsim).Wait();
                    break;

                case 9:
                    Oracle1001.Run(qsim).Wait();
                    break;

                case 10:
                    Oracle1010.Run(qsim).Wait();
                    break;

                case 11:
                    Oracle1011.Run(qsim).Wait();
                    break;

                case 12:
                    Oracle1100.Run(qsim).Wait();
                    break;

                case 13:
                    Oracle1101.Run(qsim).Wait();
                    break;

                case 14:
                    Oracle1110.Run(qsim).Wait();
                    break;

                case 15:
                    Oracle1111.Run(qsim).Wait();
                    break;

                default:
                    HelloQ.Run(qsim).Wait();
                    Console.WriteLine("Default Case");
                    break;
                }
            }
        }