Boundaryconditions

class mpcpy.Boundaryconditions(data, periodic=True, extra_time=604800.0, zoh_keys=None)[source]

A class to define boundaryconditions in the format required by mpcpy.

Create a boundaryconditions object.

Parameters:

data : dict

Actual boundary conditions and a time vector.

periodic : boolean, optional

Determines how to determine values when time is larger than the boundary conditions time.

extra_time : float, optional

Maximum allowed time outside the boundary conditions time, should be at least as large as the control horizon.

zoh_keys : list of strings, optional

Keys which will be interpolated with zero-order hold. All other values are interpolated linearly.

Examples

>>> bcs = Boundaryconditions({'time': np.arange(0.,24*3600.+1,3600.), 'T_amb':np.random.random(25)})
>>> bcs(12.1*3600)
__call__(time)[source]

Return the interpolated boundary conditions

Parameters:

time : number or np.array

true value for time

Returns:

dict

Dictionary with interpolated boundary conditions.

interp(key, time)[source]

Interpolate a value to an array of timesteps

Parameters:

key : str

The key to interpolate.

time : np.array

An array of times to interpolate to.