Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ and it then falls back to its default. [engine/configs/geolife.json](engine/conf
| `seed` | Seed for all random sampling |
| `budget_shares` | Point budgets to test, as a share of all points (`0.01` = 1%) |
| `split` | `type` (`Random` or `Time`) and `query_percentage` held out for queries |
| `algorithms` | Simplification algorithms to run: `RDP`, `SED` |
| `algorithms` | Simplification algorithms to run: `RDP`, `SED`, `UNIFORM` |
| `knn` | `k` and `query_count` (`0` = every trajectory in the query split) |
| `range` | Box size (m), time window (s) and sampling limits for range queries |
| `where_at` | Probes per trajectory and max time gap (s) between points to probe |
Expand All @@ -101,7 +101,7 @@ engine/ Simplification and evaluation
├── core/ Trajectory database, projection, interpolation
├── io/ Parquet loading
├── split/ Train/query split
├── selection/ Simplification algorithms (RDP, SED)
├── selection/ Simplification algorithms (RDP, SED, UNIFORM)
├── allocation/ Distributing the point budget across trajectories
├── query/ Query workload generation (kNN, range, where-at)
├── evaluator/ Scoring simplified data against the original
Expand Down
1 change: 1 addition & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_library(engine
src/pipeline/pipeline.cpp
src/selection/rdp.cpp
src/selection/sed.cpp
src/selection/uniform.cpp
src/selection/selector.cpp
src/split/split.cpp
src/allocation/budget_allocator.cpp
Expand Down
2 changes: 1 addition & 1 deletion engine/configs/geolife.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "Random",
"query_percentage": 0.15
},
"algorithms": ["RDP", "SED"],
"algorithms": ["RDP", "SED", "UNIFORM"],
"knn": {
"k": 10,
"query_count": 0
Expand Down
2 changes: 1 addition & 1 deletion engine/include/backend/engine/selection/selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace selection {

enum class AlgorithmType { RDP, SED };
enum class AlgorithmType { RDP, SED, UNIFORM };

std::vector<std::size_t> simplify_trajectory(const core::TrajectoryView &, AlgorithmType,
std::size_t);
Expand Down
13 changes: 13 additions & 0 deletions engine/include/backend/engine/selection/uniform.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "backend/engine/core/trajectory_db.hpp"

#include <cstddef>
#include <vector>

namespace selection::uniform {

std::vector<std::size_t> simplify(const core::TrajectoryView &trajectory,
std::size_t points_to_keep);

} // namespace selection::uniform
3 changes: 3 additions & 0 deletions engine/src/selection/selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "backend/engine/core/parallel.hpp"
#include "backend/engine/selection/rdp.hpp"
#include "backend/engine/selection/sed.hpp"
#include "backend/engine/selection/uniform.hpp"

#include <stdexcept>
#include <vector>
Expand All @@ -17,6 +18,8 @@ std::vector<std::size_t> simplify_trajectory(const core::TrajectoryView &traject
return rdp::simplify(trajectory, points_to_keep);
case AlgorithmType::SED:
return sed::simplify(trajectory, points_to_keep);
case AlgorithmType::UNIFORM:
return uniform::simplify(trajectory, points_to_keep);
}

throw std::invalid_argument("simplify_trajectory: unknown algorithm");
Expand Down
18 changes: 18 additions & 0 deletions engine/src/selection/uniform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "backend/engine/selection/uniform.hpp"

#include <algorithm>

namespace selection::uniform {

std::vector<std::size_t> simplify(const core::TrajectoryView &trajectory,
std::size_t points_to_keep) {
const std::size_t n = trajectory.size();
const std::size_t k = std::min(std::max<std::size_t>(points_to_keep, 2), n);

std::vector<std::size_t> indices(k);
for (std::size_t i = 0; i < k; ++i)
indices[i] = k == 1 ? 0 : i * (n - 1) / (k - 1);
return indices;
}

} // namespace selection::uniform
3 changes: 2 additions & 1 deletion engine/tests/selectors/simplify_database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ core::TrajectoryDb make_random_db(const std::vector<std::size_t> &sizes) {
}

constexpr selection::AlgorithmType kAlgorithms[] = {selection::AlgorithmType::RDP,
selection::AlgorithmType::SED};
selection::AlgorithmType::SED,
selection::AlgorithmType::UNIFORM};

} // namespace

Expand Down
Loading