Esempio n. 1
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;
        }
Esempio n. 2
0
 public IList<IVertex> Calculate(QapGraph input)
 {
     Graph = input;
     if (Graph != null)
     {
         Run();
     }
     if (BestAnt != null)
     {
         return BestAnt.VisitedVetecies;
     }
     return null;
 }