Conditions#
- class Condition(*args, **kwargs)[source]#
Bases:
objectThe
Conditionclass is a core component of the PINA framework that provides a unified interface to define heterogeneous constraints that must be satisfied by aAbstractProblem.It encapsulates all types of constraints - physical, boundary, initial, or data-driven - that the solver must satisfy during training. The specific behavior is inferred from the arguments passed to the constructor.
Multiple types of conditions can be used within the same problem, allowing for a high degree of flexibility in defining complex problems.
The
Conditionclass behavior specializes internally based on the arguments provided during instantiation. Depending on the specified keyword arguments, the class automatically selects the appropriate internal implementation.Available
Conditiontypes:InputTargetCondition: represents a supervised condition defined by bothinputandtargetdata. The model is trained to reproduce thetargetvalues given theinput. Supported data types includetorch.Tensor,LabelTensor,Graph, orData. The class automatically selects the appropriate implementation based on the types ofinputandtarget.DomainEquationCondition: represents a general physics-informed condition defined by adomainand anequation. The model learns to minimize the equation residual through evaluations performed at points sampled from the specified domain.InputEquationCondition: represents a general physics-informed condition defined byinputpoints and anequation. The model learns to minimize the equation residual through evaluations performed at the providedinput. Supported data types for theinputincludeLabelTensororGraph. The class automatically selects the appropriate implementation based on the types of theinput.DataCondition: represents an unsupervised, data-driven condition defined by theinputonly. The model is trained using a custom unsupervised loss determined by the chosenSolverInterface, while leveraging the provided data during training. Optionalconditional_variablescan be specified when the model depends on additional parameters. Supported data types includetorch.Tensor,LabelTensor,Graph, orData. The class automatically selects the appropriate implementation based on the type of theinput.
Note
The user should always instantiate
Conditiondirectly, without manually creating subclass instances. Please refer to the specificConditionclasses for implementation details.- Example:
>>> from pina import Condition
>>> # Example of InputTargetCondition signature >>> condition = Condition(input=input, target=target)
>>> # Example of DomainEquationCondition signature >>> condition = Condition(domain=domain, equation=equation)
>>> # Example of InputEquationCondition signature >>> condition = Condition(input=input, equation=equation)
>>> # Example of DataCondition signature >>> condition = Condition(input=data, conditional_variables=cond_vars)
Instantiate the appropriate
Conditionobject based on the keyword arguments passed.- Parameters:
- Raises:
ValueError – If unexpected positional arguments are provided.
ValueError – If the keyword arguments are invalid.
- Returns:
The appropriate
Conditionobject.- Return type: