double MOCPumpConfig::GetPress(double dX) { double dPress = 0; if(0 == FlowType())//体积流量 dX = MOCFluid::TranMassToQ(dX); if(dX > MaxFlow()) dX = MaxFlow(); if(dX < 0) dX = 0; dPress = m_CurveHQ.GetY(m_HQData,dX); if(PressType()==0)//水头 dPress = MOCFluid::TranHToPress(dPress); return dPress; }
double MOCPumpConfig::MaxMassFlow() { double dMass = MaxFlow(); if(0 == FlowType())//体积流量 dMass = MOCFluid::TranQToMass(dMass); return dMass; }
double MOCPumpConfig::GetPower(double dX) { double dNewPower = 0; double dPress = GetPress(dX); double dMass = dX; if(0 == FlowType())//体积流量 dX = MOCFluid::TranMassToQ(dX); if(dX > MaxFlow()) dX = MaxFlow(); if(dX < 0) dX = 0; dNewPower = m_CurvePower.GetY(m_PowerData,dX); if(fabs(dNewPower)<1E-6||dNewPower<0) return 0; if(0==PowerType()) { double dPe = CalcPe(dMass,dPress); dNewPower = dPe*100/dNewPower; } return dNewPower; }
int main() { FILE *in=fopen("ditch.in","r"); FILE *out=fopen("ditch.out","w"); int m,n; fscanf(in,"%d %d",&m,&n); MaxFlow nt= MaxFlow(); nt.org=1;nt.snk=n; nt.n=n; for(int i=1;i<=m;i++) {int x,b,c; fscanf(in,"%d %d %d",&x,&b,&c); nt.addEdge(x,b,c); } fprintf(out,"%d\n",nt.maxFlow()); fclose(out); return 0; }
int main() { int i,j,k; while(scanf("%d%d",&n,&m) && n+m) { memset(map,0,sizeof(map)); map[1][n+1] = map[n+1][1] = map[2*n][n] = map[n][2*n] = 20000000000LL; for(i=2;i<n;i++) { scanf("%d%d",&j,&k); map[j][j+n] = map[n+j][j] = k; } while(m--) { scanf("%d%d%d",&i,&j,&k); map[i+n][j] = map[j+n][i] = k; } printf("%lld\n",MaxFlow()); } return 0; }
int main() { int i,j,k,t,sum,goal,qq=0; char c; scanf("%d",&t); while(t--) { if(qq) puts(""); else qq = 1; memset(in,0,sizeof(in)); memset(out,0,sizeof(out)); memset(und,0,sizeof(und)); memset(map,0,sizeof(map)); memset(res,0,sizeof(res)); scanf("%d%d",&n,&m); numd = numu = 0; for(i=0;i<m;i++) { scanf("%d %d %c",&j,&k,&c); if(c == 'U') { und[j]++; und[k]++; ude[numu++] = (node){j,k}; } else { out[j]++; in[k]++; de[numd++] = (node){j,k}; } } for(i=1;i<=n && und[i]>=abs(in[i]-out[i]) && (in[i]+out[i]+und[i])%2==0;i++); if(i <= n) { puts("No euler circuit exist"); continue; } goal = numofe = 0; for(i=1;i<=n;i++) goal += abs(in[i]-out[i]+und[i]); goal /= 2; total = numu+n; //ºc¹Ï for(i=0;i<numu;i++) { res[i][numu+ude[i].a]++; res[i][numu+ude[i].b]++; } for(i=1;i<=n;i++) if(in[i]-out[i]+und[i] > 0) res[numu+i][total+2] = (in[i]-out[i]+und[i])/2; for(i=0;i<numu;i++) res[total+1][i] = 1; total += 2; sum = MaxFlow(total-1,total); //¶]flow if(sum != goal) { puts("No euler circuit exist"); continue; } for(i=0;i<numd;i++) //ºceuler circuit¹Ï map[de[i].a][de[i].b]++; for(i=0;i<numu;i++) for(j=1;j<=n;j++) if(res[j+numu][i] > 0) { if(ude[i].a == j) map[ude[i].a][ude[i].b]++; else map[ude[i].b][ude[i].a]++; } go(1); //¶]euler circuit if(numofe-1 != numd+numu) puts("No euler circuit exist"); else { for(i=numofe-1;i>0;i--) printf("%d ",ans[i]); printf("%d\n",ans[i]); } } return 0; }
int main(void) { out("starting ...\n"); std::cout << " MaxFlow " << std::endl; int N; //test cases scanf("%d\n", &N); out("N %d\n",N); int ord = 0; while(N-- > 0) { char * buff = NULL; graphtp g; size_t n; int m; //nodes scanf("%d\n", &m); out("m %d\n",m); int counter = 0; for(int i = 0; i < m; i++) { g.push_back(ve()); } out("size of g %d\n",g.size()); while(counter++ < m && getline(&buff, &n, stdin) != -1 ) { out("this is buff ='%s'\n", buff); char * tok = strtok(buff, " \n\t"); out("this is node ='%s'\n", tok); int nodefrom = atoi(tok); assert(nodefrom < m && "nodefrom is more than m"); if(tok == NULL) { printf("Error in input file"); exit(1); } tok = strtok(NULL, " \n\t"); while(tok > 0) { int nodeto = atoi(tok); if(nodeto < m) { out("red (node) tok='%s'\n", tok); } else { printf("ERROR: node %d outside of range (max %d)\n", nodeto,m); } tok = strtok(NULL, " \n\t"); if(tok == NULL) printf("ERROR: capacity must be given for each link \n"); float capacity = atof(tok); out("read (capacity) tok='%s'\n", tok); edge e; e.from = nodefrom; e.to = nodeto; e.flow = 0; e.capacity = capacity; e.backedge = false; g[nodefrom].push_back(e); out("inserting %d -> %d\n", nodefrom, nodeto); e.to = nodefrom; e.from = nodeto; e.backedge = true; g[nodeto].push_back(e); out("inserting %d -> %d\n", nodeto, nodefrom); tok = strtok(NULL, " \n\t"); } out("size of g %d\n",g.size()); } printf("Case %d:\n", ++ord); print_graph(g); MaxFlow(g, 0, g.size() - 1); printf("\n"); } return 0; }