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

Minimizing custom cost function #99

Open
al-muammar opened this issue May 4, 2023 · 1 comment
Open

Minimizing custom cost function #99

al-muammar opened this issue May 4, 2023 · 1 comment

Comments

@al-muammar
Copy link

Is there a way I could calculate a custom cost function to minimize it?

Use case: suppose I have a black box that is able to quickly score my routes. I want to inject it into VRP, so this cost is optimized, not just a linear combination of distance + time

@reinterpretcat
Copy link
Owner

reinterpretcat commented May 4, 2023

It is possible if you use the project as a library. Then you can have write your own extension. However, this would require some understanding how to do it which, I have to admit, is not yet fully documented. Anyway, let me explain it in short details.

In VRP solver, there are the following main relevant concepts:

An objective is a part of Feature definition: typical implementation requires not only comparing two solution based on their fitness, but also guiding the search in constructive heuristic. So you would need to write your feature with objective (you can also use state to cache some calculations to speed up), which will use your black box and then plug it in the goal context. I guess this could be a good starting point:
https://github.com/reinterpretcat/vrp/blob/master/vrp-scientific/src/common/text_reader.rs#L10-L26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants