tests.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /**
  2. * @file tests/boost_graph/tests.cpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #include <common/RootCoordinator.hpp>
  26. #include <tests/boost_graph/models.hpp>
  27. #include <tests/boost_graph/graph_manager.hpp>
  28. using namespace paradevs::common;
  29. using namespace paradevs::common::scheduler;
  30. using namespace paradevs::pdevs;
  31. using namespace paradevs::tests::boost_graph;
  32. void flat_test()
  33. {
  34. RootCoordinator <
  35. MyTime,
  36. paradevs::pdevs::Coordinator <
  37. MyTime,
  38. SchedulerType,
  39. SchedulerHandle,
  40. InBuildFlatGraphManager < SchedulerHandle, FlatGraphBuilder >,
  41. paradevs::common::NoParameters,
  42. paradevs::common::NoParameters >
  43. > rc(0, 100, "root", NoParameters(), NoParameters());
  44. rc.run();
  45. }
  46. void hierarchical_test()
  47. {
  48. RootCoordinator <
  49. MyTime,
  50. paradevs::pdevs::Coordinator <
  51. MyTime,
  52. SchedulerType,
  53. SchedulerHandle,
  54. HierarchicalGraphManager < SchedulerHandle,
  55. HierarchicalGraphBuilder >,
  56. paradevs::common::NoParameters,
  57. paradevs::common::NoParameters >
  58. > rc(0, 100, "root", NoParameters(), NoParameters());
  59. rc.run();
  60. }
  61. int main()
  62. {
  63. flat_test();
  64. hierarchical_test();
  65. // class M;
  66. // struct A
  67. // {
  68. // double time;
  69. // M* model;
  70. // A(double _time, M* _model)
  71. // {
  72. // time = _time;
  73. // model = _model;
  74. // }
  75. // };
  76. // struct ACompare
  77. // : std::binary_function < A, A, bool >
  78. // {
  79. // bool operator()(const A &left, const A &right) const
  80. // { return left.time > right.time; }
  81. // };
  82. // typedef boost::heap::fibonacci_heap < A, boost::heap::compare <
  83. // ACompare > > Heap;
  84. // typedef Heap::handle_type HeapHandle;
  85. // class M
  86. // {
  87. // public:
  88. // M(int a)
  89. // {
  90. // _a = a;
  91. // }
  92. // int a() const
  93. // { return _a; }
  94. // HeapHandle heap_id() const
  95. // { return _heap_id; }
  96. // void heap_id(HeapHandle id)
  97. // { _heap_id = id; }
  98. // private:
  99. // int _a;
  100. // HeapHandle _heap_id;
  101. // };
  102. // Heap heap;
  103. // M* m1 = new M(1);
  104. // M* m2 = new M(2);
  105. // m1->heap_id(heap.push(A(0, m1)));
  106. // m2->heap_id(heap.push(A(0, m2)));
  107. // (*m1->heap_id()).time = 1;
  108. // heap.decrease(m1->heap_id());
  109. // (*m2->heap_id()).time = 1;
  110. // heap.decrease(m2->heap_id());
  111. // std::cout << "Scheduler = { ";
  112. // while (not heap.empty()) {
  113. // std::cout << "(" << heap.top().time << "," << heap.top().model->a()
  114. // << ") ";
  115. // heap.pop();
  116. // }
  117. // std::cout << "}" << std::endl;
  118. return 0;
  119. }