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 location_index and description field to output, add shared target to makefile #627

Merged
merged 4 commits into from
Jan 6, 2022
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

### Added

- `description` key to unallocated tasks in the output, if provided (#403)
- `location_index` key to to unassigned tasks and each step, if provided (#625)
- Shared target to makefile, for creating Position Independent Code (#617)

## [v1.11.0] - 2021-11-19

### Added
Expand Down
3 changes: 2 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ The computed solution is written as `json` on standard output or a file
| `code` | status code |
| `error` | error message (present iff `code` is different from `0`) |
| [`summary`](#summary) | object summarizing solution indicators |
| `unassigned` | array of objects describing unassigned tasks with their `id`, `type` and `location` (if provided) |
| `unassigned` | array of objects describing unassigned tasks with their `id`, `type`, and if provided, `description`, `location` and `location_index` |
| [`routes`](#routes) | array of `route` objects |

## Code
Expand Down Expand Up @@ -376,6 +376,7 @@ A `step` object has the following properties:
| `violations` | array of `violation` objects for this step |
| [`description`] | step description, if provided in input |
| [`location`] | coordinates array for this step (if provided in input) |
| [`location_index`] | index of relevant row and column in custom matrices for this step (if provided in input) |
| [`id`] | id of the task performed at this step, only provided if `type` value is `job`, `pickup`, `delivery` or `break` |
| ~~[`job`]~~ | ~~id of the job performed at this step, only provided if `type` value is `job`~~ |
| [`load`] | vehicle load after step completion (with capacity constraints) |
Expand Down
4 changes: 4 additions & 0 deletions docs/example_2_sol.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"steps": [
{
"type": "start",
"location_index": 0,
"setup": 0,
"service": 0,
"waiting_time": 0,
Expand All @@ -34,6 +35,7 @@
{
"type": "job",
"id": 1414,
"location_index": 1,
"setup": 0,
"service": 0,
"waiting_time": 0,
Expand All @@ -45,6 +47,7 @@
{
"type": "job",
"id": 1515,
"location_index": 2,
"setup": 0,
"service": 0,
"waiting_time": 0,
Expand All @@ -55,6 +58,7 @@
},
{
"type": "end",
"location_index": 3,
"setup": 0,
"service": 0,
"waiting_time": 0,
Expand Down
4 changes: 4 additions & 0 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ DEPS = $(SRC:.cpp=.d)
# Main target.
all : $(MAIN) $(LIB)

# Shared target, for creating Position Independent Code (PIC)
shared : CXXFLAGS += -fPIC
shared : all

$(MAIN) : $(OBJ) main.o
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS)
Expand Down
14 changes: 14 additions & 0 deletions src/utils/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ rapidjson::Document to_json(const Solution& sol, bool geometry) {
to_json(job.location, allocator),
allocator);
}
if (job.location.user_index()) {
json_job.AddMember("location_index", job.location.index(), allocator);
}
json_job.AddMember("type", rapidjson::Value(), allocator);
std::string str_type;
switch (job.type) {
Expand All @@ -99,6 +102,13 @@ rapidjson::Document to_json(const Solution& sol, bool geometry) {
}
json_job["type"].SetString(str_type.c_str(), str_type.size(), allocator);

if (!job.description.empty()) {
json_job.AddMember("description", rapidjson::Value(), allocator);
json_job["description"].SetString(job.description.c_str(),
job.description.size(),
allocator);
}

json_unassigned.PushBack(json_job, allocator);
}

Expand Down Expand Up @@ -296,6 +306,10 @@ rapidjson::Value to_json(const Step& s,
json_step.AddMember("location", to_json(s.location, allocator), allocator);
}

if (s.location.user_index()) {
json_step.AddMember("location_index", s.location.index(), allocator);
}

if (s.step_type == STEP_TYPE::JOB or s.step_type == STEP_TYPE::BREAK) {
json_step.AddMember("id", s.id, allocator);
}
Expand Down