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

Function pop_from_sampling

pymoo/util/misc.py:562–595  ·  view source on GitHub ↗

Create population from sampling. Args: problem: Optimization problem. sampling: Sampling strategy or population. n_initial_samples: Number of initial samples. pop: Initial population. Returns: Population.

(
    problem: Any,
    sampling: Any,
    n_initial_samples: int,
    pop: Optional[Population] = None,
)

Source from the content-addressed store, hash-verified

560
561
562def pop_from_sampling(
563 problem: Any,
564 sampling: Any,
565 n_initial_samples: int,
566 pop: Optional[Population] = None,
567) -> Optional[Population]:
568 """Create population from sampling.
569
570 Args:
571 problem: Optimization problem.
572 sampling: Sampling strategy or population.
573 n_initial_samples: Number of initial samples.
574 pop: Initial population.
575
576 Returns:
577 Population.
578 """
579 if pop is None:
580 pop = Population()
581
582 if isinstance(sampling, Population):
583 pop = sampling
584
585 else:
586 if isinstance(sampling, np.ndarray):
587 pop = pop.new("X", sampling)
588
589 elif isinstance(sampling, Sampling):
590 pop = sampling.do(problem, n_initial_samples, pop=pop)
591
592 else:
593 return None
594
595 return pop
596
597
598def evaluate_if_not_done_yet(

Callers

nothing calls this directly

Calls 3

newMethod · 0.95
PopulationClass · 0.90
doMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…