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; }
public HtmlString ProcessMatrix(GraphViewModel graph) { if (graph == null) { return new HtmlString(null); } _qapAntAlgorithm = (QapAntAlgorithm) Session["algorithm"]; QapAntAlgorithm savedAlgorithm = (QapAntAlgorithm) QapAntAlgorithm.DeepObjectClone(_qapAntAlgorithm); if (_qapAntAlgorithm == null) { _qapAntAlgorithm = (QapAntAlgorithm) _standartAlgorithmBuilder.GetAlgorithm<QapGraph>(1, 2, 100, 50); } _qapAntAlgorithm.Graph.SetGraphMatrices(_qapAntAlgorithm.NAnts, graph.DistGraph, graph.FlowGraph); _qapAntAlgorithm.Run(); string result = _qapAntAlgorithm.Result; Session["algorithm"] = savedAlgorithm; return new HtmlString(result); }
public ActionResult LoadFile(HttpPostedFileBase file) { InputParametersViewModel inputParameters = null; if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); if (fileName != null) { _qapAntAlgorithm = (QapAntAlgorithm) _standartAlgorithmBuilder.GetAlgorithm<QapGraph>(1, 1, 100, 50); _qapAntAlgorithm.Calculate(new QapGraph().Load(file.InputStream, _qapAntAlgorithm.NAnts)); Session["algorithm"] = _qapAntAlgorithm; inputParameters = new InputParametersViewModel { PheromoneIncrement = _qapAntAlgorithm.PheromoneInc.ToString(), ExtraPheromoneIncrement = _qapAntAlgorithm.ExtraPheromoneInc.ToString(), AntsNumber = _qapAntAlgorithm.NAnts.ToString(), NoUpdatesLimit = _qapAntAlgorithm.MaxIterationsNoChanges.ToString(), IterationsNumber = _qapAntAlgorithm.MaxIterations.ToString() }; } } return RedirectToAction("Index", inputParameters); }