MCPcopy Create free account
hub / github.com/anyoptimization/pymoo / LatinHypercubeSampling

Class LatinHypercubeSampling

pymoo/operators/sampling/lhs.py:112–169  ·  view source on GitHub ↗

Latin Hypercube Sampling operator. Generates samples using Latin Hypercube Sampling with optional criterion optimization. Attributes: smooth: Whether to use smooth LHS. iterations: Number of iterations for criterion optimization. criterion: Criterion function for op

Source from the content-addressed store, hash-verified

110
111
112class LatinHypercubeSampling(Sampling):
113 """Latin Hypercube Sampling operator.
114
115 Generates samples using Latin Hypercube Sampling with optional criterion optimization.
116
117 Attributes:
118 smooth: Whether to use smooth LHS.
119 iterations: Number of iterations for criterion optimization.
120 criterion: Criterion function for optimization.
121 """
122
123 def __init__(
124 self,
125 smooth: bool = True,
126 iterations: int = 20,
127 criterion=criterion_maxmin,
128 ) -> None:
129 """Initialize the LHS operator.
130
131 Args:
132 smooth: Whether to use smooth LHS.
133 iterations: Number of iterations for criterion optimization.
134 criterion: Criterion function for optimization.
135 """
136 super().__init__()
137 self.smooth = smooth
138 self.iterations = iterations
139 self.criterion = criterion
140
141 def _do( # type: ignore[override]
142 self, problem, n_samples: int, *args, random_state=None, **kwargs
143 ) -> np.ndarray:
144 """Generate Latin Hypercube samples.
145
146 Args:
147 problem: Optimization problem.
148 n_samples: Number of samples.
149 *args: Additional positional arguments.
150 random_state: Random state for reproducibility.
151 **kwargs: Additional keyword arguments.
152
153 Returns:
154 Sample matrix of shape (n_samples, n_var).
155 """
156 xl, xu = problem.bounds()
157
158 X = sampling_lhs(
159 n_samples,
160 problem.n_var,
161 xl=xl,
162 xu=xu,
163 smooth=self.smooth,
164 criterion=self.criterion,
165 n_iter=self.iterations,
166 random_state=random_state,
167 )
168
169 return X

Callers 2

_doMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…