AbstractProblem#
Module for the AbstractProblem class.
- class AbstractProblem[source]#
Bases:
object
Abstract base class for PINA problems. All specific problem types should inherit from this class.
A PINA problem is defined by key components, which typically include output variables, conditions, and domains over which the conditions are applied.
Initialization of the
AbstractProblem
class.- property batching_dimension#
Get batching dimension.
- Returns:
The batching dimension.
- Return type:
- property input_pts#
Return a dictionary mapping condition names to their corresponding input points.
- Returns:
The input points of the problem.
- Return type:
- property discretised_domains#
Return a dictionary mapping domains to their corresponding sampled points.
- Returns:
The discretised domains.
- Return type:
- property are_all_domains_discretised#
Check if all the domains are discretised.
- Returns:
True
if all domains are discretised,False
otherwise.- Return type:
- property input_variables#
Get the input variables of the problem.
- abstract property output_variables#
Get the output variables of the problem.
- abstract property conditions#
Get the conditions of the problem.
- Returns:
The conditions of the problem.
- Return type:
- discretise_domain(n=None, mode='random', domains='all', sample_rules=None)[source]#
Discretize the problem’s domains by sampling a specified number of points according to the selected sampling mode.
- Parameters:
n (int) – The number of points to sample.
mode – The sampling method. Default is
random
. Available modes include: random sampling,random
; latin hypercube sampling,latin
orlh
; chebyshev sampling,chebyshev
; grid samplinggrid
.domains (str | list[str]) – The domains from which to sample. Default is
all
.sample_rules (dict) – A dictionary defining custom sampling rules for input variables. If provided, it must contain a dictionary specifying the sampling rule for each variable, overriding the
n
andmode
arguments. Each key must correspond to the input variables from :meth:~pina.problem.AbstractProblem.input_variables, and its value should be another dictionary with two keys:n
(number of points to sample) andmode
(sampling method). Defaults to None.
- Raises:
RuntimeError – If both
n
andsample_rules
are specified.RuntimeError – If neither
n
norsample_rules
are set.
- Example:
>>> problem.discretise_domain(n=10, mode='grid') >>> problem.discretise_domain(n=10, mode='grid', domains=['gamma1']) >>> problem.discretise_domain( ... sample_rules={ ... 'x': {'n': 10, 'mode': 'grid'}, ... 'y': {'n': 100, 'mode': 'grid'} ... }, ... domains=['D'] ... )
Warning
random
is currently the only implementedmode
for all geometries, i.e.EllipsoidDomain
,CartesianDomain
,SimplexDomain
, and geometry compositionsUnion
,Difference
,Exclusion
, andIntersection
. The modeslatin
orlh
,chebyshev
,grid
are only implemented forCartesianDomain
.Warning
If custom discretisation is applied by setting
sample_rules
not toNone
, then the discretised domain must be of classCartesianDomain