+
    LV-jEI  ã                   óv   € R t ^ RIt^ RIHt ^ RIHt ^ RIt^ RIH	t	 R t
R tR tR tRR	 ltR
 tR tRR ltR# )zn
Routines for removing redundant (linearly dependent) equations from linear
programming equality constraints.
N)Úsvd)Úinterp_decomp©Údtrsmc                ó†   € Rp\         P                  ! \        V 4      V8„  P                  ^R7      4      P	                  4       # )a^  
Counts the number of nonzeros in each row of input array A.
Nonzeros are defined as any element with absolute value greater than
tol = 1e-13. This value should probably be an input to the function.

Parameters
----------
A : 2-D array
    An array representing a matrix

Returns
-------
rowcount : 1-D array
    Number of nonzeros in each row of A

g‚vIhÂ%<=©Úaxis)ÚnpÚarrayÚabsÚsumÚflatten)ÚAÚtols   & Úr/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/optimize/_remove_redundancy.pyÚ
_row_countr      s7   € ð" €CÜ�8Š8”S˜“V˜c‘\×&Ñ&¨AÐ&Ó.Ó/×7Ñ7Ó9Ð9ó    c                óP   € \        V 4      p\        P                  ! W!,          4      # )a‚  
Returns the index of the densest row of A. Ignores rows that are not
eligible for consideration.

Parameters
----------
A : 2-D array
    An array representing a matrix
eligibleRows : 1-D logical array
    Values indicate whether the corresponding row of A is eligible
    to be considered

Returns
-------
i_densest : int
    Index of the densest row in A eligible for consideration

)r   r	   Úargmax)r   ÚeligibleRowsÚ	rowCountss   && r   Ú_get_densestr   #   s   € ô& ˜1“€IÜ�9Š9�YÕ-Ó.Ð.r   c                óô   € ^ pRp\        V 4      ^ 8H  pV \        P                  ! V4      R3,          p \        P                  ! W,          ^ 4      '       g   ^pRpV\        P                  ! V4      ,          pWW#3# )aÖ  
 Eliminates trivial equations from system of equations defined by Ax = b
and identifies trivial infeasibilities

 Parameters
 ----------
 A : 2-D array
     An array representing the left-hand side of a system of equations
 b : 1-D array
     An array representing the right-hand side of a system of equations

 Returns
 -------
 A : 2-D array
     An array representing the left-hand side of a system of equations
 b : 1-D array
     An array representing the right-hand side of a system of equations
 status: int
     An integer indicating the status of the removal operation
     0: No infeasibility identified
     2: Trivially infeasible
 message : str
     A string descriptor of the exit status of the optimization.

 Ú ºNNNzbThere is a zero row in A_eq with a nonzero corresponding entry in b_eq. The problem is infeasible.)r   r	   Úlogical_notÚallclose)r   ÚbÚstatusÚmessageÚi_zeros   &&   r   Ú_remove_zero_rowsr!   :   sq   € ð4 €FØ€GÜ˜‹]˜aÑ€FØ	Œ"�.Š.˜Ó
  !Ð
#Õ$€AÜ�;Š;�q•y !×$Ò$Øˆð>ˆà	Œ"�.Š.˜Ó
 Õ!€AØ�Ð Ð r   c                 óæ   € V w  rEW!,          p\        ^WF^^R7      pVRV^,            VRV^,           1V3&   Ws^,           R pWCV3,          p	WC^,           R1V3;;,          W‰,          ,          uu&   WE3# )é   )ÚlowerÚdiagNr   )
ÚpluÚperm_rÚvÚjÚLUÚpÚvpermÚuÚlÚpivs
   &&&&      r   Úbg_update_denser0   `   sv   € Ø�E€Bà�I€EÜˆa� !¨!Ô,€AØ�D�Q�q•S�'€B€tˆˆ!�€tˆQ€w�KØ	ˆA�#ˆ$ˆ€AØ
�ˆT�(€CØˆ…s�tˆQ€w‡K�A•EÕƒKØˆ5€Lr   c           
     ó   € RpRp^ pRpRp\        W4      w  rrVV^ 8w  d   WWV3# V P                  w  r‰\        \        V4      4      p
\        V
4      p. pRpT p\        P
                  ! WˆV	,           3RR7      p \        P                  ! V ^4       WàRVR13&   \        P
                  ! V4      p\        P                  ! WˆV	,           \        R7      p\        P                  ! VP                  \        R7      p\        P                  ! VRR7      \        P                  ! V4      3pV^,          pV
 EFØ  p^VV&   V^ 8”  d   ^ VV^,
          &    VV^,
          ,          p\        VWÐRV3,          V^,
          4      p\        P                  P%                  VV^R	7      pVV,          p^2p\        ^ \'        V4      V4       F¥  pVV\)        VV,           \'        V4      4       p\+        V RV3,          P-                  4       P/                  V4      4      pVV8„  P1                  4       '       g   Kn  VV\        P2                  ! V4      ,           ,          pVVV&   R
VVV,
          &    EK4  	  VP4                  P/                  VP7                  R^4      4      p\        P                  P9                  V4      p \+        V4      ^V ,           ,          V8”  d   ^pTpWáWV3u # VP;                  V4       Vf   EKÀ  \'        V4      W‚,
          8X  g   EKÙ   M	  \=        \        V4      4      p!\        V!\=        V4      ,
          4      p!VV!R3,          VV!,          WV3#   \         dt    \        P                  P!                  T RT3,          4      pTw  pp\        \        T4      4      p\#        T4       F  w  ppTT,          TT,          uTT&   TT&   K!  	   ELTi ; i)aw  
Eliminates redundant equations from system of equations defined by Ax = b
and identifies infeasibilities.

Parameters
----------
A : 2-D array
    An matrix representing the left-hand side of a system of equations
rhs : 1-D array
    An array representing the right-hand side of a system of equations

Returns
-------
A : 2-D array
    A matrix representing the left-hand side of a system of equations
rhs : 1-D array
    An array representing the right-hand side of a system of equations
status: int
    An integer indicating the status of the system
    0: No infeasibility identified
    2: Trivially infeasible
message : str
    A string descriptor of the exit status of the optimization.

References
----------
.. [2] Andersen, Erling D. "Finding all linearly dependent rows in
       large-scale linear programming." Optimization Methods and Software
       6.3 (1995): 219-227.

ç:Œ0âŽyE>r   úæThere is a linear combination of rows of A_eq that results in zero, suggesting a redundant constraint. However the same linear combination of b_eq is nonzero, suggesting that the constraints conflict and the problem is infeasible.NÚF)Úorderr   )Údtype)ÚtransFéÿÿÿÿ)r!   ÚshapeÚlistÚranger	   ÚzerosÚfill_diagonalÚarangeÚintÚonesÚboolÚeyer0   Ú	ExceptionÚscipyÚlinalgÚ	lu_factorÚ	enumerateÚlu_solveÚlenÚminr   Ú	transposeÚdotÚanyr   ÚTÚreshapeÚnormÚappendÚset)"r   ÚrhsÚ	true_rankÚtolapivÚ	tolprimalr   r   ÚinconsistentÚmÚnr(   r   Údr'   ÚA_origÚeÚjs_candidatesÚjs_maskÚluÚir)   r*   r+   Úi1Úi2ÚpiÚjsÚbatchÚj_indexÚ	j_indicesÚcÚbibarÚbnormÚkeeps"   &&&                               r   Ú_remove_redundancy_pivot_denserl   l   sP  € ð@ €GØ€IØ€FØ€Gð5€Lô
 0°Ó7Ñ€AˆFà�„{Ø�vÐ&Ð&à�7‰7�D€AäŒU�1‹X‹€AÜˆQ‹€Að 	€AØ€Fà€FÜ
�Š�!˜•U� 3Ô'€AÜ×Ò�Q˜ÔØ€aˆ‰€e�HÜ
�Š�‹€Aä—I’I˜a 1¥¬CÔ0€Mä�gŠg�m×)Ñ)´Ô6€Gô 
�Š�˜Ô	œrŸyšy¨›|Ð	+€BØ��U€FÜˆàˆˆ!‰ØˆqŒ5ØˆAˆa��c‰Fð	@Ø�!�A•#•ˆAÜ   V¨q°!¨t­W°a¸µcÓ:ˆBô �\‰\×"Ñ" 2 q°Ð"Ó2ˆà˜7Õ#ˆØˆô ˜Q¤ B£¨Ö/ˆGØ˜7¤C¨°­´s¸2³wÓ$?Ð@ˆIä�A�a˜�l•O×-Ñ-Ó/×3Ñ3°BÓ7Ó8ˆAØ�G‘× Ñ ×"Ô"Ø�w¤§¢¨1£Õ-Õ.�Ø��!‘Ø$�˜˜!�‘Ûñ 0ð —D‘D—H‘H˜SŸ[™[¨¨QÓ/Ó0ˆEÜ—I‘I—N‘N 3Ó'ˆEÜ�5‹z˜1˜U�7Õ# iÔ/Ø�Ø&�Ø FÐ3Ò3à—‘˜”ØÕ(¬S°«V°qµ}×-DÙñU ôX Œu�Q‹x‹=€DÜ�”s˜1“v•Ó€DØ�$˜�'�?˜C �I vÐ6Ð6øôK ô 	@Ü—‘×'Ñ'¨¨!¨Q¨$­Ó0ˆBØ‰EˆB�Üœ% ›(“^ˆFÜ# Až,‘��BØ)/°­°V¸BµZÐ&��r‘
˜F 2›Jô 'ð		@ús   Å-MÍA:OÏOc                óF  € RpRp^ pRpRp\        W4      w  rrEV^ 8w  d   WWE3# V P                  w  rx\        \        V4      4      p	\        V	4      p
\	        \        WwV,           4      4      p. pT p\
        P                  P                  \
        P                  P                  V4      V 34      P                  4       p \        P                  ! V4      pV	 EF†  pV RV
3,          p^Wï&   V^ 8”  d   ^ Wï^,
          &   \
        P                  P                  P                  VP                  4       V4      P                  R^4      p\        V\	        V
4      ,
          4      p\        P                   ! V RV3,          P                  4       P#                  V4      4      V8„  P%                  4       ^ ,          p\'        V4      ^ 8”  d   VV^ ,          ,          pVW¯&   EK  VP(                  P#                  VP                  R^4      4      p\        P                  P+                  V4      p\!        V4      ^V,           ,          V8”  d   ^pTpWÑWE3u # VP-                  V4       EK‰  	  \	        \        V4      4      p\        V\	        V4      ,
          4      pVVR3,          VV,          WE3# )a…  
Eliminates redundant equations from system of equations defined by Ax = b
and identifies infeasibilities.

Parameters
----------
A : 2-D sparse array
    An matrix representing the left-hand side of a system of equations
rhs : 1-D array
    An array representing the right-hand side of a system of equations

Returns
-------
A : 2-D sparse array
    A matrix representing the left-hand side of a system of equations
rhs : 1-D array
    An array representing the right-hand side of a system of equations
status: int
    An integer indicating the status of the system
    0: No infeasibility identified
    2: Trivially infeasible
message : str
    A string descriptor of the exit status of the optimization.

References
----------
.. [2] Andersen, Erling D. "Finding all linearly dependent rows in
       large-scale linear programming." Optimization Methods and Software
       6.3 (1995): 219-227.

r2   r   r3   r   r8   )r!   r9   r:   r;   rR   rD   ÚsparseÚhstackÚ	eye_arrayÚtocscr	   r<   rE   ÚspsolverK   rO   r   rL   ÚnonzerorI   rN   rP   rQ   )r   rS   rU   rV   r   r   rW   rX   rY   r(   r   ÚkrZ   r[   r\   r`   ÚBrc   rd   rh   r)   ri   rj   rk   s   &&                      r   Ú_remove_redundancy_pivot_sparserv   ë   s2  € ðB €GØ€IØ€FØ€Gð5€Lô
 0°Ó7Ñ€AˆFà�„{Ø�vÐ&Ð&à�7‰7�D€AäŒU�1‹X‹€AÜˆQ‹€Aô 	ŒE�!�q•S‹MÓ€AØ
€Aà€FÜ�‰×ÑœUŸ\™\×3Ñ3°AÓ6¸Ð:Ó;×AÑAÓC€AÜ
�Š�‹€Aô, ˆØˆa�ˆd�Gˆàˆ‰ØˆqŒ5ØˆA��c‰Fä�\‰\× Ñ ×(Ñ(¨¯©«¸Ó:×BÑBÀ2ÀqÓIˆä�!”C˜“F•(‹^ˆô �VŠV�A�a˜�e•H×&Ñ&Ó(×,Ñ,¨RÓ0Ó1°GÑ;×DÑDÓFÀqÕIˆÜˆq‹6�AŒ:Ø�1�Q•4•ˆAð ˆAŒDà—D‘D—H‘H˜SŸ[™[¨¨QÓ/Ó0ˆEÜ—I‘I—N‘N 3Ó'ˆEÜ�5‹z˜1˜u�9Õ%¨	Ô1Ø�Ø&�Ø FÐ3Ò3à—‘˜—ñQ ôT Œu�Q‹x‹=€DÜ�”s˜1“v•Ó€DØ�$˜�'�?˜C �I vÐ6Ð6r   c                óè  € \        W4      w  rr#V^ 8w  d   WW#3# \        V 4      w  rEp\        P                  ! \        4      P
                  pVP                  4       \        V P                  4      ,          V,          pV P                  w  ršWš8:  d
   VR,          M^ p\        V4      V8  EdD   VR,          p\        P                  ! V4      VR,          8„  p\        P                  ! V4      '       dC   \        P                  ! \        P                  ! VP                  V 4      4      V8„  4      '       d   ^pRpM·\        P                  ! \        P                  ! VP                  V4      4      V^d,          8„  4      '       d   ^pRpMi\        W4      p\        P                  ! W^ R7      p \        P                  ! W4      p\        V 4      w  rEpV P                  w  ršWš8:  d
   VR,          M^ pEKT  WW#3# )ar  
Eliminates redundant equations from system of equations defined by Ax = b
and identifies infeasibilities.

Parameters
----------
A : 2-D array
    An array representing the left-hand side of a system of equations
b : 1-D array
    An array representing the right-hand side of a system of equations

Returns
-------
A : 2-D array
    An array representing the left-hand side of a system of equations
b : 1-D array
    An array representing the right-hand side of a system of equations
status: int
    An integer indicating the status of the system
    0: No infeasibility identified
    2: Trivially infeasible
message : str
    A string descriptor of the exit status of the optimization.

References
----------
.. [2] Andersen, Erling D. "Finding all linearly dependent rows in
       large-scale linear programming." Optimization Methods and Software
       6.3 (1995): 219-227.

g    ÐcAzþDue to numerical issues, redundant equality constraints could not be removed automatically. Try providing your constraint matrices as sparse matrices to activate sparse presolve, try turning off redundancy removal, or try turning off presolve altogether.r3   r   r8   )r   r8   )r!   r   r	   ÚfinfoÚfloatÚepsÚmaxr9   r   rM   rL   r   Údelete)r   r   r   r   ÚUÚsÚVhrz   r   rX   rY   Ús_minr(   r   Úi_removes   &&             r   Ú_remove_redundancy_svdr‚   j  s‚  € ôB .¨aÓ3Ñ€Aˆ&à�„{Ø�VÐ$Ð$ä�1‹v�H€Aˆ"Ü
�(Š(”5‹/×
Ñ
€CØ
�%‰%‹'”C˜Ÿ™“LÕ
  3Õ
&€Cà�7‰7�D€AØ”VˆAˆbŽE €Eô" ˆe‹*�sÕ
Øˆe�Hˆä—v’v˜a“y 3¨¥:Ñ-ˆÜ�vŠv�l×#Ò#¤r§v¢v¬b¯fªf°Q·U±U¸1³XÓ.>ÀÑ.D×'EÒ'EØˆFð%ˆGð Ü�6Š6”"—&’&˜Ÿ™˜q›Ó" S¨3¥YÑ.×/Ò/ØˆFð8ˆGð
 ä Ó0ˆÜ�IŠI�a¨Ô*ˆÜ�IŠI�aÓ"ˆÜ�q“6‰ˆˆbØ�w‰w‰ˆØœ��"– Q‹à�Ð Ð r   c                ó”  € ^ pRpRp\        W4      w  rrEV^ 8w  d   WWE3# V P                  w  rxTp	Vf    \        P                  P	                  V 4      p	\        V P                  W“R7      w  r«\        P                  ! WRV	 ,          V,          WV	R ,          4      '       g   ^pTp\        V
RV	 4      p
W
R3,          pW,          pWÍWE3# )ag  Eliminates redundant equations from a system of equations.

Eliminates redundant equations from system of equations defined by Ax = b
and identifies infeasibilities.

Parameters
----------
A : 2-D array
    An array representing the left-hand side of a system of equations
rhs : 1-D array
    An array representing the right-hand side of a system of equations
rank : int, optional
    The rank of A
randomized: bool, optional
    True for randomized interpolative decomposition

Returns
-------
A : 2-D array
    An array representing the left-hand side of a system of equations
rhs : 1-D array
    An array representing the right-hand side of a system of equations
status: int
    An integer indicating the status of the system
    0: No infeasibility identified
    2: Trivially infeasible
message : str
    A string descriptor of the exit status of the optimization.

r   r3   N)Úrandr   )	r!   r9   r	   rE   Úmatrix_rankr   rN   r   Úsorted)r   rS   ÚrankÚ
randomizedr   r   rW   rX   rY   rt   ÚidxÚprojÚA2Úrhs2s   &&&&          r   Ú_remove_redundancy_idr�   Æ  sÔ   € ð@ €FØ€Gð5€Lô 0°Ó7Ñ€AˆFà�„{Ø�vÐ&Ð&à�7‰7�D€Aà€AØ‚|Ü�I‰I×!Ñ! !Ó$ˆä˜aŸc™c 1Ô6�I€Cô �;Š;�s˜r ˜7•| dÕ*¨C°A°B°­L×9Ò9ØˆØˆô ��R�a�‹/€CØ	
�ˆ6�€BØ�8€DØ�VÐ$Ð$r   )N)NT)Ú__doc__Únumpyr	   Úscipy.linalgr   Úscipy.linalg.interpolativer   rD   Úscipy.linalg.blasr   r   r   r!   r0   rl   rv   r‚   r�   © r   r   Ú<module>r”      sK   ðñó Ý Ý 4Û Ý #ò:ò*/ò.#!òL	ô|7ò~|7ò~Y!öxD%r   