public IActionResult DataReaderConfig(ConfigurationViewModel configuration) { if (string.IsNullOrEmpty(configuration.SelectedInputType)) { return(View("Error", "You have selected nothing")); } else { var randomView = new RandomInputViewModel(); var fileView = new FileInputViewModel(); var k = configuration.SelectedInputType; switch (k) { case "Random": return(RedirectToAction("RandomInput", randomView)); case "Manually": return(RedirectToAction("NumInput", fileView)); case "FromFile": return(RedirectToAction("FileInput", fileView)); default: break; } return(RedirectToAction("Error")); } }
public JsonResult Undetermined2() { List <Undetermined> undetermineds = new List <Undetermined>(); for (int i = 1; i < 30; i += 1) { RandomInputViewModel randomInput = new RandomInputViewModel() { PenaltyFrom = 1, PenaltyTo = 10000, DeadlineFrom = 1, DeadlineTo = 30, NumberOfElements = i, NumberOfPenalties = 10 }; double percents; List <int> list = new List <int>(); for (int k = 1; k < 10; k++) { int summaryPenaltyCount = 0; for (int j = 0; j < 100; j++) { UndeterminedResultViewModel undeterminedResult = randomInput.AlgoGenerator.Answer(randomInput.MakeSchedule()); if (undeterminedResult.ResultSchedules.Last() == 10) { summaryPenaltyCount++; } } list.Add(summaryPenaltyCount); } percents = list.Average(); Undetermined undetermined = new Undetermined() { Step = i, Percents = percents }; undetermineds.Add(undetermined); } return(Json(undetermineds)); }
// [Route("api/RandomInput")] public IActionResult RandomInput(RandomInputViewModel configuration, [FromQuery] string myMethod = null) { if (configuration.DeadlineFrom <= 0 || configuration.DeadlineTo <= 0 || configuration.PenaltyFrom <= 0 || configuration.PenaltyTo <= 0 || configuration.NumberOfElements <= 0 || configuration.DeadlineFrom.GetType() != typeof(int) || configuration.DeadlineTo.GetType() != typeof(int) || configuration.PenaltyFrom.GetType() != typeof(int) || configuration.PenaltyTo.GetType() != typeof(int) || configuration.NumberOfElements.GetType() != typeof(int) || configuration.DeadlineFrom > configuration.DeadlineTo || configuration.PenaltyFrom > configuration.PenaltyTo || configuration.NumberOfElements > 10000) { return(View("Error", "All values must not be 0 or negative or not integer, also min bound of random value must be greater than max bound and max count of elements is 10000")); } configuration.NumberOfPenalties = 1; configuration.Schedule = configuration.MakeSchedule(); return(View("RandomInput", configuration)); }
public JsonResult Precision() { List <Precision> precisions = new List <Precision>(); for (int i = 0; i < 10000; i += 100) { RandomInputViewModel randomInput = new RandomInputViewModel() { PenaltyFrom = 1, PenaltyTo = 10000, DeadlineFrom = 1, DeadlineTo = 10000, NumberOfElements = i, NumberOfPenalties = 1 }; List <int> algo1 = new List <int>(); List <int> algo2 = new List <int>(); List <int> algo3 = new List <int>(); List <int> algo4 = new List <int>(); for (int j = 0; j < 10; j++) { algo1.Add(randomInput.AlgoGenerator.MakeAlgo1(randomInput.MakeSchedule().First()).SummmaryPenalty); algo2.Add(randomInput.AlgoGenerator.MakeAlgo2(randomInput.MakeSchedule().First()).SummmaryPenalty); algo3.Add(randomInput.AlgoGenerator.MakeAlgo3(randomInput.MakeSchedule().First()).SummmaryPenalty); algo4.Add(randomInput.AlgoGenerator.MakeAlgo4(randomInput.MakeSchedule().First()).SummmaryPenalty); } Precision precision = new Precision() { Step = i, Greedy1 = algo1.Average(), Greedy2 = algo2.Average(), Greedy3 = algo3.Average(), Greedy4 = algo4.Average(), }; precisions.Add(precision); } return(Json(precisions)); }
public JsonResult UndeterminedTime() { List <Undetermined> undetermineds = new List <Undetermined>(); for (int i = 1; i < 50; i += 1) { RandomInputViewModel randomInput = new RandomInputViewModel() { PenaltyFrom = 1, PenaltyTo = 10000, DeadlineFrom = 1, DeadlineTo = 90, NumberOfElements = 90, NumberOfPenalties = i }; DateTime moment1; DateTime moment2; double diff = 0; for (int j = 0; j < 100; j++) { moment1 = DateTime.Now; //first time _ = randomInput.AlgoGenerator.Answer(randomInput.MakeSchedule()); moment2 = DateTime.Now; //time after running diff += moment2.Subtract(moment1).TotalMilliseconds; //diff between first and second times } Undetermined undetermined = new Undetermined() { Step = i, Percents = diff }; undetermineds.Add(undetermined); } return(Json(undetermineds)); }
// [Route("api/RandomInput")] public IActionResult RandomInput(RandomInputViewModel randomInputView) { randomInputView.Schedule.Add(new ScheduleViewModel()); //return Ok(randomInputView); return(View("RandomInput", randomInputView)); }
public double CountAlgoTime(int numOfAlgo, int numOfElements) { RandomInputViewModel randomInput = new RandomInputViewModel() { PenaltyFrom = 1, PenaltyTo = 10000, DeadlineFrom = 1, DeadlineTo = 10000, NumberOfElements = numOfElements, NumberOfPenalties = 1 }; DateTime moment1 = DateTime.Now;//first time switch (numOfAlgo) { case 1: { for (int i = 0; i < 10; i++) { _ = randomInput.AlgoGenerator.MakeAlgo1(randomInput.MakeSchedule().First()); } break; } case 2: { for (int i = 0; i < 10; i++) { _ = randomInput.AlgoGenerator.MakeAlgo2(randomInput.MakeSchedule().First()); } break; } case 3: { { for (int i = 0; i < 10; i++) { _ = randomInput.AlgoGenerator.MakeAlgo3(randomInput.MakeSchedule().First()); } break; } } case 4: { { for (int i = 0; i < 10; i++) { _ = randomInput.AlgoGenerator.MakeAlgo4(randomInput.MakeSchedule().First()); } break; } } } DateTime moment2 = DateTime.Now; //time after running TimeSpan diff = moment2.Subtract(moment1); //diff between first and second times return(diff.TotalMilliseconds); }