コード例 #1
0
 static void Main(string[] args)
 {
     if (args.Length != 1)
     {
         Console.WriteLine("Potreban je jedan argument, put do datoteke s vrijednostima i cijenama!");
     }
     else
     {
         KnapsackGroupsCore core = new KnapsackGroupsCore();
         try
         {
             Stopwatch    stopwatch = Stopwatch.StartNew();
             DynamicTable table     = core.ParseInitialTableFromFile(args[0]);
             core.SolveProblem(false);
             Console.WriteLine("Traženi zbroj cijena: " + table.TargetCost);
             Console.WriteLine("Odabrani:");
             table.BestTableObjects.Reverse();
             foreach (int tableObjectIndex in table.BestTableObjects)
             {
                 DynamicTableObject tableObject = table.TableObjects[tableObjectIndex];
                 Console.WriteLine(table.GroupNames[tableObject.GroupIndex] + ": " + tableObject);
             }
             Console.WriteLine("---------");
             Console.WriteLine("Ukupna vrijednost: " + table.BestValue);
             Console.WriteLine("Ukupna cijena: " + table.BestCost);
             stopwatch.Stop();
             Console.WriteLine("Vrijeme izvrsavanja: " + ((float)stopwatch.ElapsedMilliseconds / 1000) + " s");
         }
         catch (Exception)
         {
             Console.WriteLine("Datoteka ne postoji ili nije ispravno formatirana!");
         }
     }
 }
コード例 #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            pnlMain.Hide();

            // faster grid render
            typeof(DataGridView).InvokeMember(
                "DoubleBuffered",
                BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
                null,
                gridMain,
                new object[] { true });

            knapsackGroupsCore = new KnapsackGroupsCore();
        }