#2220 closed enhancement (done)
Improve the generation of all possible combinations of values in ValueGenerator.cs
Reported by: | bburlacu | Owned by: | bburlacu |
---|---|---|---|
Priority: | low | Milestone: | HeuristicLab 3.3.11 |
Component: | Problems.Instances | Version: | 3.3.10 |
Keywords: | Cc: |
Description
The method GenerateAllCombinationsOfValuesInLists from HeuristicLab.Problems.Instances.DataAnalysis.ValueGenerator.cs seems unnecessarily complicated. The following snippet [1] should achieve the same functionality:
public static IEnumerable<IEnumerable<T>> CartesianProduct<T>(this IEnumerable<IEnumerable<T>> sequences) { IEnumerable<IEnumerable<T>> result = new[] { Enumerable.Empty<T>() }; return sequences.Aggregate(result, (current, s) => (from seq in current from item in s select seq.Concat(new[] { item }))); }
[1] http://blogs.msdn.com/b/ericlippert/archive/2010/06/28/computing-a-cartesian-product-with-linq.aspx
Change History (4)
comment:1 Changed 10 years ago by mkommend
- Owner changed from mkommend to bburlacu
- Status changed from new to assigned
comment:2 Changed 10 years ago by bburlacu
- Owner changed from bburlacu to mkommend
- Status changed from assigned to reviewing
comment:3 Changed 10 years ago by mkommend
- Owner changed from mkommend to bburlacu
- Status changed from reviewing to readytorelease
comment:4 Changed 10 years ago by mkommend
- Resolution set to done
- Status changed from readytorelease to closed
Note: See
TracTickets for help on using
tickets.
r11347: Fixed bug in the CartesianProduct extension method that was added in r11309 as part of #2234.