Single Model Solver#

Module for the single-model solver class.

class SingleModelSolver(problem, model, optimizer=None, scheduler=None, weighting=None, loss=None, use_lt=True)[source]

Bases: SingleModelMixin, ConditionAggregatorMixin, BaseSolver

Base class for implementing single-model solvers.

This class provides the standard starting point for solvers based on a single model. It combines the shared solver machinery from BaseSolver with single-model handling and condition-wise loss aggregation.

Subclasses can inherit from this class to implement solver-specific behavior while reusing the common logic for model registration, optimizer and scheduler setup, loss evaluation, weighting, and aggregation across problem conditions.

Initialization of the SingleModelSolver class.

Parameters:
  • problem (BaseProblem) – The problem to be solved.

  • model (torch.nn.Module) – The model used by the solver.

  • optimizer (TorchOptimizer) – The optimizer used by the solver. If None, the torch.optim.Adam optimizer with a learning rate of 0.001 is used. Default is None.

  • scheduler (TorchScheduler) – The scheduler used by the solver. If None, the torch.optim.lr_scheduler.ConstantLR scheduler with a factor of 1.0 is used. Default is None.

  • weighting (BaseWeighting) – The weighting strategy used to combine condition losses. If None, no weighting is applied. Default is None.

  • loss – The loss function used to compute residual losses. If None, torch.nn.MSELoss is used. Default is None.

  • use_lt (bool) – If True, the solver uses LabelTensors as input. Default is True.