scheduler
Class TravelPartsGenerator

java.lang.Object
  extended byscheduler.TravelPartsGenerator

public final class TravelPartsGenerator
extends java.lang.Object

A generator of travel parts for the given origin and destination.

Author:
Piotrek

Field Summary
static double AIRPORTS_START_SEARCH_RANGE
          A range to start the search for the train stations in, if the greater range value is specified.
static double BUS_STOPS_START_SEARCH_RANGE
          A range to start the search for the bus stops in, if the greater range value is specified.
private  FeedbackTravelPartsProvider feedbackTravelPartsProvider
          A provider of feedback travel parts.
static double HARBOURS_START_SEARCH_RANGE
          A range to start the search for the harbours in, if the greater range value is specified.
private  LocationsTravelInfoProvider infoProvider
          A provider of the travel information on the world.
static int MAX_AIRPORTS_IN_RANGE_NUMBER
          The max number of airports to be returned when searching for airports in some range.
static int MAX_BUS_STOPS_IN_RANGE_NUMBER
          The max number of bus stops to be returned when searching for bus stops in some range.
static int MAX_DEPTH
          Defines the deepest level at which the partitioning algorithm performs to search.
static int MAX_FEEDBACK_KNOWLEDGE_DEPTH
          Defines the maximal depth at which the feedback rules are launched.
static int MAX_HARBOURS_IN_RANGE_NUMBER
          The max number of harbours to be returned when searching for harbours in some range.
static int MAX_TRAIN_STATIONS_IN_RANGE_NUMBER
          The max number of train stations to be returned when searching for train stations in some range.
static double MAX_TRAVEL_PARTS_SPACE
          Defines a maximal space between two travel parts in the division.
private static double MAX_UNPLANNED_DISTANCE
          Defines a maximal distance route might be away from origin or destination to be considered a close one.
private  MeansOfTransportationProvider meansOfTransportationProvider
          A provider of means of transportation for the two given points.
static double TRAIN_STATIONS_START_SEARCH_RANGE
          A range to start the search for the train stations in, if the greater range value is specified.
private  TravelConstraints travelConstraints
          The travel constraints.
 
Constructor Summary
TravelPartsGenerator()
          Constructor.
 
Method Summary
static boolean AreCloseEnough(Location x, Location y)
          Gets a boolean value indicating whether the two given locations are close enough to each other to be accepted as a space between two travel parts.
private  java.util.ArrayList GenerateParts(Location origin, Location destination, Station originStation, Station destinationStation, int depth)
          Gets a list of all possible divisions into parts taken by some mean of transportation of a travel from the given origin to the given destination.
 java.util.ArrayList GenerateTravelParts(Location origin, Location destination, TravelConstraints travelConstraints)
          Gets a list of possible divisions of the travel into the travel parts.
private  java.util.ArrayList GetAirports(Location location, int range)
          Gets the airports close to the given location, but no more then some limit value.
private  java.util.ArrayList GetBusStops(Location location, int range)
          Gets the bus stops close to the given location, but no more then some limit value.
private  java.util.ArrayList GetClosestStations(java.util.ArrayList stations, Location location, int countLimit)
          Gets a list of at most given number of stations being the closest ones from the given list to the given location.
private  java.util.ArrayList GetHarbours(Location location, int range)
          Gets the harbours close to the given location, but no more then some limit value.
static int GetMaxPartsCount()
          Gets the max parts count with the current MAX_DEPTH value.
private  java.util.ArrayList GetStations(int meanOfTransportation, Location location, int range)
          Gets a list of stations for the given location and mean of transportation.
private  java.util.ArrayList GetTrainStations(Location location, int range)
          Gets the train stations close to the given location, but no more then some limit value.
private  void MinimiseUnplannedDistances(java.util.ArrayList divisions, Location origin, Location destination)
          Removes routes with the unplanned distances much longer then the of other ones.
private  void MinimiseUnplannedDistancesPerSide(java.util.ArrayList divisions, Location origin, Location destination)
          Removes routes with the unplanned distances much longer then the of other ones.
private  void RemoveDuplicatedDivisions(java.util.ArrayList divisions)
          Removes all duplicated divisions.
private  void RemoveFarTooLongDivisions(java.util.ArrayList divisions)
          Removes travel divisions much longer then the rest of them.
private  void RemoveForbiddenMeansOfTransportation(java.util.ArrayList meansOfTransportation)
          Removes the forbidden means of transportation by user unless it would means a removal of all of them.
private  void RemoveProhibitedMeansOfTransportation(java.util.ArrayList divisions)
          Removes the divisions that use the forbiden means of transportation, unless it would mean a removal of all divisions.
 void SetFeedbackTravelPartsProvider(FeedbackTravelPartsProvider feedbackTravelPartsProvider)
          Sets the provider of the feedback travel parts.
 void SetMeansOfTransportationProvider(MeansOfTransportationProvider meansOfTransportationProvider)
          Sets the provider of the appropriate means of transportation for the two given locations.
 void SetTravelInfoProvider(LocationsTravelInfoProvider infoProvider)
          Sets the provider of the travel information on the world.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

infoProvider

private LocationsTravelInfoProvider infoProvider
A provider of the travel information on the world.


travelConstraints

private TravelConstraints travelConstraints
The travel constraints.


MAX_TRAVEL_PARTS_SPACE

public static final double MAX_TRAVEL_PARTS_SPACE
Defines a maximal space between two travel parts in the division. Do not change its value, otherwise the second step of the scheduling algorithm might not work properly.

See Also:
Constant Field Values

MAX_DEPTH

public static final int MAX_DEPTH
Defines the deepest level at which the partitioning algorithm performs to search. Below it, the algorithm stops.

See Also:
Constant Field Values

MAX_UNPLANNED_DISTANCE

private static final double MAX_UNPLANNED_DISTANCE
Defines a maximal distance route might be away from origin or destination to be considered a close one.

See Also:
Constant Field Values

MAX_AIRPORTS_IN_RANGE_NUMBER

public static final int MAX_AIRPORTS_IN_RANGE_NUMBER
The max number of airports to be returned when searching for airports in some range.

See Also:
Constant Field Values

MAX_BUS_STOPS_IN_RANGE_NUMBER

public static final int MAX_BUS_STOPS_IN_RANGE_NUMBER
The max number of bus stops to be returned when searching for bus stops in some range.

See Also:
Constant Field Values

MAX_TRAIN_STATIONS_IN_RANGE_NUMBER

public static final int MAX_TRAIN_STATIONS_IN_RANGE_NUMBER
The max number of train stations to be returned when searching for train stations in some range.

See Also:
Constant Field Values

MAX_HARBOURS_IN_RANGE_NUMBER

public static final int MAX_HARBOURS_IN_RANGE_NUMBER
The max number of harbours to be returned when searching for harbours in some range.

See Also:
Constant Field Values

BUS_STOPS_START_SEARCH_RANGE

public static final double BUS_STOPS_START_SEARCH_RANGE
A range to start the search for the bus stops in, if the greater range value is specified.

See Also:
Constant Field Values

TRAIN_STATIONS_START_SEARCH_RANGE

public static final double TRAIN_STATIONS_START_SEARCH_RANGE
A range to start the search for the train stations in, if the greater range value is specified.

See Also:
Constant Field Values

AIRPORTS_START_SEARCH_RANGE

public static final double AIRPORTS_START_SEARCH_RANGE
A range to start the search for the train stations in, if the greater range value is specified.

See Also:
Constant Field Values

HARBOURS_START_SEARCH_RANGE

public static final double HARBOURS_START_SEARCH_RANGE
A range to start the search for the harbours in, if the greater range value is specified.

See Also:
Constant Field Values

meansOfTransportationProvider

private MeansOfTransportationProvider meansOfTransportationProvider
A provider of means of transportation for the two given points.


feedbackTravelPartsProvider

private FeedbackTravelPartsProvider feedbackTravelPartsProvider
A provider of feedback travel parts.


MAX_FEEDBACK_KNOWLEDGE_DEPTH

public static final int MAX_FEEDBACK_KNOWLEDGE_DEPTH
Defines the maximal depth at which the feedback rules are launched.

See Also:
Constant Field Values
Constructor Detail

TravelPartsGenerator

public TravelPartsGenerator()
Constructor.

Method Detail

SetTravelInfoProvider

public void SetTravelInfoProvider(LocationsTravelInfoProvider infoProvider)
Sets the provider of the travel information on the world.

Parameters:
infoProvider - A provider to be set.

GenerateTravelParts

public java.util.ArrayList GenerateTravelParts(Location origin,
                                               Location destination,
                                               TravelConstraints travelConstraints)
Gets a list of possible divisions of the travel into the travel parts.

Parameters:
origin - An origin of the travel.
destination - A destination of the travel.
travelConstraints - The travel constraints.
Returns:
A list of lists of travel parts. If there are no possible divisions, the empty list is returned. @see TravelPartsList

RemoveDuplicatedDivisions

private void RemoveDuplicatedDivisions(java.util.ArrayList divisions)
Removes all duplicated divisions. Leaves only one of indentical divisions.

Parameters:
divisions - A list of divisions to be cleared of duplicated divisions.

AreCloseEnough

public static boolean AreCloseEnough(Location x,
                                     Location y)
Gets a boolean value indicating whether the two given locations are close enough to each other to be accepted as a space between two travel parts.

Parameters:
x - The first of the locations to be tested.
y - The second of the locations to be tested.
Returns:
A boolean value indicating whether the two given locations are close enough to each other to be accepted as a space between two travel parts.

GetMaxPartsCount

public static int GetMaxPartsCount()
Gets the max parts count with the current MAX_DEPTH value.

Returns:
The max parts count.

GenerateParts

private java.util.ArrayList GenerateParts(Location origin,
                                          Location destination,
                                          Station originStation,
                                          Station destinationStation,
                                          int depth)
Gets a list of all possible divisions into parts taken by some mean of transportation of a travel from the given origin to the given destination.

Parameters:
origin - The origin of the travel to be divided.
destination - The destination of the travel to be devided.
originStation - The origin station. Null if the origin location is not a station.
destinationStation - The destination station. Null if the destination location is not a station.
depth - The one-based depth of the recursive call.
Returns:
A list of lists of travel parts. If there are no possibilities, the empty list is returned.

RemoveForbiddenMeansOfTransportation

private void RemoveForbiddenMeansOfTransportation(java.util.ArrayList meansOfTransportation)
Removes the forbidden means of transportation by user unless it would means a removal of all of them.

Parameters:
meansOfTransportation - A list to be cleared of forbidden means of transportation.

RemoveProhibitedMeansOfTransportation

private void RemoveProhibitedMeansOfTransportation(java.util.ArrayList divisions)
Removes the divisions that use the forbiden means of transportation, unless it would mean a removal of all divisions.

Parameters:
divisions - A list of travel divisions to be cleared.

GetStations

private java.util.ArrayList GetStations(int meanOfTransportation,
                                        Location location,
                                        int range)
Gets a list of stations for the given location and mean of transportation.

Parameters:
meanOfTransportation - A mean of transportation.
location - An origin location.
range - A search radius.
Returns:
A list of stations or an empty list if the range was 0.
See Also:
MeanOfTransportation.AIRPLANE, MeanOfTransportation.BUS, MeanOfTransportation.TRAIN, MeanOfTransportation.SHIP

MinimiseUnplannedDistances

private void MinimiseUnplannedDistances(java.util.ArrayList divisions,
                                        Location origin,
                                        Location destination)
Removes routes with the unplanned distances much longer then the of other ones.

Parameters:
divisions - A set of travel divisions to be cleared.
origin - An origin of the travel.
destination - A destiantion of the travel.

MinimiseUnplannedDistancesPerSide

private void MinimiseUnplannedDistancesPerSide(java.util.ArrayList divisions,
                                               Location origin,
                                               Location destination)
Removes routes with the unplanned distances much longer then the of other ones. Treats the origin and the destination separately.

Parameters:
divisions - A set of travel divisions to be cleared.
origin - An origin of the travel.
destination - A destiantion of the travel.

RemoveFarTooLongDivisions

private void RemoveFarTooLongDivisions(java.util.ArrayList divisions)
Removes travel divisions much longer then the rest of them.

Parameters:
divisions - A list of travel divisions to be cleared of much longer ones.

GetClosestStations

private java.util.ArrayList GetClosestStations(java.util.ArrayList stations,
                                               Location location,
                                               int countLimit)
Gets a list of at most given number of stations being the closest ones from the given list to the given location.

Parameters:
stations - A list of stations to choose from.
location - A location to count the distances to.
countLimit - A max number of stations to return.
Returns:
A list of selected stations.

GetAirports

private java.util.ArrayList GetAirports(Location location,
                                        int range)
Gets the airports close to the given location, but no more then some limit value.

Parameters:
location - A location around which to search for the airports.
range - A range to search for the airports in.
Returns:
A list of airports close to the given location.

GetBusStops

private java.util.ArrayList GetBusStops(Location location,
                                        int range)
Gets the bus stops close to the given location, but no more then some limit value.

Parameters:
location - A location around which to search for the bus stops.
range - A range to search for the bus stops in.
Returns:
A list of bus stops close to the given location.

GetTrainStations

private java.util.ArrayList GetTrainStations(Location location,
                                             int range)
Gets the train stations close to the given location, but no more then some limit value.

Parameters:
location - A location around which to search for the train stations.
range - A range to search for the train station in.
Returns:
A list of train stations close to the given location.

GetHarbours

private java.util.ArrayList GetHarbours(Location location,
                                        int range)
Gets the harbours close to the given location, but no more then some limit value.

Parameters:
location - A location around which to search for the harbours.
range - A range to search for the harbours in.
Returns:
A list of harbours close to the given location.

SetMeansOfTransportationProvider

public void SetMeansOfTransportationProvider(MeansOfTransportationProvider meansOfTransportationProvider)
Sets the provider of the appropriate means of transportation for the two given locations.

Parameters:
meansOfTransportationProvider - A provider of means of transportation to be used.

SetFeedbackTravelPartsProvider

public void SetFeedbackTravelPartsProvider(FeedbackTravelPartsProvider feedbackTravelPartsProvider)
Sets the provider of the feedback travel parts.

Parameters:
feedbackTravelPartsProvider - A provider of feedback travel parts to be used.