AbstractProblem#
Module for the AbstractProblem class.
- class AbstractProblem[source]#
Bases:
objectAbstract 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
AbstractProblemclass.- property collected_data#
Return the collected data from the problem’s conditions. If some domains are not sampled, they will not be returned by collected data.
- Returns:
The collected data. Keys are condition names, and values are dictionaries containing the input points and the corresponding equations or target points.
- Return type:
- property input_pts#
Return a dictionary mapping condition names to their corresponding input points. If some domains are not sampled, they will not be returned and the corresponding condition will be empty.
- 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:
Trueif all domains are discretised,Falseotherwise.- 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,latinorlh; 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
nandmodearguments. 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
nandsample_rulesare specified.RuntimeError – If neither
nnorsample_rulesare 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
randomis currently the only implementedmodefor all geometries, i.e.EllipsoidDomain,CartesianDomain,SimplexDomain, and geometry compositionsUnion,Difference,Exclusion, andIntersection. The modeslatinorlh,chebyshev,gridare only implemented forCartesianDomain.Warning
If custom discretisation is applied by setting
sample_rulesnot toNone, then the discretised domain must be of classCartesianDomain