Beispiel #1
0
        public void When_ConvertingQubits_To_Groups_TheCorrectGroups_AreReturned()
        {
            SetUp();
            var result = _converter.DivideInputIntoGroupsByQubits(_originalInput, _qubitsGroups);

            DefaultAssertion(result);
        }
        /// <summary>
        /// Gets the optimal solution based on user's input, maxResults and filter.
        /// </summary>
        /// <param name="input">User's input</param>
        /// <param name="qubitsResultsFilter">Optional. A filter to filter out the results.</param>
        /// <param name="maxResults">Maximum amount of results to return. -1 as default for unlimited amount.</param>
        /// <returns></returns>
        public IResponse <IEnumerable <IBinaryGroup <InputType> > > Resolve(IEnumerable <InputType> input, Func <IEnumerable <short>, bool> qubitsResultsFilter = null, int maxResults = -1)
        {
            if (GetBreakingUsecasesResult(input, out var response))
            {
                return(response);                                                                                                                                        //If input is broken or can be resolved immediately, do it and return.
            }
            var couplingsAndBiases = _dataExtractionFacade.GetCouplingsAndBiases(input);                                                                                 //Extract couplings and biases

            var qubitsResults = _resolver.Resolve(input, couplingsAndBiases.Biases, couplingsAndBiases.Couplings);                                                       //Pass extracted data to resolver and get the result

            var finalGroups = _qubitsToGroupsConverter.DivideInputIntoGroupsByQubits(input, qubitsResults.Select(item => item.Qubits), maxResults, qubitsResultsFilter); //Convert result to groups

            return(CreateResponseFromGroups(finalGroups));                                                                                                               //Wrap the groups into a Response object with error code and message if neccesary.
        }