Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

or-tools how to force stop vrp solver during search process

Is there any way to stop or-tools solver during searching solution? I set limits for the search

 RoutingSearchParameters searchParameters =
                main.defaultRoutingSearchParameters()
                        .toBuilder()
                        .setLogSearch(true)
                        .setSolutionLimit(solutionLimit)
                        .setFirstSolutionStrategy(FirstSolutionStrategy.Value.AUTOMATIC)
                        .setLocalSearchMetaheuristic(LocalSearchMetaheuristic.Value.GUIDED_LOCAL_SEARCH)
                        .setTimeLimit(com.google.protobuf.Duration.newBuilder().setSeconds(60 * 60 * 12).build())
                        .build();

But in some cases I want to force stop search. For example when I discover error in input data. I tried endSearch method, but after call process stopped with exception.

routing.addAtSolutionCallback(() -> {
            foundSolutionsCount.getAndIncrement();
            listener.onProgress((float)foundSolutionsCount.get() / finalSolutionLimit);
            if (foundSolutionsCount.get() >= 3) {
                routing.solver().endSearch();
            }
        });

Exception log:

I0125 17:27:39.820322 203316 search.cc:254] Solution #1 (12890, objective maximum = 12920, time = 2785 ms, branches = 383, failures = 103, depth = 33, PairRelocateOperator, neighbors = 16323, filtered neighbors = 3, accepted neighbors = 1, memory used = 1858.74 MB, limit = 20%)
I0125 17:27:39.949419 203316 search.cc:254] End search (time = 2914 ms, branches = 481, failures = 112, memory used = 1858.74 MB, speed = 165 branches/s)
F0125 17:27:39.949463 203316 expressions.cc:1340] Check failed: min_.Value() == max_.Value() (0 vs. 9223372036854775807)  variable Cost(0..9223372036854775807) is not bound.
*** Check failure stack trace: ***
question from:https://stackoverflow.com/questions/65886839/or-tools-how-to-force-stop-vrp-solver-during-search-process

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...