Exemple #1
0
 public void CopyFrom(ResultInfo resultInfo)
 {
     Result = resultInfo.Result;
     PathCost = resultInfo.PathCost;
     ParametersId = resultInfo.ParametersId;
     DistMatrixId = resultInfo.DistMatrixId;
     FlowMatrixId = resultInfo.FlowMatrixId;
 }
        public void ProcessChoosenItems_Ok()
        {
            StandartAlgorithmBuilder builder = Mock.Of<StandartAlgorithmBuilder>();
            IParametersRepository parameters = Mock.Of<ParametersRepository>();
            IDistMatricesRepository distMatrices = Mock.Of<DistMatricesRepository>();
            IFlowMatricesRepository flowMatrices = Mock.Of<FlowMatricesRepository>();
            IResultsInfoRepository resultsInfo = Mock.Of<ResultsInfoRepository>();

            // Arrange
            var controller = new HomeController(builder, parameters, distMatrices, flowMatrices, resultsInfo);
            controller.Request = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            // Act
            var response = controller.Get(10);

            // Assert
            ResultInfo result = new ResultInfo {Id = 10};
            Assert.IsTrue(response.Id == result.Id);
            Assert.AreEqual(10, response.Id);
        }
Exemple #3
0
        public HtmlString ProcessChoosenItems(string parametersId, string distMatrixId, string flowMatrixId)
        {
            Parameters parameters = _parametersRepository.Get(Convert.ToInt32(parametersId));
            DistMatrix distMatrix = _distMatricesRepository.Get(Convert.ToInt32(distMatrixId));
            FlowMatrix flowMatrix = _flowMatricesRepository.Get(Convert.ToInt32(flowMatrixId));

            Stream paramStream = new MemoryStream(Encoding.UTF8.GetBytes(parameters.StringView));
            string graph = string.Format("{0}\n{1}", distMatrix.MatrixView, flowMatrix.MatrixView);
            Stream graphStream = new MemoryStream(Encoding.UTF8.GetBytes(graph));

            _qapAntAlgorithm = _standartAlgorithmBuilder.GetAlgorithm<QapGraph>(paramStream);
            QapGraph qapGraph = new QapGraph().Load(graphStream, _qapAntAlgorithm.NAnts);
            _qapAntAlgorithm.Calculate(qapGraph);

            HtmlString result = new HtmlString(_qapAntAlgorithm.Result);
            int pathCost = _qapAntAlgorithm.BestAnt.PathCost;

            ResultInfo resultInfo = new ResultInfo
            {
                ParametersId = parameters.Id,
                DistMatrixId = distMatrix.Id,
                FlowMatrixId = flowMatrix.Id,
                Result = result.ToString(),
                PathCost = pathCost
            };

            _resultsInfoRepository.Add(resultInfo);
            return result;
        }