optimizable_scalar

Graph.optimizable_scalar(lower_bound, upper_bound, is_lower_unbounded=False, is_upper_unbounded=False, initial_values=None, *, name=None)

Create an optimizable scalar Tensor, which can be bounded, semi-bounded, or unbounded.

Use this function to create a single variable that can be tuned by the optimizer to minimize the cost function.

Parameters

  • lower_bound (float) – The lower bound vminv_\mathrm{min} for generating an initial value for the variable. This will also be used as lower bound if the variable is lower bounded.
  • upper_bound (float) – The upper bound vmaxv_\mathrm{max} for generating an initial value for the variable. This will also be used as upper bound if the variable is upper bounded.
  • is_lower_unbounded (bool , optional) – Defaults to False. Set this flag to True to define a semi-bounded variable with lower bound -\infty; in this case, the lower_bound parameter is used only for generating an initial value.
  • is_upper_unbounded (bool , optional) – Defaults to False. Set this flag to True to define a semi-bounded variable with upper bound ++\infty; in this case, the upper_bound parameter is used only for generating an initial value.
  • initial_values (float or List [ float ] or None , optional) – Initial values for the optimization variable. 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 all either as a single value or a list of values of the same length. Defaults to None, meaning the optimizer initializes the variable with a random value.
  • name (str or None , optional) – The name of the node.

Returns

The vv optimizable scalar. If both is_lower_unbounded and is_upper_unbounded are False, the variables is bounded such that vminvvmaxv_\mathrm{min}\leq v \leq v_\mathrm{max}. If one of the flags is True (for example is_lower_unbounded=True), the variable is semi-bounded (for example vvmax-\infty \leq v \leq v_\mathrm{max}). If both of them are True, then the variable is unbounded and satisfies that v+-\infty \leq v \leq +\infty.

Return type

Tensor

SEE ALSO

Graph.optimization_variable : Create 1D Tensor of optimization variables.

boulderopal.run_optimization : Function to find the minimum of a generic function.

Was this useful?