ProblemInterface#

Module for the Problem Interface.

class ProblemInterface[source]#

Bases: object

Abstract interface for all problems.

abstract discretise_domain(n=None, mode='random', domains=None, sample_rules=None)[source]#

Discretise 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. This is ignored if sample_rules is provided. Default is None.

  • mode (str) – The sampling method. Available modes include: "random" for random sampling, "latin" or "lh" for latin hypercube sampling, "chebyshev" for Chebyshev sampling, and "grid" for grid sampling. Default is "random".

  • domains (str | list[str]) – The domains from which to sample. If None, all domains are considered for sampling. Default is None.

  • sample_rules (dict) – The dictionary specifying custom sampling rules for each input variable. When provided, it overrides the global n and mode arguments. Each key in the dictionary must match one of the variables defined in input_variables(), and each value must be a dictionary containing two keys: n for the number of points to sample for that variable, and mode for the sampling method to use. If None, the global n and mode parameters are used for all variables. Default is None.

Warning

"random" is the only supported mode across all geometries: CartesianDomain, EllipsoidDomain, and SimplexDomain. Sampling modes such as "latin", "chebyshev", and "grid" are only implemented for CartesianDomain. When custom discretisation is specified via sample_rules, the domain to be discretised must be an instance of CartesianDomain.

Example:
>>> problem.discretise_domain(n=10, mode="random")
>>> problem.discretise_domain(n=10, mode="lh", domains=["boundary"])
>>> problem.discretise_domain(
...     sample_rules={
...         'x': {'n': 10, 'mode': 'grid'},
...         'y': {'n': 100, 'mode': 'grid'}
...     },
... )
abstract add_points(new_points_dict)[source]#

Append additional points to an already discretised domain.

Parameters:

new_points_dict (dict) – The dictionary mapping each domain to the corresponding set of new points to be added. Each key in the dictionary must match one of the domains defined in domains, and each value must be a LabelTensor containing the new points to be added to that domain. The labels of the points to be added must correspond to those of the domain to which they are being added.

Example:
>>> additional_points = {
...     "boundary": LabelTensor(torch.rand(5, 2), labels=["x", "y"])
... }
>>> problem.add_points(additional_points)
abstract move_discretisation_into_conditions()[source]#

Move the sampled points from the discretised domains into their corresponding conditions. This ensures that the conditions are evaluated on the correct set of points after discretisation.

abstract property input_variables#

The input variables of the problem.

Returns:

The input variables of the problem.

Return type:

list[str]

abstract property output_variables#

The output variables of the problem.

Returns:

The output variables of the problem.

Return type:

list[str]

abstract property conditions#

The conditions associated with the problem.

Returns:

The conditions associated with the problem.

Return type:

dict

abstract property discretised_domains#

The dictionary containing the discretised domains of the problem. Each key corresponds to a domain defined in domains, and each value is a LabelTensor containing the sampled points for that domain.

Returns:

The discretised domains.

Return type:

dict

abstract property are_all_domains_discretised#

Whether all domains of the problem have been discretised.

Returns:

True if all domains are discretised, False otherwise.

Return type:

bool