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

Method _do

pymoo/operators/sampling/rnd.py:84–102  ·  view source on GitHub ↗

Generate random integer samples within problem bounds. Args: problem: Optimization problem. n_samples: Number of samples. *args: Additional positional arguments. random_state: Random state for reproducibility. **kwargs: Additional

(  # type: ignore[override]
        self, problem, n_samples: int, *args, random_state=None, **kwargs
    )

Source from the content-addressed store, hash-verified

82 """Random sampling operator for integer variables."""
83
84 def _do( # type: ignore[override]
85 self, problem, n_samples: int, *args, random_state=None, **kwargs
86 ) -> np.ndarray:
87 """Generate random integer samples within problem bounds.
88
89 Args:
90 problem: Optimization problem.
91 n_samples: Number of samples.
92 *args: Additional positional arguments.
93 random_state: Random state for reproducibility.
94 **kwargs: Additional keyword arguments.
95
96 Returns:
97 Sample matrix of shape (n_samples, n_var) with integer values.
98 """
99 n, (xl, xu) = problem.n_var, problem.bounds()
100 return np.column_stack(
101 [random_state.integers(xl[k], xu[k] + 1, size=n_samples) for k in range(n)]
102 )
103
104
105class PermutationRandomSampling(Sampling):

Callers

nothing calls this directly

Calls 1

boundsMethod · 0.80

Tested by

no test coverage detected