version 1.3, 2000/05/29 08:54:45 |
version 1.4, 2000/07/14 08:26:39 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp.c,v 1.2 2000/04/13 06:01:01 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp.c,v 1.3 2000/05/29 08:54:45 noro Exp $ */ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
#include "parse.h" |
#include "parse.h" |
|
|
int full; |
int full; |
DP *rp; |
DP *rp; |
{ |
{ |
DP u,p,d,s,t; |
DP u,p,d,s,t,dmy1; |
P dmy; |
P dmy; |
NODE l; |
NODE l; |
MP m,mr; |
MP m,mr; |
|
|
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( dp_redble(g,p = ps[wb[i]]) ) { |
if ( dp_redble(g,p = ps[wb[i]]) ) { |
dp_red(d,g,p,&t,&u,&dmy); |
dp_red(d,g,p,&t,&u,&dmy,&dmy1); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
if ( !u ) { |
if ( !u ) { |
|
|
DP *rp; |
DP *rp; |
P *dnp; |
P *dnp; |
{ |
{ |
DP u,p,d,s,t; |
DP u,p,d,s,t,dmy; |
NODE l; |
NODE l; |
MP m,mr; |
MP m,mr; |
int i,n; |
int i,n; |
|
|
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( dp_redble(g,p = ps[wb[i]]) ) { |
if ( dp_redble(g,p = ps[wb[i]]) ) { |
dp_red(d,g,p,&t,&u,&tdn); |
dp_red(d,g,p,&t,&u,&tdn,&dmy); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
if ( !u ) { |
if ( !u ) { |
|
|
int full,multiple; |
int full,multiple; |
DP *rp; |
DP *rp; |
{ |
{ |
DP u,p,d,s,t; |
DP u,p,d,s,t,dmy1; |
P dmy; |
P dmy; |
NODE l; |
NODE l; |
MP m,mr; |
MP m,mr; |
|
|
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( dp_redble(g,p = ps[wb[i]]) ) { |
if ( dp_redble(g,p = ps[wb[i]]) ) { |
dp_red(d,g,p,&t,&u,&dmy); |
dp_red(d,g,p,&t,&u,&dmy,&dmy1); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
if ( !u ) { |
if ( !u ) { |
Line 723 void Pdp_nf_demand(arg,rp) |
|
Line 723 void Pdp_nf_demand(arg,rp) |
|
NODE arg; |
NODE arg; |
DP *rp; |
DP *rp; |
{ |
{ |
DP g,u,p,d,s,t; |
DP g,u,p,d,s,t,dmy1; |
P dmy; |
P dmy; |
NODE b,l; |
NODE b,l; |
DP *hps; |
DP *hps; |
|
|
fprintf(stderr,"loading %s\n",fname); |
fprintf(stderr,"loading %s\n",fname); |
fp = fopen(fname,"r"); skipvl(fp); |
fp = fopen(fname,"r"); skipvl(fp); |
loadobj(fp,(Obj *)&p); fclose(fp); |
loadobj(fp,(Obj *)&p); fclose(fp); |
dp_red(d,g,p,&t,&u,&dmy); |
dp_red(d,g,p,&t,&u,&dmy,&dmy1); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
if ( !u ) { |
if ( !u ) { |
|
|
LIST *rp; |
LIST *rp; |
{ |
{ |
NODE n; |
NODE n; |
DP head,rest; |
DP head,rest,dmy1; |
P dmy; |
P dmy; |
|
|
asir_assert(ARG0(arg),O_DP,"dp_red"); |
asir_assert(ARG0(arg),O_DP,"dp_red"); |
asir_assert(ARG1(arg),O_DP,"dp_red"); |
asir_assert(ARG1(arg),O_DP,"dp_red"); |
asir_assert(ARG2(arg),O_DP,"dp_red"); |
asir_assert(ARG2(arg),O_DP,"dp_red"); |
dp_red((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),&head,&rest,&dmy); |
dp_red((DP)ARG0(arg),(DP)ARG1(arg),(DP)ARG2(arg),&head,&rest,&dmy,&dmy1); |
NEWNODE(n); BDY(n) = (pointer)head; |
NEWNODE(n); BDY(n) = (pointer)head; |
NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)rest; |
NEWNODE(NEXT(n)); BDY(NEXT(n)) = (pointer)rest; |
NEXT(NEXT(n)) = 0; MKLIST(*rp,n); |
NEXT(NEXT(n)) = 0; MKLIST(*rp,n); |
} |
} |
|
|
void dp_red(p0,p1,p2,head,rest,dnp) |
void dp_red(p0,p1,p2,head,rest,dnp,multp) |
DP p0,p1,p2; |
DP p0,p1,p2; |
DP *head,*rest; |
DP *head,*rest; |
P *dnp; |
P *dnp; |
|
DP *multp; |
{ |
{ |
int i,n; |
int i,n; |
DL d1,d2,d; |
DL d1,d2,d; |
|
|
divsp(CO,(P)c1,g,&a); c1 = (Q)a; divsp(CO,(P)c2,g,&a); c2 = (Q)a; |
divsp(CO,(P)c1,g,&a); c1 = (Q)a; divsp(CO,(P)c2,g,&a); c2 = (Q)a; |
} |
} |
NEWMP(m); m->dl = d; chsgnp((P)c1,&m->c); NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td; |
NEWMP(m); m->dl = d; chsgnp((P)c1,&m->c); NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td; |
|
*multp = s; |
muld(CO,s,p2,&t); muldc(CO,p1,(P)c2,&s); addd(CO,s,t,&r); |
muld(CO,s,p2,&t); muldc(CO,p1,(P)c2,&s); addd(CO,s,t,&r); |
muldc(CO,p0,(P)c2,&h); |
muldc(CO,p0,(P)c2,&h); |
*head = h; *rest = r; *dnp = (P)c2; |
*head = h; *rest = r; *dnp = (P)c2; |
|
|
dp_sp(p1,p2,rp); |
dp_sp(p1,p2,rp); |
} |
} |
|
|
|
extern int GenTrace; |
|
extern NODE TraceList; |
|
|
void dp_sp(p1,p2,rp) |
void dp_sp(p1,p2,rp) |
DP p1,p2; |
DP p1,p2; |
DP *rp; |
DP *rp; |
|
|
int *w; |
int *w; |
DL d1,d2,d; |
DL d1,d2,d; |
MP m; |
MP m; |
DP t,s,u; |
DP t,s1,s2,u; |
Q c,c1,c2; |
Q c,c1,c2; |
N gn,tn; |
N gn,tn; |
|
|
|
|
} |
} |
|
|
NEWMP(m); m->dl = d; m->c = (P)c2; NEXT(m) = 0; |
NEWMP(m); m->dl = d; m->c = (P)c2; NEXT(m) = 0; |
MKDP(n,m,s); s->sugar = d->td; muld(CO,s,p1,&t); |
MKDP(n,m,s1); s1->sugar = d->td; muld(CO,s1,p1,&t); |
|
|
NEWDL(d,n); d->td = td - d2->td; |
NEWDL(d,n); d->td = td - d2->td; |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
d->d[i] = w[i] - d2->d[i]; |
d->d[i] = w[i] - d2->d[i]; |
NEWMP(m); m->dl = d; m->c = (P)c1; NEXT(m) = 0; |
NEWMP(m); m->dl = d; m->c = (P)c1; NEXT(m) = 0; |
MKDP(n,m,s); s->sugar = d->td; muld(CO,s,p2,&u); |
MKDP(n,m,s2); s2->sugar = d->td; muld(CO,s2,p2,&u); |
|
|
subd(CO,t,u,rp); |
subd(CO,t,u,rp); |
|
if ( GenTrace ) { |
|
LIST hist; |
|
NODE node; |
|
|
|
node = mknode(4,ONE,0,s1,ONE); |
|
MKLIST(hist,node); |
|
MKNODE(TraceList,hist,0); |
|
|
|
node = mknode(4,ONE,0,0,ONE); |
|
chsgnd(s2,(DP *)&ARG2(node)); |
|
MKLIST(hist,node); |
|
MKNODE(node,hist,TraceList); TraceList = node; |
|
} |
} |
} |
|
|
void Pdp_sp_mod(arg,rp) |
void Pdp_sp_mod(arg,rp) |