logist.plan
Class Plan

java.lang.Object
  extended by logist.plan.Plan
All Implemented Interfaces:
java.lang.Iterable<Action>

public class Plan
extends java.lang.Object
implements java.lang.Iterable<Action>

A sequence of actions for one vehicle.

Author:
Robin Steiger

Field Summary
static Plan EMPTY
          The empty plan
 
Constructor Summary
Plan(Topology.City initialCity, Action... actions)
          Creates a simple plan from an initial city and a fixed number of actions.
Plan(Topology.City initialCity, java.util.List<Action> actions)
          Creates a simple plan from an initial city and a list of actions.
 
Method Summary
 void append(Action action)
          Appends an action to the plan
 void appendDelivery(Task task)
          Appends a delivery action to the plan
 void appendMove(Topology.City city)
          Appends a move action to the plan
 void appendPickup(Task task)
          Appends a pickup action to the plan
 boolean isSealed()
          Whether this plan has been sealed
 java.util.Iterator<Action> iterator()
           
 Plan seal()
          Prevent any future modification to this plan
 java.lang.String toString()
           
 double totalDistance()
          Computes the total distance (in km) of this plan
 long totalDistanceUnits()
          Computes the total distance (in units) of this plan
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final Plan EMPTY
The empty plan

Constructor Detail

Plan

public Plan(Topology.City initialCity,
            Action... actions)
Creates a simple plan from an initial city and a fixed number of actions. An empty plan can be created as follows: new Plan(initialCity)

Parameters:
initialCity - The initial city
actions - (optional) A fixed number of actions

Plan

public Plan(Topology.City initialCity,
            java.util.List<Action> actions)
Creates a simple plan from an initial city and a list of actions. An empty plan can be created as follows: new Plan(initialCity)

Parameters:
initialCity - The initial city
actions - The list of actions
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

append

public void append(Action action)
Appends an action to the plan

Parameters:
action - The action to append

appendMove

public void appendMove(Topology.City city)
Appends a move action to the plan

Parameters:
city - The target of the move

appendPickup

public void appendPickup(Task task)
Appends a pickup action to the plan

Parameters:
task - The task to pick up

appendDelivery

public void appendDelivery(Task task)
Appends a delivery action to the plan

Parameters:
task - The task to deliver

seal

public Plan seal()
Prevent any future modification to this plan


isSealed

public boolean isSealed()
Whether this plan has been sealed


iterator

public java.util.Iterator<Action> iterator()
Specified by:
iterator in interface java.lang.Iterable<Action>

totalDistance

public double totalDistance()
Computes the total distance (in km) of this plan


totalDistanceUnits

public long totalDistanceUnits()
Computes the total distance (in units) of this plan

See Also:
Measures