§
    TiN  ã                   óR   — d Z ddlZddlmZmZmZmZ ddlm	Z	m
Z
 d„ Zd„ Zd„ Zd	„ ZdS )
a  
This is a module evaluating the objective/constraint function with Nan/Inf handling.

Translated from Zaikun Zhang's modern-Fortran reference implementation in PRIMA.

Dedicated to late Professor M. J. D. Powell FRS (1936--2015).

Python translation by Nickolai Belakovski.
é    Né   )ÚFUNCMAXÚ	CONSTRMAXÚREALMAXÚ	DEBUGGING)ÚmatprodÚprimasumc                 óv   — d| t          j        | ¦  «        <   t          j        | t           t          ¦  «        } | S )zq
    This function moderates a decision variable. It replaces NaN by 0 and Inf/-Inf by
    REALMAX/-REALMAX.
    r   )ÚnpÚisnanÚclipr   )Úxs    úz/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/scipy/_lib/pyprima/common/evaluate.pyÚ	moderatexr      s/   € ð
 €A…b„hˆqk„kNÝ
Œ•G8WÑ%Ô%€AØ€Hó    c                 ó‚   — t          j        | ¦  «        rt          n| } t          j        | t           t          ¦  «        } | S )z‹
    This function moderates the function value of a MINIMIZATION problem. It replaces
    NaN and any value above FUNCMAX by FUNCMAX.
    )r   r   r   r   r   )Úfs    r   Ú	moderatefr      s6   € õ
 ”8˜A‘;”;Ð%ˆ A€AÝ
Œ•G8WÑ%Ô%€Að €Hr   c                 ó€   — t          j        | dt          ¬¦  «         t          j        | t           t          ¦  «        } | S )zß
    This function moderates the constraint value, the constraint demanding this value
    to be NONNEGATIVE. It replaces any value below -CONSTRMAX by -CONSTRMAX, and any
    NaN or value above CONSTRMAX by CONSTRMAX.
    F)ÚcopyÚnan)r   Ú
nan_to_numr   r   )Úcs    r   Ú	moderatecr   '   s5   € õ „M!˜%¥YÐ/Ñ/Ô/Ð/Ý
Œ•I:yÑ)Ô)€AØ€Hr   c                 óè  — |t          |¦  «        nd}t          r#t          t          j        |¦  «        ¦  «        rJ ‚t          j        ||z   ¦  «        }|t          ||j        ¦  «        |z
  |d|…<   t          t          j        |¦  «        ¦  «        r't          |¦  «        }t          j	        |¦  «        |z  }nK | t          |¦  «        ¦  «        \  }||d…<   t          |¦  «        }t          ||d…         ¦  «        ||d…<   t          rbt          j        |¦  «        st          j        |¦  «        rJ ‚t          t          j        |¦  «        t          j        |¦  «        z  ¦  «        rJ ‚||fS )z§
    This function evaluates CALCFC at X, returning the objective function value and the
    constraint value. Nan/Inf are handled by a moderated extreme barrier.
    Nr   )Úlenr   Úanyr   r   Úzerosr   ÚTr	   Úonesr   r   r   Úisposinf)Úcalcfcr   Úm_nlconÚamatÚbvecÚm_lconÚconstrr   s           r   Úevaluater(   2   se  € ð Ð*S‰YŒYˆY°€Fõ ð $õ •r”x ‘{”{Ñ#Ô#Ð#Ð#Ð#õ ŒXf˜wÑ&Ñ'Ô'€FØÐÝ! ! T¤VÑ,Ô,¨tÑ3ˆˆwˆw‰å
2Œ8A‰;Œ;ÑÔð 5õ Q‰KŒKˆÝ”˜Ñ!Ô! AÑ%ˆˆà#˜V¥I¨a¡L¤LÑ1Ô1Ñˆˆ6&''‰?õ
 a‰LŒLˆÝ# F¨6¨7¨7¤OÑ4Ô4ˆˆvˆwˆw‰õ ð ?õ ”H˜Q‘K”KÐ2¥2¤;¨q¡>¤>Ð2Ð2Ð2Ý•r”x Ñ'Ô'­"¬+°fÑ*=Ô*=Ñ=Ñ>Ô>Ð>Ð>Ð>àˆfˆ9Ðr   )Ú__doc__Únumpyr   Úconstsr   r   r   r   Úlinalgr   r	   r   r   r   r(   © r   r   ú<module>r.      sŸ   ððð ð Ð Ð Ð Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %ð
ð ð ð	ð 	ð 	ðð ð ð1ð 1ð 1ð 1ð 1r   