WJSchakel / ots-fosim

Extension of OTS which can be used as a simulation core within FOSIM.
0 stars 0 forks source link

Fosim file with parameters results in very slow traffic #20

Closed WJSchakel closed 2 months ago

WJSchakel commented 2 months ago

When using a fos file with parameters for OTS, traffic is very slow.

WJSchakel commented 2 months ago

The following code parses parameters w and vMax. As one can see, a copy-paste error makes the width value (in meters) be used for the maximum speed (in km/h). The valueWidth variable is used in the second part, rather than valueMaxV. This code is only used if OTS parameters are present in the fos file.

        ValueData valueWidth = getParameterData(ParameterDefinitions.VEHICLE_GROUP_ID, "w").value.get(vehicleTypeNumber);
        Generator<Length> width =
                (valueLength instanceof ScalarData) ? () -> Length.instantiateSI(((ScalarData) valueWidth).value())
                        : getDistribution((DistributionData) valueWidth, stream, Length.class, LengthUnit.SI);
        ValueData valueMaxV = getParameterData(ParameterDefinitions.VEHICLE_GROUP_ID, "vMax").value.get(vehicleTypeNumber);
        Generator<Speed> speed =
                (valueMaxV instanceof ScalarData) ? () -> new Speed(((ScalarData) valueWidth).value(), SpeedUnit.KM_PER_HOUR)
                        : getDistribution((DistributionData) valueMaxV, stream, Speed.class, SpeedUnit.KM_PER_HOUR);
WJSchakel commented 2 months ago

There is actually a second error, as the code regarding width also has:

(valueLength instanceof ScalarData)
WJSchakel commented 2 months ago

Both issues have been solved.