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:

int

property input_pts#

Return a dictionary mapping condition names to their corresponding input points.

Returns:

The input points of the problem.

Return type:

dict

property discretised_domains#

Return a dictionary mapping domains to their corresponding sampled points.

Returns:

The discretised domains.

Return type:

dict

property are_all_domains_discretised#

Check if all the domains are discretised.

Returns:

True if all domains are discretised, False otherwise.

Return type:

bool

property input_variables#

Get the input variables of the problem.

Returns:

The input variables of the problem.

Return type:

list[str]

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:

dict

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 or lh; chebyshev sampling, chebyshev; grid sampling grid.

  • 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 and mode 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) and mode (sampling method). Defaults to None.

Raises:
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 implemented mode for all geometries, i.e. EllipsoidDomain, CartesianDomain, SimplexDomain, and geometry compositions Union, Difference, Exclusion, and Intersection. The modes latin or lh, chebyshev, grid are only implemented for CartesianDomain.

Warning

If custom discretisation is applied by setting sample_rules not to None, then the discretised domain must be of class CartesianDomain

add_points(new_points_dict)[source]#

Add new points to an already sampled domain.

Parameters:

new_points_dict (dict) – The dictionary mapping new points to their corresponding domain.