protected override void PrintDebugData(ShiftsContainer shiftsContainer, SchedulareState state) { if (!DEBUG) { return; } Console.WriteLine($"_threshold - {_threshold}"); base.PrintDebugData(shiftsContainer, state); }
private void UpdateSchefulareStatistics(ShiftsContainer shiftsContainer, SchedulareState algoResult, string algoString) { if (!_schedulareStatisticsList.ContainsKey(algoString)) { _schedulareStatisticsList.AddOrUpdate(algoString, new SchedulareListStatistics()); } var bfsSatisfaction = CommonLogic.GetPercentageOfSatisfaction(algoResult.Node.Value, shiftsContainer); _schedulareStatisticsList[algoString].SchedulareSatisfactionList.Add(new SchedulareSatisfaction(algoResult.Node.Value, bfsSatisfaction, shiftsContainer, algoResult.Weight, algoResult.ExecuteTime, algoResult.MostUnfortunateWorkerPer)); }
protected virtual void PrintDebugData(ShiftsContainer shiftsContainer, SchedulareState state) { if (!DEBUG) { return; } double percentageOfSatisfaction = CommonLogic.GetPercentageOfSatisfaction(state.Node.Value, shiftsContainer); Console.WriteLine($"Weight = {state.Weight}"); Console.WriteLine($"Percentage of workes constrains satisfaction = {percentageOfSatisfaction}"); CommonLogic.PrintSchedulare(state.Node.Value, shiftsContainer); }
protected void UpdateCurrentBestSolution(SchedulareState currState) { if (CurrentBestSolution == null) { CurrentBestSolution = currState; CurrentBestSolution.ExecuteTime = ExecuteStopwatch.Elapsed.TotalSeconds; } // update only if the schedulare is full if (!IsSchedulareFull(currState.Node.Value, ShiftsContainer)) { return; } else if (currState.Weight < CurrentBestSolution.Weight) { CurrentBestSolution = currState; CurrentBestSolution.ExecuteTime = ExecuteStopwatch.Elapsed.TotalSeconds; } }
private void PrintDebugData(ShiftsContainer shiftsContainer, SchedulareState state, string algoName) { Console.WriteLine(algoName); double percentageOfSatisfaction = CommonLogic.GetPercentageOfSatisfaction(state.Node.Value, shiftsContainer); Console.WriteLine($"Weight = {state.Weight}"); Console.WriteLine($"Satisfaction = {percentageOfSatisfaction}"); state.MostUnfortunateWorkerPer = CommonLogic.LocateAndPrintMostUnfortunateWorker(state.Node.Value, shiftsContainer); CommonLogic.PrintSchedulare(state.Node.Value, shiftsContainer); CommonLogic.ApeandToFile(algoName, FILENAME); CommonLogic.ApeandToFile($"Weight = {state.Weight}", FILENAME); CommonLogic.ApeandToFile($"Satisfaction = {percentageOfSatisfaction}", FILENAME); string schedulareStateJson = JsonConvert.SerializeObject(state.Node.Value); CommonLogic.ApeandToFile(schedulareStateJson, FILENAME); string shiftsContainerJson = JsonConvert.SerializeObject(shiftsContainer); CommonLogic.ApeandToFile(shiftsContainerJson, FILENAME); }
private void RunAlgo(ShiftsContainer shiftsContainer, Schedulare schedulare, SchedulareState randResult, KeyValuePair <string, IAlgo> algo) { SchedulareState result = null; if (algo.Key.ContainsContent("rand")) { return; } if (algo.Key.ContainsContent("tabu")) { result = algo.Value.Execute(randResult.Node.Value.DeepClone(), shiftsContainer); } else { result = algo.Value.Execute(schedulare.DeepClone(), shiftsContainer); } PrintDebugData(shiftsContainer, result, algo.Key.ToString()); UpdateSchefulareStatistics(shiftsContainer, result, algo.Key.ToString()); }
private SchedulareState GetCurrentState(SortedArray <SchedulareState> openSet) { SchedulareState state = null; if (!_isWithTH) { _isWithTH = true; return(openSet.FindMin()); } state = openSet.FirstOrDefault(x => x.Weight > _threshold); if (state == null) { state = openSet.LastOrDefault(); } UpdateThreshold(state); _isWithTH = false; return(state); }
private static void RemoveEmpFromCurrShift(DayShift randShift, int workerIndex, SchedulareState currStateInOrderToReplaceEmp) { // remove emp from current solution to explore better solution var currShiftDay = currStateInOrderToReplaceEmp.Node.Value.Days.FirstOrDefault(x => x.Name.CompareContent(randShift.DayName)); var currShift = currShiftDay.Shifts.FirstOrDefault(x => x.Name.CompareContent(randShift.Shift.Name)); currShift.Workers[workerIndex] = new Worker() { Name = string.Empty }; }
private void UpdateThreshold(SchedulareState state = null) { //_threshold = state != null? state.Weight -1 : _threshold - 1; //_threshold = state.Weight * ALFA; _threshold = OpenSet.FirstOrDefault().Weight *ALFA; }