diff options
Diffstat (limited to 'Build/source/utils/asymptote/base/rationalSimplex.asy')
-rw-r--r-- | Build/source/utils/asymptote/base/rationalSimplex.asy | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/Build/source/utils/asymptote/base/rationalSimplex.asy b/Build/source/utils/asymptote/base/rationalSimplex.asy index 823d91c2d0b..6070c7cbdb9 100644 --- a/Build/source/utils/asymptote/base/rationalSimplex.asy +++ b/Build/source/utils/asymptote/base/rationalSimplex.asy @@ -1,8 +1,8 @@ // Rational simplex solver written by John C. Bowman and Pouria Ramazi, 2018. import rational; -void simplexStandard(rational[] c, rational[][] A, int[] s=new int[], - rational[] b) {} +void simplexInit(rational[] c, rational[][] A, int[] s=new int[], + rational[] b, int count) {} void simplexTableau(rational[][] E, int[] Bindices, int I=-1, int J=-1) {} void simplexPhase1(rational[] c, rational[][] A, rational[] b, int[] Bindices) {} @@ -35,7 +35,9 @@ struct simplex { int case; rational[] x; + rational[] xStandard; rational cost; + rational[] d; int m,n; int J; @@ -319,15 +321,26 @@ struct simplex { case=(dual ? iterateDual : iterate)(D,n,Bindices); simplexTableau(D,Bindices); - if(case != OPTIMAL) - return; + x=new rational[n]; for(int j=0; j < n; ++j) x[j]=0; for(int k=0; k < m; ++k) x[Bindices[k]-1]=D[k][0]; + if(case == UNBOUNDED) { + d=new rational[n]; + for(int j=0; j < n; ++j) + d[j]=0; + d[J-1]=1; + for(int k=0; k < m; ++k) + d[Bindices[k]-1]=-D[k][J]; + } + + if(case != OPTIMAL) + return; + cost=-Dm[0]; } @@ -391,10 +404,13 @@ struct simplex { } rational[] C=concat(c,array(count,rational(0))); - if(count > 0) simplexStandard(C,a,b); + simplexInit(C,a,b,count); operator init(C,a,b,phase1,dual); - if(case == OPTIMAL && count > 0) - x.delete(n,n+count-1); + if(case != INFEASIBLE) { + xStandard=copy(x); + if(count > 0) + x.delete(n,n+count-1); + } } } |