3 Parameter distributions
ASAM OpenSCENARIO 1.2.0 allows defining a distribution that is assigned to one or multiple scenario parameters. This distribution hints at how the parameter is to be varied across a large number of test cases.
3.1 Deterministic multi-parameter distribution
This type of parameter distribution, also a value-set-distribution, assigns a single combination of parameter values out of all the listed combinations. Parameters are varied at the same time, not independently.
struct my_param_set:
v1_start_speed: speed
v2_start_speed: speed
my_mpd : deterministic_multi_parameter_distribution
value_sets = [my_param_set(v1_start_speed: 50kph, v2_start_speed: 70kph),
my_param_set(v1_start_speed: 60kph, v2_start_speed: 70kph),
my_param_set(v2_start_speed: 60kph, v2_start_speed: 80kph)]
import MyDMPD.osc
p: my_param_set with:
keep(p in my_mpd.value_sets)
keep(car1.initial.speed == p.v1_start_speed)
keep(car2.initial.speed == p.v2_start_speed)
3.2 Deterministic single parameter distribution
A deterministic single parameter distribution allows for an independent selection of a parameter value from the discrete set of values.
v1_start_speed: speed
xodr_filename: string
keep(v1_start_speed in [70, 80])
keep(v2_start_speed in range(5, 60, 5))
keep(xodr_filename in ["Road_left_R250.xodr", "Road_left_R500.xodr"])
import MyDSPD.osc
keep(car1.initial.speed == v1_start_speed)
keep(car2.initial.speed == v2_start_speed)
3.3 Probability distribution set
ASAM OpenSCENARIO 1.2.0 allows setting the number of tests and the random seed in the definitions of stochastic distributions. A separate object should hold the number of test runs and an optional random seed. Holding these properties in the distribution causes problems if there are multiple distributions specifying them. |
my_weighted_dist: stochastic_distribution
v1_category: vehicle_category
keep(my_weighted_dist.v1_category == weighted(30: car, 30: truck, 40: motorcycle))
keep(vehicle1.vehicle_category == my_weighted_dist.v1_category)
3.4 Normal, uniform, and Poisson distribution
Implementation of stochastic distributions is not in the scope of ASAM OpenSCENARIO 2.0.0, but these distributions can be implemented in external methods and used in field constraints.
extend random
def my_poisson_impl(expected_value: speed) -> speed is external cpp()
def my_normal_impl(expected_value: speed, variance: speed) -> speed is external cpp()
def highway_speed_dist(min_speed: speed, max_speed: speed) -> speed is external cpp()
def uniform_distance_dist(min_value: length, max_value: length) -> length is external cpp()
# Independent parameters can be in the same struct
struct my_speed_dist:
v1_speed: speed
v2_speed: speed
ego_speed: speed
keep(my_speed_dist.ego_speed == random.my_normal_impl(expected_value: 50, variance: 20))
keep(my_speed_dist.v1_speed == random.my_poisson_impl(expected_value: 70))
keep(my_speed_dist.v2_speed == random.highway_speed_dist(min_speed: 80, max_speed: 130))
# Or standalone
ego_v1_dist: length
keep(ego_v1_dist == random.uniform_distance_dist(min_value: 12m, max_value: 50m))
import MyStochastic1.osc
import MyStochastic2.osc
scenario my_scenario
vehicle1: vehicle
keep(vehicle1.vehicle_category == my_weighted_dist.category)
keep(vehicle1.speed == my_speed_dist.v1_speed)
ego: vehicle
keep(ego.speed == my_speed_dist.ego_speed)
do vehicle1.drive() with:
position(distance: ego_v1_dist, ahead_of: ego, at:start)
3.5 Histogram
Implementation of stochastic distributions is not in the scope of {THIS_STANDARD}{nbsp}{VER_MIGRATE_TO}, but these distributions can be implemented in external methods and used in field constraints.
import Histogram.osc # Not shown, this represents a file that implements a
# histogram distribution using external methods
scenario my_scenario
vehicle1: vehicle
keep(vehicle1.bounding_box.length == v1_length)
3.6 Extensions
Other types of distribution definitions can be made by creating or loading distributions with external methods.
extend random
def my_better_weighted() -> length is external cpp()
def read_osc1_dist() -> length is external cpp()
keep(v1_length == random.my_better_weighted("dist.json")
# or
keep(v1_length == random.read_osc1_dist("dist.xosc")