Closed WJSchakel closed 1 year ago
There are 3 ways in which a user would want to defined the routes:
Route definition | Template | OD | Injection file |
Pre-defined | Fixed/ProbabalisticRouteGenerator in LaneBasedTemplateGtuType |
DefaultGtuCharacteristicsGeneratorOd.draw(... Category) |
yes |
With some procedure | Generator<Route> in LaneBasedTemplateGtuType |
STRATEGICALPLANNER.ROUTE.NONE|SHORTEST in LaneBasedStrategicalRoutePlannerFactory |
yes |
Strategical planner | RouteGeneratorOd in LaneBasedStrategicalRoutePlanner from LaneBasedStrategicalRoutePlannerFactory |
RouteGeneratorOd in LaneBasedStrategicalRoutePlanner from LaneBasedStrategicalRoutePlannerFactory |
yes |
This means the following can be dropped:
StrategicalPlannerFactorySupplierOd
having a RouteGeneratorOd
.DefaultGtuCharacteristicsGeneratorOd
having a RouteGeneratorOd
.Note that if there is no route defined anywhere, but a destination is known, LaneBasedStrategicalRoutePlanner
will supply a shortest-route.
The following changes were made:
TemplateGtuType
in the name were renamed to have GtuTemplate
instead.RouteGeneratorOd
renamed to RouteGenerator
.RouteGenerator.DefaultRouteGenerator
now accepts LinkWeight
to calculate different shortest paths.RouteGenerator
is currently not used. It may however be used as part of LaneBasedStrategicalRoutePlanner
, which will default to non-cached shortest length paths without it. A RouteGenerator
can be specified in LaneBasedStrategicalRoutePlannerFactory
. No other classes refer to RouteGenerator
.LaneBasedStrategicalPlannerNone
.AbstractLaneBasedStrategicalPlanner
and LaneBasedStrategicalRoutePlanner
.nextLink()
and nextNode()
removed from StrategicalPlanner
. These made no sense with directions being gone.org.opentrafficsim.road.gtu.strategical.route
to org.opentrafficsim.road.gtu.strategical
and deleted it. Route is inherent to the strategical level.org.opentrafficsim.road.gtu.generator.od
to org.opentrafficsim.road.gtu.strategical.od
. Deleted the former, renamed the latter to org.opentrafficsim.road.od
. This now contains all OD classes, and the OdApplier
and OdOptions
classes.AbstractLaneBasedStrategicalPlannerFactory
.GtuCharacteristicsGeneratorODWrapper
.StrategicalPlannerFactorySupplierOd
.Rather than supplying different factories, one factory can itself do this job. This occurs anonymously in OdParser
(note the use of gtuTypeFactoryMap
and defaultFactory
:
LaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner> factoryByGtuType =
new LaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner>()
{
/** {@inheritDoc} */
@Override
public LaneBasedStrategicalPlanner create(final LaneBasedGtu gtu, final Route route,
final Node origin, final Node destination) throws GtuException
{
LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory =
gtuTypeFactoryMap.get(gtu.getType());
if (strategicalPlannerFactory != null)
{
// a model factory for this GTU type is specified
return strategicalPlannerFactory.create(gtu, route, origin, destination);
}
if (defaultFactory != null)
{
// a default model factory is specified
return defaultFactory.create(gtu, route, origin, destination);
}
return defaultLmrsFactory.create(gtu, route, origin, destination);
}
};
Although LaneBasedGtuCharacteristicsGenerator
and LaneBasedGtuCharacteristicsGeneratorOd
are similar, they could not be removed. The LaneBasedGtuGenerator
does not have any OD information, and hence can only call a draw()
method. Any characteristics generator that does have OD information, must combine the two by bridging them with whatever form of the OD information (e.g. an OD matrix or injection file). For example OdApplier
bridges the gap anonymously as (note how characteristicsGenerator
wraps a characteristicsGeneratorOd
from OdOptions
):
LaneBasedGtuCharacteristicsGeneratorOd characteristicsGeneratorOd =
odOptions.get(OdOptions.GTU_TYPE, lane, o, linkType);
LaneBasedGtuCharacteristicsGenerator characteristicsGenerator = new LaneBasedGtuCharacteristicsGenerator()
{
/** {@inheritDoc} */
@Override
public LaneBasedGtuCharacteristics draw() throws ProbabilityException, ParameterException, GtuException
{
Time time = simulator.getSimulatorAbsTime();
Node origin = root.getObject();
DemandNode<Node, DemandNode<Category, ?>> destinationNode = root.draw(time);
Node destination = destinationNode.getObject();
Category category = destinationNode.draw(time).getObject();
return characteristicsGeneratorOd.draw(origin, destination, category, stream);
}
};
The
LaneBasedGtuGenerator
is a general purpose GTU generator. One of its major components is aLaneBasedGtuCharacteristicsGenerator
. It has 3 implementations:LaneBasedTemplateGtuType
, defining (distributed) properties for a GTUs of one GTU type. Additional to the non-lane-based features, this adds aLaneBasedStrategicalPlannerFactory
andGenerator<Route>
. Origin and destination are alwaysnull
, the vehicle model is alwaysVehicleModel.MINMAX
.LaneBasedTemplateGtuTypeDistribution
, has multipleLaneBasedTemplateGtuType
with fixed and pre-defined probabilities.GtuCharacteristicsGeneratorODWrapper
(an innertype inOdApplier
). This class houses a rootDemandNode
from which an originNode
, a destinationNode
, and aCategory
are drawn. TheCategory
may include such things as theLane
, theGtuType
and theRoute
. Next, the class has aGtuCharacteristicsGeneratorOd
.There are two implementation for
GtuCharacteristicsGeneratorOd
. The first is part of the ramp-metering demo. The second one isDefaultGtuCharacteristicsGeneratorOd
. This class uses:Generator<GtuType>
which may benull
and currently is in all applications. (The GTU type comes from the demand.)Map<GtuType, TemplateGtuType>
, which are set in theOdParser
.RouteGeneratorOd
which may benull
and currently is in all applications. (Route comes from demand, or model determines it.) This class is used in other places, and derives aRoute
based onNode
origin,Node
destination and aGtuType
.StrategicalPlannerFactorySupplierOd
which has two anonymous implementations. A default implementation under the staticlmrs()
method, which ignores the originNode
, destinationNode
, and theCategory
. The other implementation is part of theOdParser
and also ignores the originNode
and destinationNode
. It uses theCategory
to get a factory as defined in XML, if the category entails a GTU type.Eventually either of these anonymous implementations uses a
LaneBasedStrategicalPlannerFactory
to create a strategical planner based on aRoute
, originNode
and destinationNode
, which may however all benull
. Its only subtype isAbstractLaneBasedStrategicalPlannerFactory
, housing aLaneBasedTacticalPlannerFactory
andParameterFactory
. It implements desired speed and desired headway peeking. One further subtype isLaneBasedStrategicalRoutePlannerFactory
which also houses aRouteGeneratorOd
, which may benull
. It generatesLaneBasedStrategicalRoutePlanner
s, which may or may not have aRouteGeneratorOd
. It has a super classAbstractLaneBasedStrategicalPlanner
which only wraps a GTU.The conclusion is that this is all way too complicated/convoluted. Routes can be specified in many places, and it is impossible to keep track of these places. Much input is currently ignored. Some classes have only single implementations. This whole structure provides no suitable tools to create GTU generation from injection files (issue #44). The "OD" nature of many classes is unnecessary. It is good that methods may provide route/origin/destination, but these need not come from an OD. Hence, the classes should not depend on an OD, or classes only suitable to be used by the
OdApplier
.