version 1.3, 2000/05/29 08:54:45 |
version 1.7, 2000/12/05 01:24:50 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp.c,v 1.2 2000/04/13 06:01:01 noro Exp $ */ |
/* |
|
* Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED |
|
* All rights reserved. |
|
* |
|
* FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, |
|
* non-exclusive and royalty-free license to use, copy, modify and |
|
* redistribute, solely for non-commercial and non-profit purposes, the |
|
* computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and |
|
* conditions of this Agreement. For the avoidance of doubt, you acquire |
|
* only a limited right to use the SOFTWARE hereunder, and FLL or any |
|
* third party developer retains all rights, including but not limited to |
|
* copyrights, in and to the SOFTWARE. |
|
* |
|
* (1) FLL does not grant you a license in any way for commercial |
|
* purposes. You may use the SOFTWARE only for non-commercial and |
|
* non-profit purposes only, such as academic, research and internal |
|
* business use. |
|
* (2) The SOFTWARE is protected by the Copyright Law of Japan and |
|
* international copyright treaties. If you make copies of the SOFTWARE, |
|
* with or without modification, as permitted hereunder, you shall affix |
|
* to all such copies of the SOFTWARE the above copyright notice. |
|
* (3) An explicit reference to this SOFTWARE and its copyright owner |
|
* shall be made on your publication or presentation in any form of the |
|
* results obtained by use of the SOFTWARE. |
|
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
|
* e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification |
|
* for such modification or the source code of the modified part of the |
|
* SOFTWARE. |
|
* |
|
* THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL |
|
* MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND |
|
* EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS |
|
* FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' |
|
* RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY |
|
* MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. |
|
* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, |
|
* OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY |
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL |
|
* DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES |
|
* ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES |
|
* FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY |
|
* DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF |
|
* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART |
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
|
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
|
* |
|
* $OpenXM: OpenXM_contrib2/asir2000/builtin/dp.c,v 1.6 2000/08/22 05:03:57 noro Exp $ |
|
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
#include "parse.h" |
#include "parse.h" |
|
|
DP *rp; |
DP *rp; |
{ |
{ |
asir_assert(ARG0(arg),O_DP,"dp_ptozp"); |
asir_assert(ARG0(arg),O_DP,"dp_ptozp"); |
#if INET |
|
if ( Dist ) |
if ( Dist ) |
dp_ptozp_d(BDY(Dist),length(BDY(Dist)),(DP)ARG0(arg),rp); |
dp_ptozp_d(BDY(Dist),length(BDY(Dist)),(DP)ARG0(arg),rp); |
else |
else |
#endif |
|
dp_ptozp((DP)ARG0(arg),rp); |
dp_ptozp((DP)ARG0(arg),rp); |
} |
} |
|
|
|
|
p0 = (DP)ARG0(arg); p1 = (DP)ARG1(arg); |
p0 = (DP)ARG0(arg); p1 = (DP)ARG1(arg); |
asir_assert(p0,O_DP,"dp_ptozp2"); |
asir_assert(p0,O_DP,"dp_ptozp2"); |
asir_assert(p1,O_DP,"dp_ptozp2"); |
asir_assert(p1,O_DP,"dp_ptozp2"); |
#if INET |
|
if ( Dist ) |
if ( Dist ) |
dp_ptozp2_d(BDY(Dist),length(BDY(Dist)),p0,p1,&h,&r); |
dp_ptozp2_d(BDY(Dist),length(BDY(Dist)),p0,p1,&h,&r); |
else |
else |
#endif |
|
dp_ptozp2(p0,p1,&h,&r); |
dp_ptozp2(p0,p1,&h,&r); |
NEWNODE(n0); BDY(n0) = (pointer)h; |
NEWNODE(n0); BDY(n0) = (pointer)h; |
NEWNODE(NEXT(n0)); BDY(NEXT(n0)) = (pointer)r; |
NEWNODE(NEXT(n0)); BDY(NEXT(n0)) = (pointer)r; |
|
|
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 767 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) |