77
88import abc
99import warnings
10- from typing import Any , Dict , Optional , Tuple , Union , List
10+ from typing import Any , Dict , Optional , Tuple , Union , List , Sequence
1111
1212import cvxpy
1313import joblib
@@ -29,7 +29,7 @@ class StructuredSingularValue(metaclass=abc.ABCMeta):
2929 def compute_ssv (
3030 self ,
3131 N_omega : np .ndarray ,
32- block_structure : List [
32+ block_structure : Sequence [
3333 Union [RealDiagonalBlock , ComplexDiagonalBlock , ComplexFullBlock ]
3434 ],
3535 ) -> Tuple [np .ndarray , np .ndarray , Dict [str , Any ]]:
@@ -39,22 +39,15 @@ def compute_ssv(
3939 ----------
4040 N_omega : np.ndarray
4141 Closed-loop transfer function evaluated at each frequency.
42- block_structure : np.ndarray
43- 2D array with 2 columns and as many rows as uncertainty blocks
44- in Delta. The columns represent the number of rows and columns in
45- each uncertainty block. See [#mussv]_.
46-
42+ block_structure : Sequence[RealDiagonalBlock | ComplexDiagonalBlock | ComplexFullBlock]
43+ Sequence of uncertainty block objects.
4744 Returns
4845 -------
4946 Tuple[np.ndarray, np.ndarray, Dict[str, Any]]
5047 Structured singular value at each frequency, D-scales at each
5148 frequency, and solution information. If the structured singular
5249 value cannot be computed, the first two elements of the tuple are
5350 ``None``, but solution information is still returned.
54-
55- References
56- ----------
57- .. [#mussv] https://www.mathworks.com/help/robust/ref/mussv.html
5851 """
5952 raise NotImplementedError ()
6053
@@ -146,7 +139,7 @@ def __init__(
146139 def compute_ssv (
147140 self ,
148141 N_omega : np .ndarray ,
149- block_structure : List [
142+ block_structure : Sequence [
150143 Union [RealDiagonalBlock , ComplexDiagonalBlock , ComplexFullBlock ]
151144 ],
152145 ) -> Tuple [np .ndarray , np .ndarray , Dict [str , Any ]]:
@@ -329,35 +322,32 @@ def _ssv_at_omega(
329322
330323
331324def _variable_from_block_structure (
332- block_structure : List [
325+ block_structure : Sequence [
333326 Union [RealDiagonalBlock , ComplexDiagonalBlock , ComplexFullBlock ]
334327 ],
335328) -> cvxpy .Variable :
336329 """Get optimization variable with specified block structure.
337330
338331 Parameters
339332 ----------
340- block_structure : np.ndarray
341- 2D array with 2 columns and as many rows as uncertainty blocks
342- in Delta. The columns represent the number of rows and columns in
343- each uncertainty block. See [#mussv]_.
333+ block_structure : Sequence[RealDiagonalBlock | ComplexDiagonalBlock | ComplexFullBlock]
334+ Sequence of uncertainty block objects.
344335
345336 Returns
346337 -------
347338 cvxpy.Variable
348339 CVXPY variable with specified block structure.
349-
350- References
351- ----------
352- .. [#mussv] https://www.mathworks.com/help/robust/ref/mussv.html
353340 """
354341 num_blocks = len (block_structure )
355342 X_lst = []
356343 for i in range (num_blocks ):
357344 row = []
358345 for j in range (num_blocks ):
346+ # Uncertainty blocks
359347 block_i = block_structure [i ]
360348 block_j = block_structure [j ]
349+ # Square uncertainty block condition
350+ is_block_square = block_i .num_inputs == block_i .num_outputs
361351 if i == j :
362352 # If on the block diagonal, insert variable
363353 if isinstance (block_i , RealDiagonalBlock ):
@@ -368,7 +358,7 @@ def _variable_from_block_structure(
368358 raise NotImplementedError (
369359 "Complex diagonal perturbations are not yet supported."
370360 )
371- if isinstance (block_i , ComplexFullBlock ) and (not block_i . is_square ):
361+ if isinstance (block_i , ComplexFullBlock ) and (not is_block_square ):
372362 raise NotImplementedError (
373363 "Nonsquare perturbations are not yet supported."
374364 )
0 commit comments