Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add Comb data structure for K-partial alternatives
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Mon, 13 Mar 2023 13:03:12 +0000 (14:03 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Mon, 13 Mar 2023 13:03:12 +0000 (14:03 +0100)
MANIFEST.in
src/mc/explo/udpor/Comb.cpp [new file with mode: 0644]
src/mc/explo/udpor/Comb.hpp [new file with mode: 0644]
tools/cmake/DefinePackages.cmake

index 625f6cc..de1d5ac 100644 (file)
@@ -2156,6 +2156,8 @@ include src/mc/explo/LivenessChecker.hpp
 include src/mc/explo/UdporChecker.cpp
 include src/mc/explo/UdporChecker.hpp
 include src/mc/explo/simgrid_mc.cpp
+include src/mc/explo/udpor/Comb.hpp
+include src/mc/explo/udpor/Comb.cpp
 include src/mc/explo/udpor/Configuration.cpp
 include src/mc/explo/udpor/Configuration.hpp
 include src/mc/explo/udpor/Configuration_test.cpp
diff --git a/src/mc/explo/udpor/Comb.cpp b/src/mc/explo/udpor/Comb.cpp
new file mode 100644 (file)
index 0000000..877cc1d
--- /dev/null
@@ -0,0 +1,25 @@
+/* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/mc/explo/udpor/Comb.hpp"
+
+#include <functional>
+
+namespace simgrid::mc::udpor {
+
+auto Comb::combinations_begin() const
+{
+  std::vector<std::reference_wrapper<const Spike>> references;
+  std::transform(spikes.begin(), spikes.end(), std::back_inserter(references),
+                 [](const Spike& spike) { return std::cref(spike); });
+  return simgrid::xbt::variable_for_loop<const Spike>(std::move(references));
+}
+
+auto Comb::combinations_end() const
+{
+  return simgrid::xbt::variable_for_loop<const Spike>();
+}
+
+} // namespace simgrid::mc::udpor
\ No newline at end of file
diff --git a/src/mc/explo/udpor/Comb.hpp b/src/mc/explo/udpor/Comb.hpp
new file mode 100644 (file)
index 0000000..b06d799
--- /dev/null
@@ -0,0 +1,44 @@
+/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SIMGRID_MC_UDPOR_CONFIGURATION_HPP
+#define SIMGRID_MC_UDPOR_CONFIGURATION_HPP
+
+#include "src/mc/explo/udpor/UnfoldingEvent.hpp"
+#include "src/mc/explo/udpor/udpor_forward.hpp"
+#include "src/xbt/utils/iter/variable_for_loop.hpp"
+
+#include <vector>
+
+namespace simgrid::mc::udpor {
+
+class Spike : public std::vector<const UnfoldingEvent*> {
+public:
+  Spike(unsigned cap) : std::vector<const UnfoldingEvent*>() { reserve(cap); }
+};
+
+class Comb {
+public:
+  explicit Comb(unsigned k) : k(k) {}
+  Comb(const Comb& other)             = default;
+  Comb(const Comb&& other)            = default;
+  Comb& operator=(const Comb& other)  = default;
+  Comb& operator=(const Comb&& other) = default;
+
+  Spike& operator[](unsigned i) { return spikes[i]; }
+  const Spike& operator[](unsigned i) const { return spikes[i]; }
+
+  auto combinations_begin() const;
+  auto combinations_end() const;
+  auto begin() const { return spikes.begin(); }
+  auto end() const { return spikes.end(); }
+
+private:
+  unsigned k;
+  std::vector<Spike> spikes;
+};
+
+} // namespace simgrid::mc::udpor
+#endif
index bcb5bdc..80c1416 100644 (file)
@@ -529,7 +529,9 @@ set(MC_SRC
   src/mc/explo/LivenessChecker.hpp
   src/mc/explo/UdporChecker.cpp
   src/mc/explo/UdporChecker.hpp
-
+  
+  src/mc/explo/udpor/Comb.hpp
+  src/mc/explo/udpor/Comb.cpp
   src/mc/explo/udpor/Configuration.hpp
   src/mc/explo/udpor/Configuration.cpp
   src/mc/explo/udpor/EventSet.cpp