Conditions#
- class Condition(*args, **kwargs)[source]#
Bases:
object
The
Condition
class 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
Condition
class 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
Condition
types:InputTargetCondition
: represents a supervised condition defined by bothinput
andtarget
data. The model is trained to reproduce thetarget
values given theinput
. Supported data types includetorch.Tensor
,LabelTensor
,Graph
, orData
. The class automatically selects the appropriate implementation based on the types ofinput
andtarget
.DomainEquationCondition
: represents a general physics-informed condition defined by adomain
and 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 byinput
points and anequation
. The model learns to minimize the equation residual through evaluations performed at the providedinput
. Supported data types for theinput
includeLabelTensor
orGraph
. The class automatically selects the appropriate implementation based on the types of theinput
.DataCondition
: represents an unsupervised, data-driven condition defined by theinput
only. The model is trained using a custom unsupervised loss determined by the chosenSolverInterface
, while leveraging the provided data during training. Optionalconditional_variables
can 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
Condition
directly, without manually creating subclass instances. Please refer to the specificCondition
classes 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
Condition
object 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
Condition
object.- Return type: