Пример #1
0
        public async Task <ExecutionResult> RunAsync(string input, IChannel channel)
        {
            var inputParameters = ParseInputParameters(input, firstParameterInferredName: ParameterNameOperationName);

            var name   = inputParameters.DecodeParameter <string>(ParameterNameOperationName);
            var symbol = SymbolResolver.Resolve(name) as dynamic; // FIXME: Should be IQSharpSymbol.

            if (symbol == null)
            {
                throw new InvalidOperationException($"Invalid operation name: {name}");
            }

            var qsim = new OpenSystemsSimulator(
                ConfigurationSource.ExperimentalSimulatorCapacity,
                ConfigurationSource.ExperimentalSimulatorRepresentation
                );

            if (NoiseModelSource.NoiseModel != null)
            {
                var json = JsonSerializer.Serialize(NoiseModelSource.NoiseModel);
                qsim.NoiseModel = NoiseModelSource.NoiseModel;
            }
            Logger?.LogDebug("Simulating with noise model: {NoiseModel}", JsonSerializer.Serialize(NoiseModelSource.NoiseModel));
            qsim.DisableLogToConsole();
            qsim.OnLog += channel.Stdout;
            qsim.OnDisplayableDiagnostic += channel.Display;
            var operation = symbol.Operation as OperationInfo;
            var value     = await operation.RunAsync(qsim, inputParameters);

            return(value.ToExecutionResult());
        }
Пример #2
0
 public OpenSystemsDumpRegister(OpenSystemsSimulator m) : base(m)
 {
     this.Simulator = m;
 }
Пример #3
0
 public OpenSystemsQubitManager(OpenSystemsSimulator parent, uint capacity)
     : base(capacity)
 {
     this.Parent = parent;
 }
Пример #4
0
 public OpenSystemsDumpMachine(OpenSystemsSimulator m) : base(m)
 {
     this.Simulator = m;
 }