///
        ///
        ///SOLVE PROBLEM
        ///
        ///
        public override byte[] Solve(byte[] partialData, TimeSpan timeout)
        {
            if (partialData == null || partialData.Length == 0)
            {
                return(null);
            }
            //przerób bajty na PartialProblemInstance
            var converter       = new ProblemToBytesConverter();
            var partialInstance = (DVRPPartialProblemInstance)converter.FromBytesArray(partialData);
            var instance        = (DVRPProblemInstance)converter.FromBytesArray(_problemData);

            //dla każdego samochodu (listy klientów mu przypisanej) sprawdz poprawność kombinacji
            //(w sensie żądań)
            if (!demandsValid(instance))
            {
                return(converter.ToByteArray(solutionImpossible()));
            }

            var n = instance.Visits.Count;
            var s = instance.VehicleNumber;
            var i = partialInstance.MinimalSetCount;

            if (s * i > n)
            {
                return(converter.ToByteArray(solutionImpossible()));
            }

            partialInstance.PartialResult = double.MaxValue;

            solveInParallel(instance, ref partialInstance);

            return(converter.ToByteArray(partialInstance));
        }
        ///
        ///
        ///DIVIDE PROBLEM
        ///
        ///
        public override byte[][] DivideProblem(int threadCount)
        {
            if (_problemData == null || _problemData.Length == 0)
            {
                return(null);
            }

            var converter = new ProblemToBytesConverter();
            var instance  = (DVRPProblemInstance)converter.FromBytesArray(_problemData);
            var problems  = divideProblem(instance);

            return(problems.Select(x => converter.ToByteArray(x)).ToArray());
        }
        ///
        ///
        ///MERGE SOLUTION
        ///
        ///
        public override byte[] MergeSolution(byte[][] solutions)
        {
            if (solutions == null || solutions.GetLength(0) == 0)
            {
                return(null);
            }
            var converter        = new ProblemToBytesConverter();
            var partialSolutions = solutions.Select
                                       (solution => (DVRPPartialProblemInstance)converter.FromBytesArray(solution)).ToList();
            var imin    = 0;
            var minCost = double.MaxValue;

            for (var i = 0; i < solutions.GetLength(0); i++)
            {
                if (partialSolutions[i].PartialResult >= minCost)
                {
                    continue;
                }
                imin    = i;
                minCost = partialSolutions[i].PartialResult;
            }

            return(solutions[imin]);
        }