//Generate Periods private List <CPeriodSet> GetPeriods(CConfiguration config) { List <CPeriodSet> allPeriods = new List <CPeriodSet>(); CPeriodSet ps = new CPeriodSet(); ps.Add(10); ps.Add(12); ps.Add(15); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(18); ps.Add(20); ps.Add(21); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(24); ps.Add(27); ps.Add(30); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(31); ps.Add(32); ps.Add(33); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(36); ps.Add(29); ps.Add(42); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(45); ps.Add(48); ps.Add(51); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(54); ps.Add(57); ps.Add(60); allPeriods.Add(ps); ps = new CPeriodSet(); ps.Add(63); ps.Add(66); ps.Add(69); allPeriods.Add(ps); return(allPeriods); }
/// <summary> /// /// </summary> /// <param name="oConfiguration"></param> /// <returns></returns> public List <CPeriodSet> GetPeriods(CConfiguration oConfiguration, IPrimeNumberGenerator primeGenerator) { List <List <double> > allCombinations; List <CPeriodSet> allPeriodSets = new List <CPeriodSet>(); List <double> mainSet = generateMainSet(oConfiguration.MinPeriod, oConfiguration.MaxPeriod); CCombinationGenerator comb = new CCombinationGenerator(); _Message = ""; allCombinations = comb.GenerateCombinations(mainSet, oConfiguration.NumberOfTasksPerSet); //Convert allCombinations to allPeriodSets CPeriodSet ps; foreach (List <double> c in allCombinations) { ps = new CPeriodSet(); foreach (double d in c) { ps.Add(d); } allPeriodSets.Add(ps); } return(allPeriodSets); }
/// <summary> /// /// </summary> /// <param name="oConfiguration"></param> /// <returns></returns> public List <CPeriodSet> GetPeriods(CConfiguration oConfiguration, IPrimeNumberGenerator primeGenerator) { int noOfPeriods = oConfiguration.NumberOfTaskSets; Hashtable hshMain = new Hashtable(); long tmp; List <CPeriodSet> allPeriodSets = new List <CPeriodSet>(); CPeriodSet ps; _Message = ""; while (allPeriodSets.Count < oConfiguration.NumberOfTaskSets) { ps = new CPeriodSet(); while (ps.Count < oConfiguration.NumberOfTasksPerSet) { tmp = GetRandomPeriod((long)oConfiguration.MinPeriod, (long)oConfiguration.MaxPeriod); while (ps.isPresent(tmp)) { tmp = GetRandomPeriod((long)oConfiguration.MinPeriod, (long)oConfiguration.MaxPeriod); } ps.Add(tmp); } allPeriodSets.Add(ps); } return(allPeriodSets); }
/// <summary> /// /// </summary> /// <param name="oConfiguration"></param> /// <returns></returns> public List <CPeriodSet> GetPeriods(CConfiguration oConfiguration, IPrimeNumberGenerator primeGenerator) { int maxGroups; int maxIdx; int idx = 0; double maxFactor; List <double> tmpList; int ii; double delta; double maxPrime; delta = oConfiguration.MaxPeriod - oConfiguration.MinPeriod + 1; maxPrime = Math.Ceiling(delta / 2); _allPeriods = new List <CPeriodSet>(); //Generate Primes if (_primes == null) { GeneratePrimes(oConfiguration); } maxGroups = GetMaximumGroups(oConfiguration.MinPeriod, oConfiguration.MaxPeriod, oConfiguration.NumberOfTasksPerSet); _Message = ""; _groups = new List <double> [maxGroups]; maxFactor = GetMaximumFactor(oConfiguration.MinPeriod, oConfiguration.MaxPeriod, oConfiguration.NumberOfTasksPerSet); maxIdx = GetIndexOfMaxPrime(maxFactor); //Fill in Periods in All Groups //Starting with Highest Index First idx = 0; int primeIdx = maxIdx; while (primeIdx >= 0) { tmpList = GeneratePeriods(oConfiguration.MinPeriod, oConfiguration.MaxPeriod, _primes[primeIdx--]); _groups[idx++] = tmpList; } //Now Return Periods CCombinationGenerator oComb = new CCombinationGenerator(); CPeriodSet ps; //Customize the group number here for (ii = 0; ii < _groups.Length; ii++) { tmpList = _groups[ii]; List <List <double> > indexes; indexes = oComb.GenerateCombinations(tmpList, oConfiguration.NumberOfTasksPerSet); foreach (List <double> lst in indexes) { ps = new CPeriodSet(); foreach (double p in lst) { ps.Add(p); } _allPeriods.Add(ps); } } return(_allPeriods); }