mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add greedySchrimpfFactory
This commit is contained in:
parent
bb1e9d0659
commit
8f27dee476
2 changed files with 141 additions and 0 deletions
|
|
@ -0,0 +1,73 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import util.Resource;
|
||||
|
||||
|
||||
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.io.AlgorithmConfig;
|
||||
import basics.io.AlgorithmConfigXmlReader;
|
||||
|
||||
|
||||
/**
|
||||
* Factory that creates the {@link VehicleRoutingAlgorithm} as proposed by Schrimpf et al., 2000 with the following parameters:
|
||||
*
|
||||
* <p>
|
||||
* R&R_random (prob=0.5, F=0.5);
|
||||
* R&R_radial (prob=0.5, F=0.3);
|
||||
* threshold-accepting with exponentialDecayFunction (alpha=0.1, warmup-iterations=100);
|
||||
* nuOfIterations=2000
|
||||
*
|
||||
* <p>Gerhard Schrimpf, Johannes Schneider, Hermann Stamm- Wilbrandt, and Gunter Dueck.
|
||||
* Record breaking optimization results using the ruin and recreate principle.
|
||||
* Journal of Computational Physics, 159(2):139 – 171, 2000. ISSN 0021-9991. doi: 10.1006/jcph.1999. 6413.
|
||||
* URL http://www.sciencedirect.com/science/article/ pii/S0021999199964136
|
||||
*
|
||||
* <p>algorithm-xml-config is available at src/main/resources/schrimpf.xml.
|
||||
*
|
||||
* @author stefan schroeder
|
||||
*
|
||||
*/
|
||||
public class GreedySchrimpfFactory {
|
||||
|
||||
/**
|
||||
* Creates the {@link VehicleRoutingAlgorithm}.
|
||||
*
|
||||
* @param vrp
|
||||
* @return algorithm
|
||||
*/
|
||||
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp){
|
||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||
URL resource = Resource.getAsURL("greedySchrimpf.xml");
|
||||
new AlgorithmConfigXmlReader(algorithmConfig).read(resource.getPath());
|
||||
return VehicleRoutingAlgorithms.createAlgorithm(vrp, algorithmConfig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
68
jsprit-core/src/main/resources/greedySchrimpf.xml
Executable file
68
jsprit-core/src/main/resources/greedySchrimpf.xml
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2013 Stefan Schroeder
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Contributors:
|
||||
Stefan Schroeder - initial API and implementation
|
||||
-->
|
||||
<algorithm xmlns="http://www.w3schools.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com algorithm_schema.xsd">
|
||||
|
||||
<iterations>2000</iterations>
|
||||
|
||||
<construction>
|
||||
<insertion name="bestInsertion"/>
|
||||
</construction>
|
||||
|
||||
<strategy>
|
||||
<memory>1</memory>
|
||||
<searchStrategies>
|
||||
<searchStrategy name="randomRuinAndRecreate">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="acceptNewRemoveWorst"/>
|
||||
<modules>
|
||||
<module name="ruin_and_recreate">
|
||||
<ruin name="randomRuin">
|
||||
<share>0.5</share>
|
||||
</ruin>
|
||||
<insertion name="bestInsertion"/>
|
||||
</module>
|
||||
|
||||
</modules>
|
||||
<probability>0.5</probability>
|
||||
</searchStrategy>
|
||||
|
||||
<searchStrategy name="radialRuinAndRecreate">
|
||||
<selector name="selectBest"/>
|
||||
<acceptor name="acceptNewRemoveWorst"/>
|
||||
<modules>
|
||||
<module name="ruin_and_recreate">
|
||||
<ruin name="radialRuin">
|
||||
<share>0.3</share>
|
||||
</ruin>
|
||||
<insertion name="bestInsertion"/>
|
||||
</module>
|
||||
|
||||
</modules>
|
||||
<probability>0.5</probability>
|
||||
</searchStrategy>
|
||||
|
||||
</searchStrategies>
|
||||
</strategy>
|
||||
|
||||
|
||||
</algorithm>
|
||||
Loading…
Add table
Add a link
Reference in a new issue