# anchored_difference_bounded_variables¶

Graph.anchored_difference_bounded_variables(count, lower_bound, upper_bound, difference_bound, initial_values=None, *, name=None)

Create a sequence of optimizable variables with an anchored difference bound.

Use this function to create a sequence of optimization variables that have a difference bound (each variable is constrained to be within a given distance of the adjacent variables) and are anchored to zero at the start and end (the initial and final variables are within a given distance of zero).

Parameters
• count (int) – The number $$N$$ of individual real-valued variables to create.

• lower_bound (float) – The lower bound $$v_\mathrm{min}$$ on the variables. The same lower bound applies to all count individual variables.

• upper_bound (float) – The upper bound $$v_\mathrm{max}$$ on the variables. The same upper bound applies to all count individual variables.

• difference_bound (float) – The difference bound $$\delta$$ to enforce between adjacent variables.

• initial_values (np.ndarray or List[np.ndarray], optional) – Initial values for optimization variable. Defaults to None, meaning the optimizer initializes these variables with random values. You can either provide a single initial value, or a list of them. Note that all optimization variables in a graph with non-default initial values must have the same length. That is, you must set them either as a single array or a list of arrays of the same length.

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

Returns

The sequence $$\{v_n\}$$ of $$N$$ anchored difference-bounded optimization variables, satisfying $$v_\mathrm{min}\leq v_n\leq v_\mathrm{max}$$, $$|v_{n-1}-v_n|\leq\delta$$ for $$2\leq n\leq N$$, $$|v_1|\leq\delta$$, and $$|v_N|\leq\delta$$.

Return type

Tensor

calculate_optimization()

Function to find the minimum of generic deterministic functions.

calculate_stochastic_optimization()

Function to find the minimum of generic stochastic functions.

optimization_variable()

Create optimization variables.

Examples

Create optimizable PWC signal with anchored difference bound.

>>> values = graph.anchored_difference_bounded_variables(
...     count=10, lower_bound=-1, upper_bound=1, difference_bound=0.1
... )
>>> graph.pwc_signal(values=values, duration=1)
<Pwc: name="pwc_signal_#1", operation_name="pwc_signal", value_shape=(), batch_shape=()>


See the “Band-limited pulses with bounded slew rates” example in the How to add smoothing and band-limits to optimized controls user guide.