-
Notifications
You must be signed in to change notification settings - Fork 322
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
feature/custom_matrix#47 #59
Conversation
Thanks for the WIP PR. Trying to expand on what I had in mind regarding dealing with matrix indices. Job and vehicle ids are just a way of identification between input and output data, they might be any number (think job ids exported from a database) and are uncorrelated with actual index of any location in the matrix. So any place like jobs or vehicle start/end embed a location as defined in
Hope that helps! |
|
Is there a deeper reason behind the assert at Maybe there are no further side effects, if the assert is deleted and |
About the assert, there would be other bad side effects during solving. The main problem is having a 0 on the diagonal, hence this. Currently, similar start and end locations are duplicated in the matrix, which is really a work-around we should avoid with the custom matrix use-case. I should probably try to fix the problem raised by having a 0 on the diagonal. This requires a deep dive into the munkres implementation I had hoped would stay happily untouched for long... This would make sense in the light of #57 and would also allow to avoid location duplicates in any case. I'd suggest keeping the assertion so far and consider the round-trip case with same start/end as not handled (yet) in the PR. |
@PattyDePuh just added a commit to your branch to avoid having things showing up in diffs (or github compare) only because of formatting differences. |
Regarding the jobs definition, I think the
I'm fine with the input description you suggested before with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, for an consistent output, i adjusted the step class:
instead of an job
attribute, it stores an general identifier id
plus an optional location_index
with a flag, that location_index
is initialized. Depending on this flag, the json_output prints the location_index
into the step.
An identifier for steps of type start
and end
is also provided from now on, but will not be printed out.
src/utils/output_json.cpp
Outdated
} | ||
if(s.type == TYPE::END){ | ||
json_step.AddMember("end", s.job, allocator); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is still bugging me, since i don't have a flag inside the output_json
-class to indicate, that this should only happen, if a custom matrix is provided.
With the latest commit we should be good to go now, i guess. |
Thanks @PattyDePuh for the ongoing work! I'm sorry I don't have much time to review this properly right now. I'll try to find some time soon to take a deeper look... Just two quick comments for now:
|
About the boolean flag - that was only for the location identifier during the output, since i wanted to achieve, that both the About the input-class, that should be unaware of the json-matrix: |
/done |
@jcoupey is the code review still in process? |
@PattyDePuh I just want to find enough time to go through the changes in detail, which I wasn't able to do since our last exchanges. But I'm positive about this getting merged soon, so meanwhile I'm sorry for the delay here, especially as you've been promptly reacting to all suggestions! |
Hey @PattyDePuh I went through the code and just did a few adjustments. I checked that the behaviour didn't change while solving with Using the matrix key in json input seems to work provided every matrix index is used exactly once in a job or vehicle location. This is something I didn't anticipate, due to the fact that the TSP solving code is really based on the matrix it is fed, in a way that is quite unrelated from the jobs description in the API. In a way it could make sense to require the matrix to be exactly the "right" one for the problem but from an API point of view, it feels odd. For example, one might want to modify an input problem by simply removing a job without bothering to remove the matching line and column in the matrix. In such a case I guess one would expect the unnecessary line/column to just be ignored during solving. |
You got there a point - the current implementation is strict with the consideration, that the input json is computer generated and no human dares to alter the in existing input files. |
I think we can store the full matrix in I hope to be able to give it a go in the next few days! |
The solution, that i pushed right now, filters the matrix from the unused indexes before storing it in the That shall solve the inconvinient need to adjust the matrix in the inputfile, if somebody messes with the jobs. |
@PattyDePuh the filtering you implemented works just fine, yet I see two drawbacks:
I want to retain your filtering logic but move it after input description and before the creation of the problem instance. Working on this right now! EDIT: will ticket this and address after merging. |
As suggested in #47 here is the PR of the branch, that is still in progress:
push_back
's anymore.start_id
is now optional and the sanity check, if eitherstart_id
end_id
available, is insideadd_vehicle
What is was ToDo:
location::index
as general id for location in matrix (At least thats, what i understood)Editing the code style: I would prefer to do that after the pull in an own branch. I do like the spaces between parantheses, brackets and control structures, but that wasn't consistent so far.