mpcrl.WarmStartStrategy#

class mpcrl.WarmStartStrategy(warmstart='last-successful', structured_points=None, random_points=None, update_biases_for_random_points=True, seed=None)[source]#

Bases: object

Class containing all the information to guide the warmstart strategy for the MPC’s NLP in order to speed up computations (by selecting appropriate initial conditions) and to support multiple initial conditions.

Parameters:
warmstart: “last” or “last-successful”, optional

The warmstart strategy for the MPC’s NLP solver. If "last-successful", the last successful solution is automatically used to warmstart the solver for the next iteration. If "last", the last solution is automatically used, regardless of success or failure.

structured_pointscsnlp.multistart.StructuredStartPoint, optional

Class containing info on how to generate structured starting points for the NLP solver. If None, no structured point is generated.

random_pointscsnlp.multistart.RandomStartPoints, optional

Class containing info on how to generate random starting points for the NLP solver. Its csnlp.multistart.RandomStartPoints.biases field will be automatically updated with the last available solution (based on warmstart), unless disabled with update_biases_for_random_points=False). If None, no random point is generated.

update_biases_for_random_pointsbool, optional

If True, the random points are biased around the values from the last available solution to the MPC optimization (based on warmstart). If False, the biases in random_points are not updated.

seedNone, int, array of ints, SeedSequence, BitGenerator, Generator

Seed for the random number generator. By default, None.

Methods

generate([previous_sol])

Generates some initial conditions/guesses for the primal optimization variables of the MPC's NLP problem.

reset([seed])

Resets the numpy.random.Generator for sampling random points, if any were specified.

Attributes

n_points

Returns the number of both random and structured starting points.

generate(previous_sol=None)[source]#

Generates some initial conditions/guesses for the primal optimization variables of the MPC’s NLP problem.

Parameters:
previous_soldict of (str, array_like), optional

Optional dict that contains the previous solution’s values, if available. If passed, it is used

  • to update the random points’ original, unless update_biases_for_random_points=False, at which point the original biases are kept constant (this does not affect the generation of structure points in any way)

  • to fill in the rest of the initial conditions that are not included in the multistart strategy (neither structured nor random).

Yields:
Generator of dict of (str, array_like)

Yields the initial conditions for the MPC’s NLP.

Return type:

Generator[dict[str, Union[Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], complex, bytes, str, _NestedSequence[complex | bytes | str]]], None, None]

property n_points: int[source]#

Returns the number of both random and structured starting points.

reset(seed=None)[source]#

Resets the numpy.random.Generator for sampling random points, if any were specified.

Return type:

None

Examples using mpcrl.WarmStartStrategy#

Bayesian Optimization for MPC Data-driven Tuning

Bayesian Optimization for MPC Data-driven Tuning