Program.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using MetaheuristicsPCL;
  2. using System;
  3. namespace MetaheuristicsMainProgram
  4. {
  5. class Program : IHM
  6. {
  7. static void Main(string[] _args)
  8. {
  9. Program p = new Program();
  10. p.Run();
  11. }
  12. protected void Run()
  13. {
  14. Console.Out.WriteLine("Métaheuristiques d'optimisation\n");
  15. IProblem kspb = new KnapsackProblem();
  16. RunAlgorithms(kspb);
  17. Console.Out.WriteLine("*****************************************************************\n");
  18. IProblem kspbRandom = new KnapsackProblem(100, 30, 20);
  19. RunAlgorithms(kspbRandom);
  20. Console.Out.WriteLine("FIN");
  21. while (true) ;
  22. }
  23. private void RunAlgorithms(IProblem _pb)
  24. {
  25. Algorithm algo;
  26. Console.Out.WriteLine("Algorithme glouton");
  27. algo = new GreedyAlgorithmForKnapsack();
  28. algo.Solve(_pb, this);
  29. Console.Out.WriteLine("");
  30. Console.Out.WriteLine("Descente de gradient");
  31. algo = new GradientDescentForKnapsack();
  32. algo.Solve(_pb, this);
  33. Console.Out.WriteLine("");
  34. Console.Out.WriteLine("Recherche tabou");
  35. algo = new TabuSearchForKnapsack();
  36. algo.Solve(_pb, this);
  37. Console.Out.WriteLine("");
  38. Console.Out.WriteLine("Recuit simulé");
  39. algo = new SimulatedAnnealingForKnapsack();
  40. algo.Solve(_pb, this);
  41. Console.Out.WriteLine("");
  42. Console.Out.WriteLine("Optimisation par essaim particulaire");
  43. algo = new ParticleSwarmOptimizationForKnapsack();
  44. algo.Solve(_pb, this);
  45. Console.Out.WriteLine("");
  46. }
  47. public void PrintMessage(String _message)
  48. {
  49. Console.Out.WriteLine(_message);
  50. }
  51. }
  52. }