
    g                        d dl  d dl d dl d dl d dl d dl d dl d dl d dl d dl	 d dl
 d dl eeeeeeeeeeeeeeeeeeeee e!e"gZ#ddl$Z$ e       jK                         r e       Z&n< e       jK                         r e       Z&n e       jK                         r e       Z&ndZ&d Z'd Z(d Z)d Z*d Z+d
d	Z,y)   )*    Nc                      t               }|j                  t               | j                         D ]  \  }}|j	                  d||        t        t        d      }|j                  |       |j                          y)z
    set the data in the configuration file
    at the moment will only edit things in [locations]
    the keyword value pairs come from the keywords dictionary
    	locationswN)Parserreadconfig_filenameitemssetopenwriteclose)keywordsconfigkeyvalfps        O/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/pulp/apis/__init__.pysetConfigInformationr   5   sd     XF
KK NN$ *S

;S)* 
os	#B
LLHHJ    c                      t         ddft        ddfg} t        d       i }| D ]+  \  }}}t        |dz   t	        |      z   dz         }|s'|||<   - t        d	i | y)
z
    Configure the path the the solvers on the command line

    Designed to configure the file locations of the solvers from the
    command line after installation
    	cplexpathzCPLEX: 
coinmppathzCoinMP dll (windows only): zUPlease type the full path including filename and extension 
for each solver available[]N )cplex_dll_pathcoinMP_pathprintinputstrr   )
configlist
configdictdefaultr   msgvalues         r   configSolversr(   H   s     
i0	l$ABJ 
	& J' $ccCi#g,.45#JsO$ &:&r   c                     t         D ci c]  }|j                  | }}	  ||    |i |S c c}w # t        $ r* t        dj	                  | |j                                     w xY w)z
    Instantiates a solver from its name

    :param str solver: solver name to create
    :param args: additional arguments to the solver
    :param kwargs: additional keyword arguments to the solver
    :return: solver of type :py:class:`LpSolver`
    z?The solver {} does not exist in PuLP.
Possible options are: 
{})_all_solversnameKeyErrorPulpSolverErrorformatkeys)solverargskwargskmappings        r   	getSolverr5   _   sv     #//Qqvvqy/G/
wv/// 0  
OVV
 	

s   +
0 3A#c                 X    | j                  dd      }|t        d      t        |fi | S )aF  
    Instantiates a solver from a dictionary with its data

    :param dict data: a dictionary with, at least an "solver" key with the name
        of the solver to create
    :return: a solver of type :py:class:`LpSolver`
    :raises PulpSolverError: if the dictionary does not have the "solver" key
    :rtype: LpSolver
    r0   Nz&The json file has no solver attribute.)popr-   r5   )datar0   s     r   getSolverFromDictr9   s   s5     XXh%F~FGGV$t$$r   c                     t        |       5 }t        j                  |      }ddd       t        |      S # 1 sw Y   t              S xY w)z
    Instantiates a solver from a json file with its data

    :param str filename: name of the json file to read
    :return: a solver of type :py:class:`LpSolver`
    :rtype: LpSolver
    N)r   jsonloadr9   )filenamefr8   s      r   getSolverFromJsonr?      s@     
h 1yy|T""T""s	   5Ac                     g }t         D ]9  } |d      }| r|j                         r|j                  |j                         ~; |S )z
    List the names of all the existing solvers in PuLP

    :param bool onlyAvailable: if True, only show the available solvers
    :return: list of solver names
    :rtype: list
    F)r&   )r*   	availableappendr+   )onlyAvailableresultsr0   s       r   listSolversrF      sI     F u&"2"2"4MM&++&	
 Mr   )F)-coin_api	cplex_api
gurobi_apiglpk_api	choco_api	mipcl_api	mosek_apiscip_api
xpress_api	highs_apicopt_apicoreGLPK_CMDPYGLPK	CPLEX_CMDCPLEX_PYGUROBI
GUROBI_CMDMOSEKXPRESS
XPRESS_CMD	XPRESS_PYPULP_CBC_CMDCOIN_CMD
COINMP_DLL	CHOCO_CMD	MIPCL_CMDSCIP_CMD	FSCIP_CMDSCIP_PYHiGHS	HiGHS_CMDCOPTCOPT_DLLCOPT_CMDr*   r;   rA   LpSolverDefaultr   r(   r5   r9   r?   rF   r   r   r   <module>rk      s                

	
	/4  >"nOZjOZjOO&'.
(% 
#r   