ifley
March 28, 2018, 6:41pm
1
Is there a way to limit number iterations by time?
Yes there is. Besides setting the maximum number of iterations, jsprit supports three types of premature termination. Check them out here:
#### Configure and create algorithm
##### Per xml
Structure of overall algorithm config:
![configBuildingBlock](https://github.com/jsprit/misc-rep/raw/master/wiki-images/config1.png)
Structure of overall (search) strategy:
![overallStrategyBuildingBlock](https://github.com/jsprit/misc-rep/raw/master/wiki-images/config2.png)
Structure of individual search strategies and modules:
![searchStrategyBuildingBlock](https://github.com/jsprit/misc-rep/raw/master/wiki-images/config3.png)
<pre><code>VehicleRoutingProblem problem = ...
String myAlgorithmConfigXmlFilname = ...
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(problem, myAlgorithmConfigXmlFilename);</code></pre>
##### In code
This file has been truncated. show original
ifley
March 29, 2018, 7:00am
3
Perfect. Thanks a lot.
What is the variation coefficient termination?
If the coefficient of variation of the solutions obtained in the past X iterations is smaller than a specified threshold, the algo will terminate.
You can check out the implementation here:
/*
* Licensed to GraphHopper GmbH under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* GraphHopper GmbH licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.graphhopper.jsprit.core.algorithm.termination;
import com.graphhopper.jsprit.core.algorithm.SearchStrategy;
This file has been truncated. show original
ifley
March 29, 2018, 7:40am
5
In which case changing of this value can be useful?
In the case of dynamically terminating a solution. You might decide that if the last 100 iterations amount to nothing but bashing your head against the wall, you might as well terminate. This termination criteria requires no assumptions on your part re: how many iterations are needed or how long an algorithm should run.
So, one solution may terminate after 2 minutes and 1000 iterations, another after 30 secs and 1500 iterations. Clearly, those problems will be of drastically different size and constraint complexity, but both were terminated when the last 100 iterations were detected as not giving any real improvement. They terminated when they were considered “solved”.
ifley
August 12, 2018, 4:41pm
8
Are there recommended values of number of solutions and threshold?