starling.inference.constraints.RgConstraint

class RgConstraint[source]

Bases: Constraint

Methods

__init__

Create constraint for radius of gyration (Rg).

apply

Apply the constraint to the given latents.

bell_shaped_schedule

Bell-shaped schedule for time-dependent guidance strength.

compute_loss

Compute loss based on deviation from target Rg.

cosine_weight

Cosine schedule for time-dependent guidance strength.

get_adaptive_clip_threshold

Get an adaptive clipping threshold that follows a cosine schedule.

get_time_scale

Get the time-dependent scaling factor.

initialize

Called by the sampler to set model parameters.

should_apply_guidance

Check if guidance should be applied at the current timestep.

__init__(target, tolerance=0.0, force_constant=2.0, **kwargs)[source]

Create constraint for radius of gyration (Rg).

Parameters:
  • target (float) – Target Rg value in Angstroms

  • tolerance (float, default=0.0) – Allowed deviation from target before penalty applies

  • force_constant (float, default=2.0) – Force constant for the harmonic potential

  • **kwargs – Additional parameters passed to parent Constraint class

compute_loss(distance_maps: Tensor) Tuple[Tensor, Tensor][source]

Compute loss based on deviation from target Rg.

Parameters:

distance_maps (torch.Tensor) – Pre-computed distance maps from the latents

Returns:

Per-batch loss and mean loss

Return type:

Tuple[torch.Tensor, torch.Tensor]