Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh] Add quasi-random sampling: Halton #828

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ppsci/constraint/boundary_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BoundaryConstraint(base.Constraint):
geom (geometry.Geometry): Geometry where data sampled from.
dataloader_cfg (Dict[str, Any]): Dataloader config.
loss (loss.Loss): Loss functor.
random (Literal["pseudo", "LHS"], optional): Random method for sampling data in
random (Literal["pseudo", "Halton", "LHS"], optional): Random method for sampling data in
geometry. Defaults to "pseudo".
criteria (Optional[Callable]): Criteria for refining specified boundaries.
Defaults to None.
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(
geom: geometry.Geometry,
dataloader_cfg: Dict[str, Any],
loss: "loss.Loss",
random: Literal["pseudo", "LHS"] = "pseudo",
random: Literal["pseudo", "Halton", "LHS"] = "pseudo",
criteria: Optional[Callable] = None,
evenly: bool = False,
weight_dict: Optional[Dict[str, Union[float, Callable]]] = None,
Expand Down
4 changes: 2 additions & 2 deletions ppsci/constraint/initial_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class InitialConstraint(base.Constraint):
geom (geometry.TimeXGeometry): Geometry where data sampled from.
dataloader_cfg (Dict[str, Any]): Dataloader config.
loss (loss.Loss): Loss functor.
random (Literal["pseudo", "LHS"], optional): Random method for sampling data in
random (Literal["pseudo", "Halton", "LHS"], optional): Random method for sampling data in
geometry. Defaults to "pseudo".
criteria (Optional[Callable]): Criteria for refining specified boundaries.
Defaults to None.
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(
geom: geometry.TimeXGeometry,
dataloader_cfg: Dict[str, Any],
loss: "loss.Loss",
random: Literal["pseudo", "LHS"] = "pseudo",
random: Literal["pseudo", "Halton", "LHS"] = "pseudo",
criteria: Optional[Callable] = None,
evenly: bool = False,
weight_dict: Optional[Dict[str, Callable]] = None,
Expand Down
4 changes: 2 additions & 2 deletions ppsci/constraint/integral_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IntegralConstraint(base.Constraint):
geom (geometry.Geometry): Geometry where data sampled from.
dataloader_cfg (Dict[str, Any]): Dataloader config.
loss (loss.Loss): Loss functor.
random (Literal["pseudo", "LHS"], optional): Random method for sampling data in
random (Literal["pseudo", "Halton", "LHS"], optional): Random method for sampling data in
geometry. Defaults to "pseudo".
criteria (Optional[Callable]): Criteria for refining specified boundaries.
Defaults to None.
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(
geom: geometry.Geometry,
dataloader_cfg: Dict[str, Any],
loss: "loss.Loss",
random: Literal["pseudo", "LHS"] = "pseudo",
random: Literal["pseudo", "Halton", "LHS"] = "pseudo",
criteria: Optional[Callable] = None,
weight_dict: Optional[Dict[str, Callable]] = None,
name: str = "IgC",
Expand Down
4 changes: 2 additions & 2 deletions ppsci/constraint/interior_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class InteriorConstraint(base.Constraint):
geom (geometry.Geometry): Geometry where data sampled from.
dataloader_cfg (Dict[str, Any]): Dataloader config.
loss (loss.Loss): Loss functor.
random (Literal["pseudo", "LHS"], optional): Random method for sampling data in
random (Literal["pseudo", "Halton", "LHS"], optional): Random method for sampling data in
geometry. Defaults to "pseudo".
criteria (Optional[Callable]): Criteria for refining specified boundaries.
Defaults to None.
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(
geom: geometry.Geometry,
dataloader_cfg: Dict[str, Any],
loss: "loss.Loss",
random: Literal["pseudo", "LHS"] = "pseudo",
random: Literal["pseudo", "Halton", "LHS"] = "pseudo",
criteria: Optional[Callable] = None,
evenly: bool = False,
weight_dict: Optional[Dict[str, Union[Callable, float]]] = None,
Expand Down
4 changes: 2 additions & 2 deletions ppsci/constraint/periodic_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PeriodicConstraint(base.Constraint):
dataloader_cfg (Dict[str, Any]): Dataloader config.
periodic_key (str): name of dimension which periodic constraint applied to.
loss (loss.Loss): Loss functor.
random (Literal["pseudo", "LHS"], optional): Random method for sampling data in
random (Literal["pseudo", "Halton", "LHS"], optional): Random method for sampling data in
geometry. Defaults to "pseudo".
criteria (Optional[Callable]): Criteria for refining specified boundaries.
Defaults to None.
Expand All @@ -66,7 +66,7 @@ def __init__(
periodic_key: str,
dataloader_cfg: Dict[str, Any],
loss: "loss.Loss",
random: Literal["pseudo", "LHS"] = "pseudo",
random: Literal["pseudo", "Halton", "LHS"] = "pseudo",
criteria: Optional[Callable] = None,
evenly: bool = False,
weight_dict: Optional[Dict[str, Callable]] = None,
Expand Down
2 changes: 1 addition & 1 deletion ppsci/geometry/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


def sample(
n_samples: int, ndim: int, method: Literal["pseudo", "LHS"] = "pseudo"
n_samples: int, ndim: int, method: Literal["pseudo", "Halton", "LHS"] = "pseudo"
) -> np.ndarray:
"""Generate pseudorandom or quasi-random samples in [0, 1]^ndim.

Expand Down
4 changes: 2 additions & 2 deletions ppsci/validate/geo_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GeometryValidator(base.Validator):
geom (geometry.Geometry): Geometry where data sampled from.
dataloader_cfg (Dict[str, Any]): Dataloader config.
loss (loss.Loss): Loss functor.
random (Literal["pseudo", "LHS"], optional): Random method for sampling data in
random (Literal["pseudo", "Halton", "LHS"], optional): Random method for sampling data in
geometry. Defaults to "pseudo".
criteria (Optional[Callable]): Criteria for refining specified domain. Defaults to None.
evenly (bool, optional): Whether to use evenly distribution sampling. Defaults to False.
Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(
geom: geometry.Geometry,
dataloader_cfg: Dict[str, Any],
loss: loss.Loss,
random: Literal["pseudo", "LHS"] = "pseudo",
random: Literal["pseudo", "Halton", "LHS"] = "pseudo",
criteria: Optional[Callable] = None,
evenly: bool = False,
metric: Optional[Dict[str, metric.Metric]] = None,
Expand Down