time_concatenate_pwc

Graph.time_concatenate_pwc(pwc_list, *, name=None)

Concatenate multiple piecewise-constant functions in the time dimension.

Parameters:
  • pwc_list (list[Pwc]) – The individual piecewise-constant functions \(\{A_i(t)\}\) to concatenate. All the functions must have the same value shape, and can have broadcastable batch shapes.

  • name (str or None, optional) – The name of the node.

Returns:

The concatenated piecewise-constant function (or batch of functions).

Return type:

Pwc

See also

Graph.pwc

Create piecewise-constant functions.

Graph.pwc_sum

Sum multiple Pwcs.

Graph.symmetrize_pwc

Symmetrize Pwcs.

Graph.time_reverse_pwc

Reverse Pwcs in time.

Notes

The function resulting from the concatenation is

\[\begin{split}C(t) = \begin{cases} A_0(t) & \mathrm{for} & 0 < t < \tau_0 \\ A_1(t - \tau_0) & \mathrm{for} & \tau_0 < t < \tau_0 + \tau_1 \\ A_2(t - \tau_0 - \tau_1) & \mathrm{for} & \tau_0 + \tau_1 < t < \tau_0 + \tau_1 + \tau_2 \\ & \vdots & \end{cases}\end{split}\]

where \(\tau_i\) is the duration of the i-th function.

For more information on Pwc nodes see the Working with time-dependent functions in Boulder Opal topic.

Examples

Concatenate two piecewise-constant functions.

>>> pwc1 = graph.pwc(durations=np.array([0.2, 0.5]), values=np.array([1, 2]))
>>> pwc2 = graph.pwc(durations=np.array([0.7, 0.9]), values=np.array([3, 4]))
>>> graph.time_concatenate_pwc([pwc1, pwc2], name="concat")
<Pwc: name="concat", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="concat")
>>> result["output"]["concat"]
{
    'durations': array([0.2, 0.5, 0.7, 0.9]),
    'values': array([1., 2., 3., 4.]),
    'time_dimension': 0