ó
Ê½÷Xc           @` sí   d  Z  d d l m Z m Z m Z d d l Z d d l m Z m	 Z	 d d d g Z
 d	 Z d
 „  Z d „  Z d e d „ Z d d „ Z d d e d d e d „ Z e e e e e d e e d e d „
 Z e e e e e d e e d „ Z d S(   s"  
A top-level linear programming interface. Currently this interface only
solves linear programming problems via the Simplex Method.

.. versionadded:: 0.15.0

Functions
---------
.. autosummary::
   :toctree: generated/

    linprog
    linprog_verbose_callback
    linprog_terse_callback

i    (   t   divisiont   print_functiont   absolute_importNi   (   t   OptimizeResultt   _check_unknown_optionst   linprogt   linprog_verbose_callbackt   linprog_terse_callbacks   restructuredtext enc   
      K` s‚  | d } | d } | d \ } } | d } | d } | d } t  j ƒ  }	 t  j d d d	 i d
 „  d 6ƒ | r” t d j | ƒ ƒ t d ƒ nB | d k r¶ t d j | ƒ ƒ n  t d j | | ƒ ƒ t d ƒ | d k rqt d t | ƒ d ƒ | st d j | | ƒ ƒ n  t d | ƒ t ƒ  t d ƒ t d |  ƒ t ƒ  t d ƒ t d | d ƒ t ƒ  n  t  j |	   d S(   s]  
    A sample callback function demonstrating the linprog callback interface.
    This callback produces detailed output to sys.stdout before each iteration
    and after the final iteration of the simplex algorithm.

    Parameters
    ----------
    xk : array_like
        The current solution vector.
    **kwargs : dict
        A dictionary containing the following parameters:

        tableau : array_like
            The current tableau of the simplex algorithm.
            Its structure is defined in _solve_simplex.
        phase : int
            The current Phase of the simplex algorithm (1 or 2)
        nit : int
            The current iteration number.
        pivot : tuple(int, int)
            The index of the tableau selected as the next pivot,
            or nan if no pivot exists
        basis : array(int)
            A list of the current basic variables.
            Each element contains the name of a basic variable and its value.
        complete : bool
            True if the simplex algorithm has completed
            (and this is the final call to callback), otherwise False.
    t   tableaut   nitt   pivott   phaset   basist   completet	   linewidthiô  t	   formatterc         S` s   d j  |  ƒ S(   Ns
   {0: 12.4f}(   t   format(   t   x(    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyt   <lambda>C   s    t   floats3   --------- Iteration Complete - Phase {0:d} -------
s   Tableau:i    s3   --------- Initial Tableau - Phase {0:d} ----------
s2   --------- Iteration {0:d}  - Phase {1:d} --------
t    s   
s#   Pivot Element: T[{0:.0f}, {1:.0f}]
s   Basic Variables:s   Current Solution:s   x = s   Current Objective Value:s   f = iÿÿÿÿN(   iÿÿÿÿiÿÿÿÿ(   t   npt   get_printoptionst   set_printoptionst   printR   t   str(
   t   xkt   kwargsR   R	   t   pivrowt   pivcolR   R   R   t   saved_printoptions(    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyR      s:    








c         K` sJ   | d } | d k r# t  d ƒ n  t  d j | ƒ d d ƒt  |  ƒ d S(   sz  
    A sample callback function demonstrating the linprog callback interface.
    This callback produces brief output to sys.stdout before each iteration
    and after the final iteration of the simplex algorithm.

    Parameters
    ----------
    xk : array_like
        The current solution vector.
    **kwargs : dict
        A dictionary containing the following parameters:

        tableau : array_like
            The current tableau of the simplex algorithm.
            Its structure is defined in _solve_simplex.
        vars : tuple(str, ...)
            Column headers for each column in tableau.
            "x[i]" for actual variables, "s[i]" for slack surplus variables,
            "a[i]" for artificial variables, and "RHS" for the constraint
            RHS vector.
        phase : int
            The current Phase of the simplex algorithm (1 or 2)
        nit : int
            The current iteration number.
        pivot : tuple(int, int)
            The index of the tableau selected as the next pivot,
            or nan if no pivot exists
        basics : list[tuple(int, float)]
            A list of the current basic variables.
            Each element contains the index of a basic variable and
            its value.
        complete : bool
            True if the simplex algorithm has completed
            (and this is the final call to callback), otherwise False.
    R	   i    s
   Iter:   X:s   {0: <5d}   t   endR   N(   R   R   (   R   R   R	   (    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyR   ]   s
    $
gê-™—q=c         C` sµ   t  j j |  d d d … f | k |  d d d … f d t ƒ} | j ƒ  d k ra t t  j f S| r‹ t t  j | j t k ƒ d d f St t  j j | | j	 ƒ  k ƒ d d f S(   s´  
    Given a linear programming simplex tableau, determine the column
    of the variable to enter the basis.

    Parameters
    ----------
    T : 2D ndarray
        The simplex tableau.
    tol : float
        Elements in the objective row larger than -tol will not be considered
        for pivoting.  Nominally this value is zero, but numerical issues
        cause a tolerance about zero to be necessary.
    bland : bool
        If True, use Bland's rule for selection of the column (select the
        first column with a negative coefficient in the objective row,
        regardless of magnitude).

    Returns
    -------
    status: bool
        True if a suitable pivot column was found, otherwise False.
        A return of False indicates that the linear programming simplex
        algorithm is complete.
    col: int
        The index of the column of the pivot element.
        If status is False, col will be returned as nan.
    iÿÿÿÿNt   copyi    (
   R   t   mat   masked_wheret   Falset   countt   nant   Truet   wheret   maskt   min(   t   Tt   tolt   blandR!   (    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyt
   _pivot_col‰   s    B$c         C` sô   | d k r d } n d } t  j j |  d | … | f | k |  d | … | f d t ƒ} | j ƒ  d k r} t t  j f St  j j |  d | … | f | k |  d | … d f d t ƒ} | | } t t  j j | | j ƒ  k ƒ d d f S(   sI  
    Given a linear programming simplex tableau, determine the row for the
    pivot operation.

    Parameters
    ----------
    T : 2D ndarray
        The simplex tableau.
    pivcol : int
        The index of the pivot column.
    phase : int
        The phase of the simplex algorithm (1 or 2).
    tol : float
        Elements in the pivot column smaller than tol will not be considered
        for pivoting.  Nominally this value is zero, but numerical issues
        cause a tolerance about zero to be necessary.

    Returns
    -------
    status: bool
        True if a suitable pivot row was found, otherwise False.  A return
        of False indicates that the linear programming problem is unbounded.
    row: int
        The index of the row of the pivot element.  If status is False, row
        will be returned as nan.
    i   i   NR    i    iÿÿÿÿ(	   R   R!   R"   R#   R$   R%   R&   R'   R)   (   R*   R   R   R+   t   kR!   t   mbt   q(    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyt
   _pivot_row­   s    	CC
iè  i   c	         C` s1  | }	 t  }
 | d k r, |  j d d } n, | d k rL |  j d d } n t d ƒ ‚ | d k rÏxhg  t | j ƒ D]' } | | |  j d d k rw | ^ qw D]&} g  t |  j d d ƒ D]" } |  | | f d k rÀ | ^ qÀ } t | ƒ d k r¢ | d } | | | <|  | | } |  | d d … f | |  | d d … f <xr t |  j d ƒ D]] } | | k rZ|  | d d … f |  | d d … f |  | | f |  | d d … f <qZqZW|	 d 7}	 q¢ q¢ Wn  t | |  ƒ d k rt j |  j d d d t j ƒ} n: t j t	 |  j d d t	 | |  ƒ d ƒ d t j ƒ} xß|
 s&t
 |  | | ƒ \ } } | st j } t j } d } t }
 n0 t |  | | | ƒ \ } } | s½d } t }
 n  | d k	 r>d | (|  d | … d f | | |  <| | |  i |  d	 6| d
 6|	 d 6| | f d 6| d 6|
 o3| d k d 6 n  |
 sH|	 | k r_d } t }
 q#| | | <|  | | } |  | d d … f | |  | d d … f <xr t |  j d ƒ D]] } | | k rµ|  | d d … f |  | d d … f |  | | f |  | d d … f <qµqµW|	 d 7}	 qHqHW|	 | f S(   s8  
    Solve a linear programming problem in "standard maximization form" using
    the Simplex Method.

    Minimize :math:`f = c^T x`

    subject to

    .. math::

        Ax = b
        x_i >= 0
        b_j >= 0

    Parameters
    ----------
    T : array_like
        A 2-D array representing the simplex T corresponding to the
        maximization problem.  It should have the form:

        [[A[0, 0], A[0, 1], ..., A[0, n_total], b[0]],
         [A[1, 0], A[1, 1], ..., A[1, n_total], b[1]],
         .
         .
         .
         [A[m, 0], A[m, 1], ..., A[m, n_total], b[m]],
         [c[0],   c[1], ...,   c[n_total],    0]]

        for a Phase 2 problem, or the form:

        [[A[0, 0], A[0, 1], ..., A[0, n_total], b[0]],
         [A[1, 0], A[1, 1], ..., A[1, n_total], b[1]],
         .
         .
         .
         [A[m, 0], A[m, 1], ..., A[m, n_total], b[m]],
         [c[0],   c[1], ...,   c[n_total],   0],
         [c'[0],  c'[1], ...,  c'[n_total],  0]]

         for a Phase 1 problem (a Problem in which a basic feasible solution is
         sought prior to maximizing the actual objective.  T is modified in
         place by _solve_simplex.
    n : int
        The number of true variables in the problem.
    basis : array
        An array of the indices of the basic variables, such that basis[i]
        contains the column corresponding to the basic variable for row i.
        Basis is modified in place by _solve_simplex
    maxiter : int
        The maximum number of iterations to perform before aborting the
        optimization.
    phase : int
        The phase of the optimization being executed.  In phase 1 a basic
        feasible solution is sought and the T has an additional row representing
        an alternate objective function.
    callback : callable, optional
        If a callback function is provided, it will be called within each
        iteration of the simplex algorithm. The callback must have the
        signature `callback(xk, **kwargs)` where xk is the current solution
        vector and kwargs is a dictionary containing the following::
        "T" : The current Simplex algorithm T
        "nit" : The current iteration.
        "pivot" : The pivot (row, column) used for the next iteration.
        "phase" : Whether the algorithm is in Phase 1 or Phase 2.
        "basis" : The indices of the columns of the basic variables.
    tol : float
        The tolerance which determines when a solution is "close enough" to
        zero in Phase 1 to be considered a basic feasible solution or close
        enough to positive to to serve as an optimal solution.
    nit0 : int
        The initial iteration number used to keep an accurate iteration total
        in a two-phase problem.
    bland : bool
        If True, choose pivots using Bland's rule [3].  In problems which
        fail to converge due to cycling, using Bland's rule can provide
        convergence at the expense of a less optimal path about the simplex.

    Returns
    -------
    res : OptimizeResult
        The optimization result represented as a ``OptimizeResult`` object.
        Important attributes are: ``x`` the solution array, ``success`` a
        Boolean flag indicating if the optimizer exited successfully and
        ``message`` which describes the cause of the termination. Possible
        values for the ``status`` attribute are:
         0 : Optimization terminated successfully
         1 : Iteration limit reached
         2 : Problem appears to be infeasible
         3 : Problem appears to be unbounded

        See `OptimizeResult` for a description of other attributes.
    i   i    i   s1   Argument 'phase' to _solve_simplex must be 1 or 2Nt   dtypei   iÿÿÿÿR   R   R	   R
   R   R   (   R#   t   shapet
   ValueErrort   ranget   sizet   lenR   t   zerost   float64t   maxR-   R%   R&   R1   t   None(   R*   t   nR   t   maxiterR   t   callbackR+   t   nit0R,   R	   R   t   mt   rowR   t   colt   non_zero_rowR   t   pivvalt   irowt   solutiont   pivcol_foundt   statust   pivrow_found(    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyt   _solve_simplexÔ   sr    ^	+"

*O&.						
*Oc   2      K` s…  t  | ƒ d } i d d 6d d 6d d 6d d 6d	 d
 6} t } t j |  ƒ } d } t |  ƒ } | d k	 r{ t j | ƒ n t j d t | ƒ g ƒ } | d k	 r± t j | ƒ n t j d t | ƒ g ƒ } | d k	 rð t j t j | ƒ ƒ n t j d g ƒ } | d k	 r&t j t j | ƒ ƒ n t j d g ƒ } t j | d t j	 ƒ} t j
 | d t j	 ƒt j } | d k st | ƒ d k rn‹t | ƒ d k r>t | d d ƒ r>| d d k	 rÐ| d n t j } | d d k	 rô| d n t j } t j | | g d t j	 ƒ} t j | | g d t j	 ƒ} nÝ t | ƒ | k r_d } d } n¼ yœ x• t | ƒ D]‡ } t | | ƒ d k r—t ƒ  ‚ n  | | d d k	 r¹| | d n t j | | <| | d d k	 ré| | d n t j | | <qoWWn t k
 rd } d } n Xt j | t j k ƒ r| d } t j t j d g ƒ | g ƒ } t j t j t j g ƒ | g ƒ } t j t j d g ƒ | g ƒ } t j t j | j d d g ƒ | g ƒ } t j t j | j d d g ƒ | g ƒ } t } n  xŸt | ƒ D]‘} | | | | k rCd } d | | f } n  t j | | ƒ ru| | d k rud } d } n  t j | | ƒ r§| | d k  r§d } d } n  t j | | ƒ r+| | d k r+t j | t j | ƒ g ƒ } d | d | f <t j | t j | | g ƒ g ƒ } d | | <n  t j | | ƒ rt j | t j | ƒ g ƒ } d | d | f <t j | t j | | g ƒ g ƒ } t j | | <qqWxit d | ƒ D]X} | | d k  rØt j | | ƒ rK| | d k  rK| | d d … | f | | } | | d d … | f | | } | | | | | } qØ| d d … d f | d d … | f | d d … d f <| d d … d f | d d … | f | d d … d f <| d | | | d <n  t j | | ƒ rµ| | d k  rd } d } qqµqµWt | ƒ } t | ƒ } | | } | } | t j | d k  ƒ }  y | j \ }! }" Wn t k
 r„t d ƒ ‚ n Xy | j \ }# }$ Wn t k
 r·t d ƒ ‚ n X|# | k rÓd } d } n  |! | k rîd } d } n  |$ d k r|$ | k rd } d } n  |" d k r<|" | k r<d } d } n  | d k rWt | ƒ ‚ n  t j | d | | |  d g ƒ }% | |% d d | … f <| |% d. <|% d d … d f } | d k rç| |% d | … d | … f <| | | *n  | d k rQ	| |% | | | … d | … f <| | | | | +t j |% | | … | | | … f d ƒ n  d }& d }' t j | d t ƒ}( t j |  d t ƒ}) xØ t | ƒ D]Ê } | | k  s¶	| | d k  rF
| | |' |( | <| |) |' <|' d 7}' | | d k  r
| | c d 9<|% | d d … f c d 9<n  d |% | |( | f <d |% d |( | f <q”	| |& |( | <|& d 7}& q”	WxH |) D]@ }* |% d d d … f |% |* d d … f |% d d d … f <qi
Wt |% | |( d d d | d | d |	 d  |
 ƒ\ }+ } t |% d/ ƒ |	 k  rC|% d d … d d … f }% t j |% t j | | | | |  !d ƒ }% n d } | d k r¥| | } | rrt  | ƒ n  t! d! t j" d" |% d0 d# |+ d$ | d% | d& t ƒ St |% | |( d | |+ d d d | d |	 d' |+ d  |
 ƒ\ }, } t j | | |  ƒ }- |% d | … d f |- |( |  <|- |  }. |- | | | !}/ t j# j | d( t j | ƒ d) d* ƒj$ ƒ  }0 |. |0 }. | rÃxA t d | ƒ D]0 } t j | | ƒ r‚|. | c |. d 8<q‚q‚W|. d }. n  |% d1 }1 | d2 k r| rDt  | | ƒ t  d+ j% |1 ƒ ƒ t  d, j% |, ƒ ƒ qDn* | rDt  | | ƒ t  d, j% |, ƒ ƒ n  t! d! |. d" |1 d# t |, ƒ d$ | d- |/ d% | | d& | d k ƒ S(3   s€  
    Solve the following linear programming problem via a two-phase
    simplex algorithm.

    minimize:     c^T * x

    subject to:   A_ub * x <= b_ub
                  A_eq * x == b_eq

    Parameters
    ----------
    c : array_like
        Coefficients of the linear objective function to be minimized.
    A_ub : array_like
        2-D array which, when matrix-multiplied by x, gives the values of the
        upper-bound inequality constraints at x.
    b_ub : array_like
        1-D array of values representing the upper-bound of each inequality
        constraint (row) in A_ub.
    A_eq : array_like
        2-D array which, when matrix-multiplied by x, gives the values of the
        equality constraints at x.
    b_eq : array_like
        1-D array of values representing the RHS of each equality constraint
        (row) in A_eq.
    bounds : array_like
        The bounds for each independent variable in the solution, which can take
        one of three forms::
        None : The default bounds, all variables are non-negative.
        (lb, ub) : If a 2-element sequence is provided, the same
                  lower bound (lb) and upper bound (ub) will be applied
                  to all variables.
        [(lb_0, ub_0), (lb_1, ub_1), ...] : If an n x 2 sequence is provided,
                  each variable x_i will be bounded by lb[i] and ub[i].
        Infinite bounds are specified using -np.inf (negative)
        or np.inf (positive).
    callback : callable
        If a callback function is provide, it will be called within each
        iteration of the simplex algorithm. The callback must have the
        signature `callback(xk, **kwargs)` where xk is the current solution
        vector and kwargs is a dictionary containing the following::
        "tableau" : The current Simplex algorithm tableau
        "nit" : The current iteration.
        "pivot" : The pivot (row, column) used for the next iteration.
        "phase" : Whether the algorithm is in Phase 1 or Phase 2.
        "bv" : A structured array containing a string representation of each
               basic variable and its current value.

    Options
    -------
    maxiter : int
       The maximum number of iterations to perform.
    disp : bool
        If True, print exit status message to sys.stdout
    tol : float
        The tolerance which determines when a solution is "close enough" to zero
        in Phase 1 to be considered a basic feasible solution or close enough
        to positive to to serve as an optimal solution.
    bland : bool
        If True, use Bland's anti-cycling rule [3] to choose pivots to
        prevent cycling.  If False, choose pivots which should lead to a
        converged solution more quickly.  The latter method is subject to
        cycling (non-convergence) in rare instances.

    Returns
    -------
    A scipy.optimize.OptimizeResult consisting of the following fields::
        x : ndarray
            The independent variable vector which optimizes the linear
            programming problem.
        fun : float
            Value of the objective function.
        slack : ndarray
            The values of the slack variables.  Each slack variable corresponds
            to an inequality constraint.  If the slack is zero, then the
            corresponding constraint is active.
        success : bool
            Returns True if the algorithm succeeded in finding an optimal
            solution.
        status : int
            An integer representing the exit status of the optimization::
             0 : Optimization terminated successfully
             1 : Iteration limit reached
             2 : Problem appears to be infeasible
             3 : Problem appears to be unbounded
        nit : int
            The number of iterations performed.
        message : str
            A string descriptor of the exit status of the optimization.

    Examples
    --------
    Consider the following problem:

    Minimize: f = -1*x[0] + 4*x[1]

    Subject to: -3*x[0] + 1*x[1] <= 6
                 1*x[0] + 2*x[1] <= 4
                            x[1] >= -3

    where:  -inf <= x[0] <= inf

    This problem deviates from the standard linear programming problem.  In
    standard form, linear programming problems assume the variables x are
    non-negative.  Since the variables don't have standard bounds where
    0 <= x <= inf, the bounds of the variables must be explicitly set.

    There are two upper-bound constraints, which can be expressed as

    dot(A_ub, x) <= b_ub

    The input for this problem is as follows:

    >>> from scipy.optimize import linprog
    >>> c = [-1, 4]
    >>> A = [[-3, 1], [1, 2]]
    >>> b = [6, 4]
    >>> x0_bnds = (None, None)
    >>> x1_bnds = (-3, None)
    >>> res = linprog(c, A, b, bounds=(x0_bnds, x1_bnds))
    >>> print(res)
         fun: -22.0
     message: 'Optimization terminated successfully.'
         nit: 1
       slack: array([ 39.,   0.])
      status: 0
     success: True
           x: array([ 10.,  -3.])

    References
    ----------
    .. [1] Dantzig, George B., Linear programming and extensions. Rand
           Corporation Research Study Princeton Univ. Press, Princeton, NJ, 1963
    .. [2] Hillier, S.H. and Lieberman, G.J. (1995), "Introduction to
           Mathematical Programming", McGraw-Hill, Chapter 4.
    .. [3] Bland, Robert G. New finite pivoting rules for the simplex method.
           Mathematics of Operations Research (2), 1977: pp. 103-107.
    i    s%   Optimization terminated successfully.s   Iteration limit reached.i   s>   Optimization failed. Unable to find a feasible starting point.i   s9   Optimization failed. The problem appears to be unbounded.i   s1   Optimization failed. Singular matrix encountered.i   R2   t   __len__iÿÿÿÿsi   Invalid input for linprog with method = 'simplex'.  Length of bounds is inconsistent with the length of csk   Invalid input for linprog with method = 'simplex'.  bounds must be a n x 2 sequence/array where n = len(c).sa   Invalid input for linprog with method = 'simplex'.  Lower bound %d is greater than upper bound %dsT   Invalid input for linprog with method = 'simplex'.  Lower bound may not be +infinitysT   Invalid input for linprog with method = 'simplex'.  Upper bound may not be -infinityNsP   Invalid input for linprog with method = 'simplex'.  Upper bound may not be -inf.s,   Invalid input.  A_ub must be two-dimensionals,   Invalid input.  A_eq must be two-dimensionals|   Invalid input for linprog with method = 'simplex'.  The number of rows in A_eq must be equal to the number of values in b_eqs|   Invalid input for linprog with method = 'simplex'.  The number of rows in A_ub must be equal to the number of values in b_ubsl   Invalid input for linprog with method = 'simplex'.  Number of columns in A_eq must be equal to the size of csl   Invalid input for linprog with method = 'simplex'.  Number of columns in A_ub must be equal to the size of ciþÿÿÿR   R>   R=   R+   R,   R   t   funR	   RH   t   messaget   successR?   R(   t
   fill_valueg        s,            Current function value: {0: <12.6f}s            Iterations: {0:d}t   slack(   iþÿÿÿiÿÿÿÿ(   iÿÿÿÿiÿÿÿÿ(   iÿÿÿÿiÿÿÿÿ(   iÿÿÿÿiÿÿÿÿ(   i    i   (&   R   R#   R   t   asarrayR7   R;   t   emptyt   ravelR8   R9   t   onest   inft   hasattrR5   t
   IndexErrort   anyt   concatenatet   arrayt   hstackR3   R&   t   isinft   isfinitet   vstackt   count_nonzeroR4   t   fill_diagonalt   intRJ   t   abst   deletet   s_R   R   R%   R!   t   filledR   (2   t   ct   A_ubt   b_ubt   A_eqt   b_eqt   boundsR=   t   dispR>   R+   R,   t   unknown_optionsRH   t   messagest   have_floor_variablet   cct   f0R<   t   Aeqt   Aubt   beqt   bubt   Lt   Ut   at   bRM   t   it   mubt   meqR@   t   n_slackt   n_artificialt   Aub_rowst   Aub_colst   Aeq_rowst   Aeq_colsR*   t   slcountt   avcountR   t   r_artificialt   rt   nit1t   nit2RF   R   RP   t   masked_Lt   obj(    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyt   _linprog_simplex‡  sV   


6666&$#"	07

!$!++	#	#	#&%#""::
				%
 -

>.
&
-
*t   simplexc	   
      C` sr   | j  ƒ  }	 | d	 k r! i  } n  |	 d k r^ t |  d | d | d | d | d | d | | St d | ƒ ‚ d	 S(
   sš  
    Minimize a linear objective function subject to linear
    equality and inequality constraints.

    Linear Programming is intended to solve the following problem form:

    Minimize:     c^T * x

    Subject to:   A_ub * x <= b_ub
                  A_eq * x == b_eq

    Parameters
    ----------
    c : array_like
        Coefficients of the linear objective function to be minimized.
    A_ub : array_like, optional
        2-D array which, when matrix-multiplied by x, gives the values of the
        upper-bound inequality constraints at x.
    b_ub : array_like, optional
        1-D array of values representing the upper-bound of each inequality
        constraint (row) in A_ub.
    A_eq : array_like, optional
        2-D array which, when matrix-multiplied by x, gives the values of the
        equality constraints at x.
    b_eq : array_like, optional
        1-D array of values representing the RHS of each equality constraint
        (row) in A_eq.
    bounds : sequence, optional
        ``(min, max)`` pairs for each element in ``x``, defining
        the bounds on that parameter. Use None for one of ``min`` or
        ``max`` when there is no bound in that direction. By default
        bounds are ``(0, None)`` (non-negative)
        If a sequence containing a single tuple is provided, then ``min`` and
        ``max`` will be applied to all variables in the problem.
    method : str, optional
        Type of solver.  At this time only 'simplex' is supported
        :ref:`(see here) <optimize.linprog-simplex>`.
    callback : callable, optional
        If a callback function is provide, it will be called within each
        iteration of the simplex algorithm. The callback must have the signature
        `callback(xk, **kwargs)` where xk is the current solution vector
        and kwargs is a dictionary containing the following::

            "tableau" : The current Simplex algorithm tableau
            "nit" : The current iteration.
            "pivot" : The pivot (row, column) used for the next iteration.
            "phase" : Whether the algorithm is in Phase 1 or Phase 2.
            "basis" : The indices of the columns of the basic variables.

    options : dict, optional
        A dictionary of solver options. All methods accept the following
        generic options:

            maxiter : int
                Maximum number of iterations to perform.
            disp : bool
                Set to True to print convergence messages.

        For method-specific options, see `show_options('linprog')`.

    Returns
    -------
    A `scipy.optimize.OptimizeResult` consisting of the following fields:

        x : ndarray
            The independent variable vector which optimizes the linear
            programming problem.
        fun : float
            Value of the objective function.
        slack : ndarray
            The values of the slack variables.  Each slack variable corresponds
            to an inequality constraint.  If the slack is zero, then the
            corresponding constraint is active.
        success : bool
            Returns True if the algorithm succeeded in finding an optimal
            solution.
        status : int
            An integer representing the exit status of the optimization::

                 0 : Optimization terminated successfully
                 1 : Iteration limit reached
                 2 : Problem appears to be infeasible
                 3 : Problem appears to be unbounded

        nit : int
            The number of iterations performed.
        message : str
            A string descriptor of the exit status of the optimization.

    See Also
    --------
    show_options : Additional options accepted by the solvers

    Notes
    -----
    This section describes the available solvers that can be selected by the
    'method' parameter. The default method is :ref:`Simplex <optimize.linprog-simplex>`.

    Method *Simplex* uses the Simplex algorithm (as it relates to Linear
    Programming, NOT the Nelder-Mead Simplex) [1]_, [2]_. This algorithm
    should be reasonably reliable and fast.

    .. versionadded:: 0.15.0

    References
    ----------
    .. [1] Dantzig, George B., Linear programming and extensions. Rand
           Corporation Research Study Princeton Univ. Press, Princeton, NJ, 1963
    .. [2] Hillier, S.H. and Lieberman, G.J. (1995), "Introduction to
           Mathematical Programming", McGraw-Hill, Chapter 4.
    .. [3] Bland, Robert G. New finite pivoting rules for the simplex method.
           Mathematics of Operations Research (2), 1977: pp. 103-107.

    Examples
    --------
    Consider the following problem:

    Minimize: f = -1*x[0] + 4*x[1]

    Subject to: -3*x[0] + 1*x[1] <= 6
                 1*x[0] + 2*x[1] <= 4
                            x[1] >= -3

    where:  -inf <= x[0] <= inf

    This problem deviates from the standard linear programming problem.
    In standard form, linear programming problems assume the variables x are
    non-negative.  Since the variables don't have standard bounds where
    0 <= x <= inf, the bounds of the variables must be explicitly set.

    There are two upper-bound constraints, which can be expressed as

    dot(A_ub, x) <= b_ub

    The input for this problem is as follows:

    >>> c = [-1, 4]
    >>> A = [[-3, 1], [1, 2]]
    >>> b = [6, 4]
    >>> x0_bounds = (None, None)
    >>> x1_bounds = (-3, None)
    >>> from scipy.optimize import linprog
    >>> res = linprog(c, A_ub=A, b_ub=b, bounds=(x0_bounds, x1_bounds),
    ...               options={"disp": True})
    Optimization terminated successfully.
         Current function value: -22.000000
         Iterations: 1
    >>> print(res)
         fun: -22.0
     message: 'Optimization terminated successfully.'
         nit: 1
       slack: array([ 39.,   0.])
      status: 0
     success: True
           x: array([ 10.,  -3.])

    Note the actual objective value is 11.428571.  In this case we minimized
    the negative of the objective function.

    RŒ   Rg   Rh   Ri   Rj   Rk   R>   s   Unknown solver %sN(   t   lowerR;   R‹   R4   (
   Rf   Rg   Rh   Ri   Rj   Rk   t   methodR>   t   optionst   meth(    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyR   8  s    £	!(   t   __doc__t
   __future__R    R   R   t   numpyR   t   optimizeR   R   t   __all__t   __docformat__R   R   R#   R-   R1   R;   RJ   R‹   R   (    (    (    s6   /tmp/pip-build-7oUkmx/scipy/scipy/optimize/_linprog.pyt   <module>   s$   	A	,$'	²ÿ °	