mpcrl.WarmStartStrategy#
- class mpcrl.WarmStartStrategy(warmstart='last-successful', structured_points=None, random_points=None, update_biases_for_random_points=True, seed=None)[source]#
Bases:
objectClass 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_points
csnlp.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_points
csnlp.multistart.RandomStartPoints, optional Class containing info on how to generate random starting points for the NLP solver. Its
csnlp.multistart.RandomStartPoints.biasesfield will be automatically updated with the last available solution (based onwarmstart), unless disabled withupdate_biases_for_random_points=False). IfNone, 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 onwarmstart). IfFalse, the biases inrandom_pointsare 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.Generatorfor sampling random points, if any were specified.Attributes
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]
- reset(seed=None)[source]#
Resets the
numpy.random.Generatorfor sampling random points, if any were specified.- Return type: