Skip to content

Commit

Permalink
Document updating (#69)
Browse files Browse the repository at this point in the history
* Removing redundant readme files

* Updating format and documentation

* script for uploading actions to redis database for planrec

* Saving

* Updating

* Updating

* redundant

* Updated
  • Loading branch information
lchamp87x authored Jun 17, 2024
1 parent 8f815c3 commit 4736d56
Show file tree
Hide file tree
Showing 7 changed files with 376 additions and 204 deletions.
317 changes: 282 additions & 35 deletions README.md

Large diffs are not rendered by default.

98 changes: 0 additions & 98 deletions apps/README.md

This file was deleted.

3 changes: 3 additions & 0 deletions apps/data_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ add_executable(redis_grapher redis_grapher.cpp)
target_include_directories(redis_grapher PRIVATE ${Boost_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIRS} ${HIREDIS_HEADER} ${REDIS_PLUS_PLUS_HEADER} ../../lib)
target_link_libraries(redis_grapher PRIVATE ${Boost_LIBRARIES} ${GRAPHVIZ_LIBS} ${HIREDIS_LIB} ${REDIS_PLUS_PLUS_LIB})

add_executable(pr_samples_to_redis pr_samples_to_redis.cpp)
target_include_directories(pr_samples_to_redis PRIVATE ${Boost_INCLUDE_DIR} ${HIREDIS_HEADER} ${REDIS_PLUS_PLUS_HEADER} ../../lib)
target_link_libraries(pr_samples_to_redis PRIVATE ${Boost_LIBRARIES} ${HIREDIS_LIB} ${REDIS_PLUS_PLUS_LIB})
82 changes: 82 additions & 0 deletions apps/data_tools/pr_samples_to_redis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include <boost/program_options.hpp>
#include <iostream>
#include <sw/redis++/redis++.h>
#include "../../domains/pr_samples.h"

namespace po = boost::program_options;

using namespace sw::redis;

int main(int argc, char* argv[]) {
std::string redis_address = "";
std::string samples_key = "delivery_sample";
std::string key = "actions";
int samples = -1;

try {
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("redis_address,a",po::value<std::string>(),"redis address to redis database (string), default = none")
("samples_key,s", po::value<std::string>(), "map key for pr_samples.h (string), default = delivery_sample")
("key,k",po::value<std::string>(),"key to use for uploading actions to redis database (string), default = actions")
("samples,n", po::value<int>(),"number of sample actions to upload from pr_samples.h (int), default = -1 (all of them)")
;

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count("help")) {
std::cout << desc << std::endl;
return 0;
}

if (vm.count("redis_address")) {
redis_address = vm["redis_address"].as<std::string>();
}

if (vm.count("samples_key")) {
samples_key = vm["samples_key"].as<std::string>();
}

if (vm.count("key")) {
key = vm["key"].as<std::string>();
}

if (vm.count("samples")) {
samples = vm["samples"].as<int>();
}

}
catch(std::exception& e) {
std::cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
std::cerr << "Exception of unknown type!\n";
}

try {
auto redis = Redis(redis_address);
std::vector<std::pair<std::string,std::string>> obs = pr_samples[samples_key];
std::vector<std::pair<std::string,std::string>> acts;
if (samples > 0 && samples <= obs.size()) {
acts = {obs.begin(),obs.begin() + samples};
}
else {
acts = obs;
}
int i = 1;
for (auto a : acts) {
auto rank = std::to_string(i) + "-*";
redis.xadd("actions",rank,{a});
i++;
}
}
catch (const Error &e) {
std::cout << "Failed : " << e.what() << std::endl;
}

return EXIT_SUCCESS;
}
31 changes: 0 additions & 31 deletions apps/perc/README.md

This file was deleted.

18 changes: 9 additions & 9 deletions domains/pr_samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#include <vector>
#include <unordered_map>

std::vector<std::string> delivery_sample= {"(drive truck_0 city_loc_2 city_loc_1)",
"(pick_up truck_0 city_loc_1 package_0 capacity_1 capacity_2)",
"(noop truck_0 city_loc_1)",
"(pick_up truck_0 city_loc_1 package_1 capacity_0 capacity_1)",
"(drive truck_0 city_loc_1 city_loc_0)",
"(drop truck_0 city_loc_0 package_0 capacity_0 capacity_1)",
"(drive truck_0 city_loc_0 city_loc_2)",
"(drop truck_0 city_loc_2 package_1 capacity_1 capacity_2)"};
std::vector<std::pair<std::string,std::string>> delivery_sample= {{"drive","(drive truck_0 city_loc_2 city_loc_1)"},
{"pick_up","(pick_up truck_0 city_loc_1 package_0 capacity_1 capacity_2)"},
{"noop","(noop truck_0 city_loc_1)"},
{"pick_up","(pick_up truck_0 city_loc_1 package_1 capacity_0 capacity_1)"},
{"drive","(drive truck_0 city_loc_1 city_loc_0)"},
{"drop","(drop truck_0 city_loc_0 package_0 capacity_0 capacity_1)"},
{"drive","(drive truck_0 city_loc_0 city_loc_2)"},
{"drop","(drop truck_0 city_loc_2 package_1 capacity_1 capacity_2)"}};

std::unordered_map<std::string,std::vector<std::string>> pr_samples = {{"delivery_sample",delivery_sample}};
std::unordered_map<std::string,std::vector<std::pair<std::string,std::string>>> pr_samples = {{"delivery_sample",delivery_sample}};
31 changes: 0 additions & 31 deletions lib/cpphop/README.md

This file was deleted.

0 comments on commit 4736d56

Please sign in to comment.