Skip to content

generate_initial_conditions

RL4CRN.utils.generate_initial_conditions

generate_triangular_prism_points(max_val=10.0, radius=1.0, n_height=20, n_along_edge=20)

Generate surface samples of a triangular prism centered on the diagonal line x=y=z.

This utility constructs a regular triangle in the plane orthogonal to the diagonal direction (i.e., in the plane x+y+z=0), then translates that triangle along the axis x=y=z to form a prism. Points are sampled on the three rectangular faces of the prism by linearly interpolating along each triangle edge at multiple heights.

After sampling, each point is assigned to one of three classes based on the index of its maximum coordinate:

  • A: x is strictly/weakly the largest coordinate (argmax = 0)
  • B: y is strictly/weakly the largest coordinate (argmax = 1)
  • C: z is strictly/weakly the largest coordinate (argmax = 2)
PARAMETER DESCRIPTION
max_val

Upper bound of the ambient cube [0, max_val]^3 in which points are generated.

TYPE: float DEFAULT: 10.0

radius

Distance from the axis x=y=z to the triangle vertices (controls prism thickness).

TYPE: float DEFAULT: 1.0

n_height

Number of sample positions along the axis x=y=z.

TYPE: int DEFAULT: 20

n_along_edge

Number of samples along each triangle edge for each height (controls face resolution).

TYPE: int DEFAULT: 20

RETURNS DESCRIPTION

dict[str, list[list[float]]]: Dictionary mapping class labels to lists of 3D points:

  • A: [[x, y, z], ...], points with x largest
  • B: [[x, y, z], ...], points with y largest
  • C: [[x, y, z], ...], points with z largest
Notes
  • Ties are broken by np.argmax, which returns the first occurrence of the maximum (e.g., if x==y>z the label will be indicated as "A").
  • The prism is kept inside the box [0, max_val]^3 by restricting the diagonal coordinate s to [radius, max_val-radius].
  • Only the faces of the prism are sampled (not the interior).