void Compute(KnapsackAlgorithm algorithm) { var timer = new Timer(algorithm); var result = timer.MeasureTimeWithResult(); FillTable(algorithm.GetType(), result); }
public ActionResult KnapsackAnimation(int id) { AnimationViewModel vm = new AnimationViewModel(); KnapsackAlgorithm knapsack = new KnapsackAlgorithm(); KnapsackItems items = new KnapsackItems(); int noOfInput = Int32.Parse(Request.Form["noOfKnapsackInput"]); List <KnapsackItems> itemWeightList = new List <KnapsackItems>(); for (int i = 1; i <= noOfInput; i++) { int val = Int32.Parse(Request.Form["itemWeight_" + i]); int benefit = Int32.Parse(Request.Form["itemBenefit_" + i]); itemWeightList.Add(new KnapsackItems { Weight = val, Benefit = benefit }); } knapsack.Capacity = Int32.Parse(Request.Form["capacityValue"]); knapsack.Items = itemWeightList; vm.knapsackAnimationData = knapsack; vm.algoNavBar = algorithmRepository.FindSameParadigmTypeAlgorithm(id).ToList(); vm.algoDetails = algorithmRepository.FindThis(id).SingleOrDefault(); vm.noOfIndex = noOfInput; /* * if (id == 1) * { * return PartialView("_FracKnapAnimationPartial", vm); * } * else * { * return PartialView("_KnapsackAnimationPartial", vm); * } */ return(View(vm)); }
public Timer(KnapsackAlgorithm algorithm) { _algorithm = algorithm; _stopWatch = new Stopwatch(); }
public KnapsackForm() { knapsackAlgorithm = new KnapsackAlgorithm(); specs = new Dictionary <string, byte[]>(); InitializeComponent(); }