artist.core.motor_position_optimizer
Attributes
A logger for the motor positions optimizer. |
Classes
Initialize the motor positions optimizer. |
Module Contents
- artist.core.motor_position_optimizer.log
A logger for the motor positions optimizer.
- class artist.core.motor_position_optimizer.MotorPositionsOptimizer(ddp_setup: dict[str, Any], scenario: artist.scenario.scenario.Scenario, optimization_configuration: dict[str, Any], incident_ray_direction: torch.Tensor, target_area_index: int, ground_truth: torch.Tensor, bitmap_resolution: torch.Tensor = torch.tensor([256, 256]), device: torch.device | None = None)
Initialize the motor positions optimizer.
Parameters
- ddp_setupdict[str, Any]
Information about the distributed environment, process_groups, devices, ranks, world_Size, heliostat group to ranks mapping.
- scenarioScenario
The scenario.
- optimization_configurationdict[str, Any]
The parameters for the optimizer, learning rate scheduler, regularizers and early stopping.
- incident_ray_directiontorch.Tensor
The incident ray direction during the optimization. Tensor of shape [4].
- target_area_indexint
The index of the target used for the optimization.
- ground_truthtorch.Tensor
The desired focal spot or distribution. Tensor of shape [4] or tensor of shape [bitmap_resolution_e, bitmap_resolution_u].
- bitmap_resolutiontorch.Tensor
The resolution of all bitmaps during optimization (default is torch.tensor([256,256])). Tensor of shape [2].
- devicetorch.device | None
The device on which to perform computations or load tensors and models (default is None). If None,
ARTISTwill automatically select the most appropriate device (CUDA or CPU) based on availability and OS.
- ddp_setup
- scenario
- optimization_configuration
- incident_ray_direction
- target_area_index
- ground_truth
- bitmap_resolution
- optimize(loss_definition: artist.core.loss_functions.Loss, device: torch.device | None = None) torch.Tensor
Optimize the motor positions.
The motor positions are optimized through a reparameterization to ensure stable training across different heliostats with widely varying initial motor positions and ranges. Motor positions can range from 0 to up to ~80000. Instead of directly optimizing the absolute motor positions, which can differ in magnitudes, an unconstrained parameter is optimized. Directly optimizing the absolute motor positions, would have very different effects depending on the scale of the motors. For small initial motor positions (e.g. ~100), a gradient update of size 10 may cause a ~10% relative change, drastically altering the motor positions of this heliostat. For large initial motor positions (e.g. ~50000), the same optimizer step would correspond to only a 0.02% relative change in motor positions, effectively freezing the optimization of this heliostat. This mismatch makes it impossible to choose a single learning rate that works robustly across all heliostats. The reparametrization of the optimizable parameter (motor positions) defines the optimizable parameter as:
\[\text{motor\_positions\_optimized} = \tanh( \text{torch.nn.Parameter(optimizable\_parameter)} )\]The true motor positions can be reconstructed by:
\[\text{motor\_positions} = \text{initial\_motor\_positions} + \text{motor\_positions\_normalized} \cdot \text{scale}\]where scale defines the range (e.g. up to ~80000) for adjustments. By optimizing as explained above instead of raw motor positions, every heliostat sees updates of comparable relative magnitude, regardless of the absolute size of its motors positions.
Parameters
- loss_definitionLoss
The definition of the loss function and pre-processing of the prediction.
- devicetorch.device | None
The device on which to perform computations or load tensors and models (default is None). If None,
ARTISTwill automatically select the most appropriate device (CUDA or CPU) based on availability and OS.
Returns
- torch.Tensor
The final loss of the motor position optimization.