Emulator

class mpcpy.Emulator(input_keys, parameters=None, initial_conditions=None)[source]

Base class for defining an emulator object

Initializes the emulator object self.inputs and self.res attributes must be defined

Parameters:

input_keys : list of strings

list of strings of inputs. This is done so that not all data from the boundary conditions and control signals have to be transferred to the simulation. Only the boundary conditions and control signals in the inputs attribute are interpolated and passed to the __call__ method.

parameters : dict

A dictionary of parameters used by the emulator.

initial_conditions : dict

A dictionary of initial conditions of the system under consideration.

__call__(time, input)[source]

Simulates the system and updated the results dictionary, calls the :code:`simulate`method.

Parameters:

time : numpy array

Times at which the results are requested.

input : dict

Dictionary with values for the inputs of the model, time must be a part of it.

Returns:

dict

Dictionary with the complete simulation results.

Examples

>>> em = Emulator(['u1'])
>>> t  = np.arange(0., 3600.1, 600.)
>>> u1 = 5.*np.ones_like(t)
>>> em(t, ['time': t, 'u1': u1])
initialize()[source]

Redefine in a child class

This method is called once before the start of the MPC and by default clears the results dictionary and then add the initial conditions to it at time 0.

simulate(starttime, stoptime, input)[source]

Redefine in a child class

This method runs the simulation and should return a dictionary with results for times between the starttime and stoptime given the inputs.

Parameters:

starttime : number

time to start the simulation

stoptime : number

time to stop the simulation

input : dict

dictionary with values for the inputs for the simulation, ‘time’ and all values in self.inputs must be keys

Returns:

dict

dictionary with the simulation results