1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

modify to use external RNG

This commit is contained in:
oblonski 2016-04-01 12:02:46 +02:00
parent d55c080fee
commit 358010de91
2 changed files with 8 additions and 4 deletions

View file

@ -58,6 +58,7 @@ public class FiniteFleetManagerFactory implements VehicleFleetManagerFactory {
if (vehicles.isEmpty()) throw new IllegalStateException("vehicle-collection is empty. this must not be"); if (vehicles.isEmpty()) throw new IllegalStateException("vehicle-collection is empty. this must not be");
VehicleFleetManagerImpl vehicleFleetManager = new VehicleFleetManagerImpl(vehicles); VehicleFleetManagerImpl vehicleFleetManager = new VehicleFleetManagerImpl(vehicles);
vehicleFleetManager.setRandom(random); vehicleFleetManager.setRandom(random);
vehicleFleetManager.init();
return vehicleFleetManager; return vehicleFleetManager;
} }

View file

@ -81,20 +81,23 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
private Random random = RandomNumberGeneration.getRandom(); private Random random = RandomNumberGeneration.getRandom();
public VehicleFleetManagerImpl(Collection<Vehicle> vehicles) { VehicleFleetManagerImpl(Collection<Vehicle> vehicles) {
super(); super();
this.vehicles = vehicles; this.vehicles = vehicles;
int arrSize = vehicles.size() + 2; int arrSize = vehicles.size() + 2;
locked = new boolean[arrSize]; locked = new boolean[arrSize];
vehicleArr = new Vehicle[arrSize]; vehicleArr = new Vehicle[arrSize];
initializeVehicleTypes();
logger.debug("initialise {}",this);
} }
public void setRandom(Random random) { void setRandom(Random random) {
this.random = random; this.random = random;
} }
void init(){
initializeVehicleTypes();
logger.debug("initialise {}",this);
}
@Override @Override
public String toString() { public String toString() {
return "[name=finiteVehicles]"; return "[name=finiteVehicles]";