Матрица $A$ и тестовые данные приведены ниже.
Задача:
$$ w^Tu \rightarrow min\\ s.t. Au=b, $$где $w^T=[1,1,1,1,4,3,2,1,7,5,3,1,10,7,4,1],~b=[220,215,93,64,108,286,71,127]$.
Оптимальный план: $$ \begin{bmatrix} 108 & 112 & 0 & 0\\ 0 & 174 & 41 & 0\\ 0 & 0 & 30 & 63\\ 0 & 0 & 0 & 64 \end{bmatrix} $$
$A$ -- матрица оператора суммирования по строкам и столбцам
In [25]:
vec =vector([2,3,4,5])
len(vec)
Out[25]:
In [2]:
import time
##initial data
A=matrix([[1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],
[1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0],
[0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0],
[0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0],
[0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1]])
feasibleSolution=vector([68,119,26,7,
20,84,17,94,
15,54,14,10,
5,29,14,16])
In [5]:
load("StandardGBIP.sage")
start = time.time()#measuring the time
#first row is for t
optimizationOrder=TermOrder('lex',9)+TermOrder('wdeglex',(
1,1,1,1,
4,3,2,1,
7,5,3,1,
10,7,4,1))
feasibleSolution=vector([68,119,26,7,
20,84,17,94,
15,54,14,10,
5,29,14,16])
StdGBIP.SolveOptimizationProblem(A,optimizationOrder,feasibleSolution)
print(time.time() - start)#measuring the time
In [11]:
load("QuotGBIP.sage")
start = time.time()#measuring the time
#first row is for t
optimizationOrder=TermOrder('wdeglex',(
1,1,1,1,
4,3,2,1,
7,5,3,1,
10,7,4,1))
feasibleSolution=vector([68,119,26,7,
20,84,17,94,
15,54,14,10,
5,29,14,16])
QuotGBIP.SolveOptimizationProblem(A,optimizationOrder,feasibleSolution)
print(time.time() - start)#measuring the time
In [52]:
load("LatticeBuchberger.sage")
start = time.time()#measuring the time
#first row is for t
optimizationOrder=['deglex',vector([
1,1,1,1,
4,3,2,1,
7,5,3,1,
10,7,4,1])]
feasibleSolution=vector([68,119,26,7, 20,84,17,94, 15,54,14,10, 5,29,14,16])
LatticeBuchberger.SolveOptimizationProblem(A,optimizationOrder,feasibleSolution)
print(time.time() - start)#measuring the time
In [ ]: