public async Task <IHttpActionResult> SimulateAndGetResult(RequestVM model)
        {
            RecalculateMeasumentUnits(model);

            var distanceMatrix = await DistanceHelper.GetDistanceMatrix(model);

            var simulationProcessController = new SimulationProcessController(model, distanceMatrix);

            var delayTask      = Task.Delay(10000);
            var simulationTask = Task.Run(() => simulationProcessController.StartSimulationProcessSession());

            var firstTask = await Task.WhenAny(simulationTask, delayTask);

            if (firstTask == simulationTask && simulationTask.Result != null)
            {
                return(Json(simulationTask.Result));
            }

            return(Content(HttpStatusCode.Accepted, "Для даних об'єктів і ремонтних станцій за допустимий час не вдалось знайти розв'язку"));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// If only the coordinates are given, can calculate the distance matrix.
 /// </summary>
 /// <returns>A full distance matrix between all cities.</returns>
 public double[,] GetDistanceMatrix()
 {
     return(DistanceHelper.GetDistanceMatrix(DistanceMeasure, Coordinates, Distances, Dimension));
 }
Ejemplo n.º 3
0
        private DistanceMatrix CalculateDistanceMatrix(double[,] coordinates)
        {
            var distances = DistanceHelper.GetDistanceMatrix(DistanceMeasure.Euclidean, coordinates, null, coordinates.GetLength(0));

            return(new DistanceMatrix(distances));
        }