Control¶
-
class
mpcpy.Control(stateestimation, prediction, parameters=None, horizon=None, timestep=None, receding=None, savesolutions=0)[source]¶ Base class for defining the control for an mpc simulation
the
formulationandsolutionmethods must be redefined in a child class to generate control signals over the control horizonInitializes the control object
Parameters: stateestimation : mpcpy.Stateestimation
The object used to determine the state at the beginning of the control horizon.
prediction : mpcpy.Prediction object
The object used to determine the predictions over the control horizon.
parameters : dict
Dictionary specifying control parameters.
horizon : number
The length of the control horizon.
timestep : number
The length of the control timestep.
receding : number
The receding time, i.e. the time between subsequent calls to this control object.
savesolutions : int
Number of control solutions to be saved in the control object. Set to -1 to save all solutions.
-
__call__(starttime)[source]¶ Calculate the value of the control signal over the control horizon. Calls the
solutionmethod.Parameters: starttime : real
Time at the beginning of the control horizon.
Returns: dict
A dictionary with representing the control signals with time.
-
formulation()[source]¶ Performs actions the first time the control is run.
Can be used to set up an optimal control problem. The set-up and solution are separated as sometimes the set-up takes a significant amount of time and performs actions which must not be repeated.
Should be redefined in a child class to set up the actual control algorithm.
-
solution(state, prediction)[source]¶ Returns the control profiles (“the plan”).
Should be redefined in a child class to set up the actual control algorithm.
Parameters: state : dict
Dictionary with the states at the start of the control horizon as returned by the stateestimation object.
prediction : dict
Dictionary with the values of predictions over the control horizon as returned by the prediction object.
Returns: dict
Dictionary with the solution, “time” must be a key.
-