Commit cb3d295e authored by LIly's avatar LIly
Browse files

update test so that 1) locations are ordered and 2) times don't overlap with the constraint time

parent 0e8c6701
......@@ -2,14 +2,15 @@
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#define CONSTRAINT_TIME_START 100
#define CONSTRAINT_TIME_START 0
#define CONSTRAINT_TIME_END 200
#define CONSTRAINT_LOCATION_RANGE 100 // boxes centered around 0
#define NUM_CONSTRAINT_BOXES 1
#define CHAIN_LEN 4
#define FANOUT 2
#define CHAIN_LEN 2
#define FANOUT 5
#define PROPORTION_SATISFY 0.5
int user_index = 0;
......@@ -101,17 +102,16 @@ std::vector<EncounterInfo> generate_encounters() {
while (user2 == user1) {
user2 = rand() % user_index;
}
// for right now, ensure out of box at the last filter (longi), but allow other aspects
// to be within the constraint
// 50% of the time it will be out of the time range
time1 = rand() % (2*(CONSTRAINT_TIME_END-CONSTRAINT_TIME_START));
time2 = rand() % 2*((CONSTRAINT_TIME_END-CONSTRAINT_TIME_START));
// for right now, ensure that the time doesn't overlap (or else we get weird
// jumpy behavior)
time1 = rand() % (2*(CONSTRAINT_TIME_END-CONSTRAINT_TIME_START)) + CONSTRAINT_TIME_END;
time2 = rand() % 2*((CONSTRAINT_TIME_END-CONSTRAINT_TIME_START)) + CONSTRAINT_TIME_END;
start = (time1 > time2? time2 : time1) ;
end = (time1 > time2? time1 : time2);
// 50% of the time it will be out of the lat range
lat = (rand() % (4*CONSTRAINT_LOCATION_RANGE)) - CONSTRAINT_LOCATION_RANGE;
// add the constraint so we know for sure it's out of the box
longi = (rand() % (2*CONSTRAINT_LOCATION_RANGE)) + CONSTRAINT_LOCATION_RANGE + 1;
// 50% of the time it will be out of the longi range
longi = (rand() % (4*CONSTRAINT_LOCATION_RANGE)) - CONSTRAINT_LOCATION_RANGE;
EncounterInfo enc = EncounterInfo(user1, user2, generate_random_hex_str(),
start, end, lat, longi);
printf("%s\n", enc.to_string().c_str());
......@@ -123,33 +123,42 @@ return encs;
void insert_auths(std::vector<EncounterInfo>& encs)
{
char buffer[1000];
for (int i = 0; i < user_index; i++) {
snprintf(buffer, sizeof(buffer), "%dAUTHDELIMITERSocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNIRVUzNTA4ZVxuR29vZ2xlXG4xMTY4Njc1MTE0MDIxMzc1NzcxNTkiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQ1MDU1MzgzfQ.qOfRCnuO0wn6ntBMkCRgcKYzd0Ymzn5a6Tm56Wc5nlI\r\n", user_index);
for (int i = 0; i <= user_index; i++) {
snprintf(buffer, sizeof(buffer), "%dAUTHDELIMITERSocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNIRVUzNTA4ZVxuR29vZ2xlXG4xMTY4Njc1MTE0MDIxMzc1NzcxNTkiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQ1MDU1MzgzfQ.qOfRCnuO0wn6ntBMkCRgcKYzd0Ymzn5a6Tm56Wc5nlI\r\n", i);
printf("Return: %d\n", call_client_with_message(buffer));
}
}
struct LocationEntry {
double lat;
double longi;
LocationEntry() {}
LocationEntry(double lat, double longi)
: lat(lat), longi(longi) {}
};
void insert_encs(std::vector<EncounterInfo>& encs)
{
for (int i = 0; i < user_index; i++) {
for (int i = 0; i <= user_index; i++) {
std::string encountersStr;
std::string locationsStr;
std::map<long, LocationEntry> locs;
for (auto enc : encs) {
if (enc.user1 == i || enc.user2 == i) {
char buffer[1000];
snprintf(buffer, sizeof(buffer), "%ld,%ld,%s,%s",
enc.start, enc.end, enc.ss.c_str(), "3he-1Q0OaOj;");
encountersStr += buffer;
snprintf(buffer, sizeof(buffer), "%f,%f,%ld;",
enc.lat, enc.longi, enc.start);
locationsStr += buffer;
snprintf(buffer, sizeof(buffer), "%f,%f,%ld;",
enc.lat, enc.longi, enc.end);
locationsStr += buffer;
locs[enc.start] = LocationEntry(enc.lat, enc.longi);
locs[enc.end] = LocationEntry(enc.lat, enc.longi);
}
}
for (auto const& loc : locs) {
char buffer[1000];
snprintf(buffer, sizeof(buffer), "%f,%f,%ld;",
loc.second.lat, loc.second.longi, loc.first);
locationsStr += buffer;
}
char buffer[encountersStr.length() + locationsStr.length() + 100];
snprintf(buffer, sizeof(buffer), "%dENCDELIMITER%sENCDELIMITER%s\r\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment