Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all data for Jobs #244

Closed
wants to merge 2 commits into from
Closed
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
32 changes: 32 additions & 0 deletions src/utils/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ rapidjson::Document to_json(const Solution& sol, bool geometry) {
to_json(job.location, allocator),
allocator);
}
if (job.amount.size() > 0) {
rapidjson::Value json_amount(rapidjson::kArrayType);
for (std::size_t i = 0; i < job.amount.size(); ++i) {
json_amount.PushBack(job.amount[i], allocator);
}
json_job.AddMember("amount", json_amount, allocator);
}
if (job.tws.size() > 0) {
rapidjson::Value json_tws(rapidjson::kArrayType);
for (std::size_t i = 0; i < job.tws.size(); ++i) {
json_tws.PushBack(to_json(job.tws[i], allocator), allocator);
}
json_job.AddMember("time_windows", json_tws, allocator);
}
json_job.AddMember("service", job.service, allocator);
json_unassigned.PushBack(json_job, allocator);
}

Expand Down Expand Up @@ -174,6 +189,13 @@ rapidjson::Value to_json(const Step& s,
json_step.AddMember("service", s.service, allocator);
json_step.AddMember("waiting_time", s.waiting_time, allocator);
}
if (s.amount.size() > 0) {
rapidjson::Value json_amount(rapidjson::kArrayType);
for (std::size_t i = 0; i < s.amount.size(); ++i) {
json_amount.PushBack(s.amount[i], allocator);
}
json_step.AddMember("amount", json_amount, allocator);
}

json_step.AddMember("arrival", s.arrival, allocator);
json_step.AddMember("duration", s.duration, allocator);
Expand All @@ -195,6 +217,16 @@ rapidjson::Value to_json(const Location& loc,
return json_coords;
}

rapidjson::Value to_json(const TimeWindow& time_window,
rapidjson::Document::AllocatorType& allocator) {
rapidjson::Value json_time_window(rapidjson::kArrayType);

json_time_window.PushBack(time_window.start, allocator);
json_time_window.PushBack(time_window.end, allocator);

return json_time_window;
}

void write_to_json(const Solution& sol,
bool geometry,
const std::string& output_file) {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/output_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ rapidjson::Value to_json(const Step& s,
rapidjson::Value to_json(const Location& loc,
rapidjson::Document::AllocatorType& allocator);

rapidjson::Value to_json(const TimeWindow& loc,
rapidjson::Document::AllocatorType& allocator);

void write_to_json(const Solution& sol,
bool geometry,
const std::string& output_file);
Expand Down