Exemple #1
0
        private List <SolutionModel> PrepareSolutions()
        {
            var solutions = new List <SolutionModel>();

            List <List <SolutionModel> > solutionsCombination = new List <List <SolutionModel> >();

            foreach (var demand in _networkModel.Demands)
            {
                solutionsCombination.Add(PrepareOneDemandPathCombinations(demand));
            }

            List <List <int> > indexesCombinations = new List <List <int> >();

            foreach (var solutionCombination in solutionsCombination)
            {
                indexesCombinations.Add(AdditionalFunctions.FillListWithIndexes(solutionCombination.Count));
            }

            List <List <int> > indexesCombinationsCartesianResult = new List <List <int> >();

            indexesCombinationsCartesianResult = AdditionalFunctions.GetPermutations(indexesCombinations);

            foreach (var indexesCombination in indexesCombinationsCartesianResult)
            {
                solutions.Add(PrepareSolution(solutionsCombination, indexesCombination));
            }

            return(solutions);
        }
Exemple #2
0
        private List <List <int> > PrepareCombinations(int demandVolume, int numberOfPaths)
        {
            List <List <int> > combinations      = new List <List <int> >();
            List <int>         singleCombination = new List <int>();

            for (int i = 0; i <= demandVolume; i++)
            {
                singleCombination.Add(i);
            }

            for (int i = 0; i < numberOfPaths; i++)
            {
                combinations.Add(singleCombination);
            }

            return(AdditionalFunctions.GetPermutations(combinations).Where(x => x.Sum() == demandVolume).ToList());
        }