Class RoadLocation
- java.lang.Object
-
- org.optaplanner.examples.common.domain.AbstractPersistable
-
- org.optaplanner.examples.tsp.domain.location.Location
-
- org.optaplanner.examples.tsp.domain.location.RoadLocation
-
public class RoadLocation extends Location
The cost between 2 locations was precalculated on a real road network route. The cost itself might be the distance in km, the travel time, the fuel usage or a weighted function of any of those. Used withDistanceType.ROAD_DISTANCE.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<RoadLocation,Double>travelDistanceMap-
Fields inherited from class org.optaplanner.examples.tsp.domain.location.Location
latitude, longitude, name
-
Fields inherited from class org.optaplanner.examples.common.domain.AbstractPersistable
id
-
-
Constructor Summary
Constructors Constructor Description RoadLocation()RoadLocation(long id, double latitude, double longitude)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetDistanceTo(Location location)The distance's unit of measurement depends on theTspSolution'sDistanceType.Map<RoadLocation,Double>getTravelDistanceMap()voidsetTravelDistanceMap(Map<RoadLocation,Double> travelDistanceMap)-
Methods inherited from class org.optaplanner.examples.tsp.domain.location.Location
getAirDistanceDoubleTo, getAngle, getLatitude, getLongitude, getName, setLatitude, setLongitude, setName, toString
-
Methods inherited from class org.optaplanner.examples.common.domain.AbstractPersistable
getId, setId
-
-
-
-
Field Detail
-
travelDistanceMap
protected Map<RoadLocation,Double> travelDistanceMap
-
-
Method Detail
-
getTravelDistanceMap
public Map<RoadLocation,Double> getTravelDistanceMap()
-
setTravelDistanceMap
public void setTravelDistanceMap(Map<RoadLocation,Double> travelDistanceMap)
-
getDistanceTo
public long getDistanceTo(Location location)
Description copied from class:LocationThe distance's unit of measurement depends on theTspSolution'sDistanceType. It can be in miles or km, but for most cases it's in the TSPLIB's unit of measurement.- Specified by:
getDistanceToin classLocation- Parameters:
location- never null- Returns:
- a positive number, the distance multiplied by 1000 to avoid floating point arithmetic rounding errors
-
-