set_sampling_var

Class method.

do_mpc.sampling.samplingplanner.SamplingPlanner.set_sampling_var(self, name, fun_var_pdf=None)

Introduce new sampling variables to the SamplingPlanner. Define variable name. Optionally add a function to generate values for the sampled variable (e.g. following some distribution). The parameter fun_var_pdf defaults to None.

Note

If no value-generating function is passed (for any of the introduced variables), all sampling cases must be created manually with add_sampling_case().

Note

Value generating function fun_var_pdf must not require inputs.

Example:

sp = do_mpc.sampling.SamplingPlanner()

# Plan with two variables alpha and beta:
sp.set_sampling_var('alpha', np.random.randn)
sp.set_sampling_var('beta', lambda: np.random.randint(0,5))

In the example we have passed a BuiltinFunction for the introduced variable alpha. We use the function that created values from the random normal distribution with zero mean and unity covariance. For the variable beta we created a new lambda function that draws random integers from 0 to 5.

Parameters:
  • name (string) – Name of the sampled variable
  • fun_var_pdf (Function of BuiltinFunction) – Declare the value-generating function of the sampled variable
Raises:
  • assertionname must be string
  • assertionfun_var_pdf must be Function or BuiltinFunction

This page is auto-generated. Page source is not available on Github.