[Pntool-developers] SF.net SVN: pntool:[231] spnbox
Brought to you by:
compaqdrew,
miordache
From: <Ste...@us...> - 2009-08-21 19:39:41
|
Revision: 231 http://pntool.svn.sourceforge.net/pntool/?rev=231&view=rev Author: StephenCamp Date: 2009-08-21 19:39:34 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Modified actn.c to use the optimized row/column swaps during the uniqueness test. Modified Paths: -------------- spnbox/actn.c spnbox/tests/Makefile Modified: spnbox/actn.c =================================================================== --- spnbox/actn.c 2009-08-21 19:18:18 UTC (rev 230) +++ spnbox/actn.c 2009-08-21 19:39:34 UTC (rev 231) @@ -1,6 +1,7 @@ #include <stdlib.h> #include "../pnheaders/matrix.h" #include "matrixmath.h" +#include "extendedmatrix.h" #include "MemoryManager.h" #include "spnbox.h" @@ -101,9 +102,8 @@ int* UnraisableT; double* B; short int *IntList; - ipsolve_r result; + ipsolve_r result; - //If no transitions are being evaluated, return true. if ((Transitions = NumberOfColumns(*D) - XCount) <= 0) return 1; /*Build a flag array of the columns whose indices are in X.*/ @@ -112,8 +112,10 @@ { UnraisableT[X[i]] = 1; } - /*Build Dx. It should include only columns of D whose indices are not in X.*/ - AllocateMatrixType(2, &Dx, NumberOfRows(*D) + 1, Transitions); + /*Build Dx. It should include only columns of D whose indices are not in X. + It should be optimized for column ops.*/ + AllocateMatrixType(2, &Dx, Transitions, NumberOfRows(*D) + 1); + TransposeMatrix(&Dx); j = 0; for (i = 0; i < NumberOfColumns(*D); i++) { @@ -129,8 +131,9 @@ free(UnraisableT); /*Allocate space to record the values of the current column while it is - zeroed.*/ - AllocateMatrixType(1, &dx, NumberOfRows(*D) + 1, 1); + zeroed. Make it a type-2 transpose to optimize the column-swap operation.*/ + AllocateMatrixType(1, &dx, 1, NumberOfRows(*D) + 1); + TransposeMatrix(&dx); /*Build B. It is all zeroes except for a 1 in the last element.*/ B = tcalloc(NumberOfRows(*D) + 1, sizeof(double)); @@ -142,16 +145,13 @@ /*Iterate through each transition*/ for (i = 0; i < Transitions; i++) { - /*Zero a column of Dx and store it temporarily in dx for later restoration*/ - for (j = 0; j <= NumberOfRows(*D); j++) - { - //Restore the previous transition (if there is one to restore) - if (i) SetMatrixEl(&Dx, j, i - 1, GetMatrixEl(&dx, j, 0)); - //Copy the current transition - SetMatrixEl(&dx, j, 0, GetMatrixEl(&Dx, j, i)); - //Zero the current transition. - SetMatrixEl(&Dx, j, i, 0); - } + /*If there is a previous transition to restore, restore it.*/ + if (i) SwapColumns(&Dx, &dx, i - 1, 0); + /*Swap out the current transition. Because dx is a column of zeros this + will effectively zero the current transition and save a copy in dx for later + restoration.*/ + SwapColumns(&Dx, &dx, i, 0); + //ipsolve_r ipsolve(matrix* L, double* B, double* f, short int *IntList, double *ub, double *lb, short int *ctype); result = ipsolve(&Dx, B, 0, IntList, 0, 0, 0); if (result.res) free(result.res); Modified: spnbox/tests/Makefile =================================================================== --- spnbox/tests/Makefile 2009-08-21 19:18:18 UTC (rev 230) +++ spnbox/tests/Makefile 2009-08-21 19:39:34 UTC (rev 231) @@ -39,7 +39,7 @@ MSPLIT=msplit.o PN2ACPN=pn2acpn.o SUPERVIS=supervis.o $(EXTENDEDMATRIX) -ACTN=actn.o $(NLTRANS) +ACTN=actn.o $(EXTENDEDMATRIX) $(NLTRANS) ADMCON=admcon.o $(EXTENDEDMATRIX) $(IPSOLVE) ASIPH=asiph.o $(ACTN) $(EXTENDEDMATRIX) ILPADM=ilpadm.o $(IPSOLVE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |