sum_squares#
- VarDict1D.sum_squares()[source]#
Sum squares of all variables in an expression.
- Returns:
- xpress.expression
Examples
Create xpress problem:
>>> import xpress as xp >>> import warnings >>> warnings.filterwarnings('ignore', category=xp.LicenseWarning)
>>> prob = xp.problem()
Create index-set:
>>> nodes = IndexSet1D(['A', 'B', 'C'], name='node')
Add variables:
>>> from opti_extensions.xpress import addVariables >>> node_select = addVariables(prob, nodes, name='node-select', vartype=xp.binary)
Sum squares of all variables:
>>> node_select.sum_squares() node-select(A) ** 2 + node-select(B) ** 2 + node-select(C) ** 2