Исходные данные задачи в стандартной форме

``````

In [194]:

function get_problem()
A = Float64[3 2 1 1 0; 2 5 3 0 1]
b = Float64[10, 15]
c = Float64[-2, -3, -4, 0, 0]
A, b, c
end

``````
``````

WARNING: Method definition get_problem() in module Main at In[185]:2 overwritten at In[194]:2.

Out[194]:

get_problem (generic function with 1 method)

``````
``````

In [195]:

function update_vars(A, basis, nonbasis)
B = A[:,basis]
N = A[:,nonbasis]
B⁻¹ = inv(B)
b̂ = B⁻¹ * b
return B, B⁻¹, N, b̂
end

``````
``````

WARNING: Method definition update_vars(Any, Any, Any) in module Main at In[186]:2 overwritten at In[195]:2.

Out[195]:

update_vars (generic function with 1 method)

``````
``````

In [196]:

function CHUZR(A, b̂)
m, n = size(A)
e = eye(m)
rations = [b̂[p] / norm(B⁻¹ * e[:,p]) for p in 1:m]
p = collect(take(sortperm(rations, rev=true), 1))
return p[1]
end

``````
``````

WARNING: Method definition CHUZR(Any, Any) in module Main at In[187]:2 overwritten at In[196]:2.

Out[196]:

CHUZR (generic function with 1 method)

``````
``````

In [197]:

function BTRAN(A, B⁻¹, p)
m, n = size(A)
e = eye(m)
πᵀ = e[:,p]' * B⁻¹
return πᵀ
end

``````
``````

WARNING: Method definition BTRAN(Any, Any, Any) in module Main at In[188]:2 overwritten at In[197]:2.

Out[197]:

BTRAN (generic function with 1 method)

``````
``````

In [198]:

function PRICE(πᵀ, N)
âᵀ = πᵀ * N
return âᵀ
end

``````
``````

WARNING: Method definition PRICE(Any, Any) in module Main at In[189]:2 overwritten at In[198]:2.

Out[198]:

PRICE (generic function with 1 method)

``````
``````

In [199]:

function CHUZC(c, nonbasis, âᵀ)
ĉ = c[nonbasis]
rations = [ĉ[j] / âᵀ'[j] for j in 1:length(âᵀ)]
q = collect(take(sortperm(rations), 1))
ĉₙ = c[nonbasis]
β = ĉ[q] / âᵀ[q]
c[nonbasis] = (ĉₙ' - β * âᵀ)'
return q[1]
end

``````
``````

WARNING: Method definition CHUZC(Any, Any, Any) in module Main at In[190]:2 overwritten at In[199]:2.

Out[199]:

CHUZC (generic function with 1 method)

``````
``````

In [200]:

function FTRAN(A, B⁻¹, b̂, p, âᵀ, q)
âq = B⁻¹ * A[:,q]
α = (b̂[p] / âᵀ[q])[1]
b̂ = b̂ - α * âq
end

``````
``````

WARNING: Method definition FTRAN(Any, Any, Any, Any, Any, Any) in module Main at In[191]:2 overwritten at In[200]:2.

Out[200]:

FTRAN (generic function with 1 method)

``````
``````

In [201]:

function update(basis, nonbasis, p, q)
basis[p], nonbasis[q] = nonbasis[q], basis[p]
end

``````
``````

WARNING: Method definition update(Any, Any, Any, Any) in module Main at In[192]:2 overwritten at In[201]:2.

Out[201]:

update (generic function with 1 method)

``````
``````

In [202]:

function iter(A, b, c, basis, nonbasis)
B, B⁻¹, N, b̂ = update_vars(A, basis, nonbasis)

p = CHUZR(A, b̂)

πᵀ = BTRAN(A, B⁻¹, p)

âᵀ = PRICE(πᵀ, N)

q = CHUZC(c, nonbasis, âᵀ)

FTRAN(A, B⁻¹, b̂, p, âᵀ, q)

update(basis, nonbasis, p, q)
end

``````
``````

WARNING: Method definition iter(Any, Any, Any, Any, Any) in module Main at In[193]:2 overwritten at In[202]:2.

Out[202]:

iter (generic function with 1 method)

``````
``````

In [203]:

A, b, c = get_problem()

basis = [4, 5]
nonbasis = [1, 2, 3]

iter(A, b, c, basis, nonbasis)

``````
``````

Out[203]:

(3,5)

``````