5-OPTIM - COMPUTING AND SELECTING THE BEST OF THE 15 PERMUTATIONS

This code was generated automatically by a Maple program. The main difficulty is the selection of the right data for each permutation. In symbolic form, all permutations can be generated quite easily and the pattern is simple. The code generated has quite a bit of variation. The header part is preparative code, it does not depend on the data and has been removed for clarity.


BOOL FiveOptim345( int e3, int e4, int e5, int vc, int ix, int iy, int iw )
{ double dd, L[7], M[12], W[12], t1, t2, v, Wei;
  int e1, e2, e6, e7, i, si, sj, va, vb, vd, ve;
  int NewTopology;

  . . . . . .

  NewTopology = 0;
  t1 = FiveSubtree( Wab,Mab, Wac,Mac, Wad,Mad, Wae,Mae,
     Wbc,Mbc, Wbd,Mbd, Wbe,Mbe, Wcd,Mcd, Wce,Mce, Wde,Mde, L);
  Edge[e1].len = L[0];
  Edge[e2].len = L[1];
  Edge[e3].len = L[2];
  Edge[e4].len = L[3];
  Edge[e5].len = L[4];
  Edge[e6].len = L[5];
  Edge[e7].len = L[6];
  t2 = FiveSubtree( Wad,Mad, Wac,Mac, Wab,Mab, Wae,Mae,
     Wcd,Mcd, Wbd,Mbd, Wde,Mde, Wbc,Mbc, Wce,Mce, Wbe,Mbe, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vd;
	Edge[e4].From = iw+ne;  Edge[e4].To = vc;
	Edge[e6].From = iy+ne;  Edge[e6].To = vb;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 1;
	}
  t2 = FiveSubtree( Wae,Mae, Wac,Mac, Wad,Mad, Wab,Mab,
     Wce,Mce, Wde,Mde, Wbe,Mbe, Wcd,Mcd, Wbc,Mbc, Wbd,Mbd, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = ve;
	Edge[e4].From = iw+ne;  Edge[e4].To = vc;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = vb;
	NewTopology = 2;
	}
  t2 = FiveSubtree( Wbc,Mbc, Wac,Mac, Wcd,Mcd, Wce,Mce,
     Wab,Mab, Wbd,Mbd, Wbe,Mbe, Wad,Mad, Wae,Mae, Wde,Mde, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = vc;
	Edge[e2].From = ix+ne;  Edge[e2].To = vb;
	Edge[e4].From = iw+ne;  Edge[e4].To = va;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 3;
	}
  t2 = FiveSubtree( Wcd,Mcd, Wac,Mac, Wbc,Mbc, Wce,Mce,
     Wad,Mad, Wbd,Mbd, Wde,Mde, Wab,Mab, Wae,Mae, Wbe,Mbe, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = vc;
	Edge[e2].From = ix+ne;  Edge[e2].To = vd;
	Edge[e4].From = iw+ne;  Edge[e4].To = va;
	Edge[e6].From = iy+ne;  Edge[e6].To = vb;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 4;
	}
  t2 = FiveSubtree( Wce,Mce, Wac,Mac, Wcd,Mcd, Wbc,Mbc,
     Wae,Mae, Wde,Mde, Wbe,Mbe, Wad,Mad, Wab,Mab, Wbd,Mbd, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = vc;
	Edge[e2].From = ix+ne;  Edge[e2].To = ve;
	Edge[e4].From = iw+ne;  Edge[e4].To = va;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = vb;
	NewTopology = 5;
	}
  t2 = FiveSubtree( Wac,Mac, Wab,Mab, Wad,Mad, Wae,Mae,
     Wbc,Mbc, Wcd,Mcd, Wce,Mce, Wbd,Mbd, Wbe,Mbe, Wde,Mde, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vc;
	Edge[e4].From = iw+ne;  Edge[e4].To = vb;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 6;
	}
  t2 = FiveSubtree( Wad,Mad, Wab,Mab, Wac,Mac, Wae,Mae,
     Wbd,Mbd, Wcd,Mcd, Wde,Mde, Wbc,Mbc, Wbe,Mbe, Wce,Mce, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vd;
	Edge[e4].From = iw+ne;  Edge[e4].To = vb;
	Edge[e6].From = iy+ne;  Edge[e6].To = vc;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 7;
	}
  t2 = FiveSubtree( Wae,Mae, Wab,Mab, Wad,Mad, Wac,Mac,
     Wbe,Mbe, Wde,Mde, Wce,Mce, Wbd,Mbd, Wbc,Mbc, Wcd,Mcd, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = ve;
	Edge[e4].From = iw+ne;  Edge[e4].To = vb;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = vc;
	NewTopology = 8;
	}
  t2 = FiveSubtree( Wab,Mab, Wad,Mad, Wac,Mac, Wae,Mae,
     Wbd,Mbd, Wbc,Mbc, Wbe,Mbe, Wcd,Mcd, Wde,Mde, Wce,Mce, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vb;
	Edge[e4].From = iw+ne;  Edge[e4].To = vd;
	Edge[e6].From = iy+ne;  Edge[e6].To = vc;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 9;
	}
  t2 = FiveSubtree( Wac,Mac, Wad,Mad, Wab,Mab, Wae,Mae,
     Wcd,Mcd, Wbc,Mbc, Wce,Mce, Wbd,Mbd, Wde,Mde, Wbe,Mbe, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vc;
	Edge[e4].From = iw+ne;  Edge[e4].To = vd;
	Edge[e6].From = iy+ne;  Edge[e6].To = vb;
	Edge[e7].From = iy+ne;  Edge[e7].To = ve;
	NewTopology = 10;
	}
  t2 = FiveSubtree( Wae,Mae, Wad,Mad, Wac,Mac, Wab,Mab,
     Wde,Mde, Wce,Mce, Wbe,Mbe, Wcd,Mcd, Wbd,Mbd, Wbc,Mbc, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = ve;
	Edge[e4].From = iw+ne;  Edge[e4].To = vd;
	Edge[e6].From = iy+ne;  Edge[e6].To = vc;
	Edge[e7].From = iy+ne;  Edge[e7].To = vb;
	NewTopology = 11;
	}
  t2 = FiveSubtree( Wab,Mab, Wae,Mae, Wad,Mad, Wac,Mac,
     Wbe,Mbe, Wbd,Mbd, Wbc,Mbc, Wde,Mde, Wce,Mce, Wcd,Mcd, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vb;
	Edge[e4].From = iw+ne;  Edge[e4].To = ve;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = vc;
	NewTopology = 12;
	}
  t2 = FiveSubtree( Wad,Mad, Wae,Mae, Wab,Mab, Wac,Mac,
     Wde,Mde, Wbd,Mbd, Wcd,Mcd, Wbe,Mbe, Wce,Mce, Wbc,Mbc, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vd;
	Edge[e4].From = iw+ne;  Edge[e4].To = ve;
	Edge[e6].From = iy+ne;  Edge[e6].To = vb;
	Edge[e7].From = iy+ne;  Edge[e7].To = vc;
	NewTopology = 13;
	}
  t2 = FiveSubtree( Wac,Mac, Wae,Mae, Wad,Mad, Wab,Mab,
     Wce,Mce, Wcd,Mcd, Wbc,Mbc, Wde,Mde, Wbe,Mbe, Wbd,Mbd, L);
  if( ReallyLess(t2,t1) ) {
	t1 = t2;
	Edge[e1].len = L[0];
	Edge[e2].len = L[1];
	Edge[e3].len = L[2];
	Edge[e4].len = L[3];
	Edge[e5].len = L[4];
	Edge[e6].len = L[5];
	Edge[e7].len = L[6];
	Edge[e1].From = ix+ne;  Edge[e1].To = va;
	Edge[e2].From = ix+ne;  Edge[e2].To = vc;
	Edge[e4].From = iw+ne;  Edge[e4].To = ve;
	Edge[e6].From = iy+ne;  Edge[e6].To = vd;
	Edge[e7].From = iy+ne;  Edge[e7].To = vb;
	NewTopology = 14;
	}
  return( NewTopology );
}