Ejemplo n.º 1
0
        public override byte[] Solve(byte[] partialData, TimeSpan timeout)
        {
            State = TaskSolverState.Solving;
            var tspSolver      = new RecurentTspSolver();
            var partialProblem = DvrpProblemData.Deserialize(partialData);

            Route route = tspSolver.SolveRecurent(partialProblem);

            State = TaskSolverState.Idle;
            OnProblemSolvingFinished(this);
            return((new DvrpSolutionData()
            {
                Routes = new List <Route>()
                {
                    route
                },
                Distance = route.Distance
            }).Serialize());
        }
Ejemplo n.º 2
0
        public override byte[][] DivideProblem(int threadCount)
        {
            State              = TaskSolverState.Dividing;
            solution           = new DvrpSolutionData();
            solution.StartTime = DateTime.Now;
            List <DvrpProblemData> dvrpPartialProblems = new List <DvrpProblemData>();

            partialDictionary = new Dictionary <List <int>, int>(new ListComparer <int>());
            var subsets = Set.GenerateAllSubsets(problem.Clients.Length);
            int tag     = 0;

            foreach (var subset in subsets)
            {
                List <Client> clients = new List <Client>();

                foreach (int index in subset.Elements)
                {
                    clients.Add(problem.Clients[index]);
                }

                var partialProblem = new DvrpProblemData(clients.ToArray(), problem.Depots, problem.Fleet, tag);
                partialDictionary.Add(subset.Elements, tag);
                ++tag;
                dvrpPartialProblems.Add(partialProblem);
            }

            byte[][] dividedData = new byte[dvrpPartialProblems.Count][];
            for (int i = 0; i < dvrpPartialProblems.Count; i++)
            {
                dividedData[i] = dvrpPartialProblems[i].Serialize();
            }
            PartialProblems = dividedData;
            OnProblemDividingFinished(this);
            State = TaskSolverState.Idle;
            return(dividedData);
        }
Ejemplo n.º 3
0
 DvrpSolutionData solution;//to be removed
 public DvrpTaskSolver(byte[] problemData)
     : base(problemData)
 {
     this.problem = DllProject.DvrpProblemData.Deserialize(problemData);
 }
Ejemplo n.º 4
0
 public DvrpProblem(DvrpProblemData problemData)
 {
     ProblemType = "DVRP";
     MData       = problemData;
 }