get_penalty_from_target

(function from pyomo.contrib.mpc.modeling.cost_expressions)

pyomo.contrib.mpc.modeling.cost_expressions.get_penalty_from_target(variables, time, setpoint_data, weight_data=None, variable_set=None, tolerance=None, prefer_left=None)[source]

A function to get a penalty expression for specified variables from a target that is constant, piecewise constant, or time-varying.

This function accepts ScalarData, IntervalData, or TimeSeriesData objects, or compatible mappings/tuples as the target, and builds the appropriate penalty expression for each. Mappings are converted to ScalarData, and tuples (of data dict, time list) are unpacked and converted to IntervalData or TimeSeriesData depending on the contents of the time list.

Parameters:
  • variables (List) – List of time-indexed variables to be penalized

  • time (Set) – Set of time points at which to construct penalty expressions. Also indexes the returned Expression.

  • setpoint_data (ScalarData, TimeSeriesData, or IntervalData) – Data structure representing the possibly time-varying or piecewise constant setpoint

  • weight_data (ScalarData (optional)) – Data structure holding the weights to be applied to each variable

  • variable_set (Set (optional)) – Set indexing the provided variables, if one already exists. Also indexes the returned Expression.

  • tolerance (Float (optional)) – Tolerance for checking inclusion within an interval. Only may be provided if IntervalData is provided as the setpoint.

  • prefer_left (Bool (optional)) – Flag indicating whether left endpoints of intervals should take precedence over right endpoints. Default is False. Only may be provided if IntervalData is provided as the setpoint.

Returns:

Set indexing the list of provided variables and an Expression, indexed by this set and the provided time set, containing the penalties for each variable at each point in time.

Return type:

Set, Expression