main() { dis_partstart(); init_copper(); initvect(); plz(); vect(); close_copper(); }
stype minknap(int n, int *p, int *w, int *x, int c) { allinfo a; item* tab;//[KNAPSIZE]; static item tabmem[KNAPSIZE]; interval* inttab;//[KNAPSIZE]; static interval inttabmem[SORTSTACK]; /* allocate space for internal representation */ //tab = (item *) palloc(sizeof(item) * n); tab = tabmem;//(item *) palloc(sizeof(item) * n); a.fitem = &tab[0]; a.litem = &tab[n-1]; copyproblem(a.fitem, a.litem, p, w, x); a.n = n; a.cstar = c; a.iterates = 0; a.simpreduced = 0; a.pireduced = 0; a.pitested = 0; a.maxstates = 0; a.coresize = 0; //inttab = (interval*) palloc(sizeof(interval) * SORTSTACK); inttab = inttabmem; a.intv1 = a.intv1b = &inttab[0]; a.intv2 = a.intv2b = &inttab[SORTSTACK - 1]; a.fsort = a.litem; a.lsort = a.fitem; partsort(&a, a.fitem, a.litem, 0, PARTIATE); findbreak(&a); a.ub = a.dantzig; a.firsttime = TRUE; for (;;) { a.iterates++; a.s = a.b-1; a.t = a.b; initfirst(&a, a.psumb, a.wsumb); initvect(&a); reduceset(&a); while ((a.d.size > 0) && (a.z < a.ub)) { if (a.t <= a.lsort) { if (haschance(&a, a.t, RIGHT)) multiply(&a, a.t, RIGHT); (a.t)++; } reduceset(&a); if (a.s >= a.fsort) { if (haschance(&a, a.s, LEFT)) multiply(&a, a.s, LEFT); (a.s)--; } reduceset(&a); } //pfree(a.d.set1); definesolution(&a); if (a.welldef) break; } //pfree(tab); //pfree(inttab); return a.zstar; }