SGU194 无源汇上下界可行流 上下界网络流 pascal

本文介绍了一种解决网络流问题的有效方法,特别是针对带有流量上下限约束的复杂网络。通过构造特殊的图结构并利用增广路径算法来寻找最大流,最终达到平衡网络中的流量分配。

@2004年集训队论文 

一种简易的方法求解流量有上下界的网络中网络流问题


的问题1.1


一开始建图建反了T T

论文里很详细..不多说了=w=

code:


var
  tmp,ans,tot,n,m,i,j,s,t,x,y,z,z1,z2,min,lo,p,flow:longint;
  su,path,dis,anti,next,his,pre,di,vh,a,b,c,flo:array[0..100009] of longint;  
  flag:boolean;
begin

  tot:=0;ans:=0;tmp:=0;
  fillchar(su,sizeof(su),0);
  fillchar(b,sizeof(b),0);
  read(n,m);
  for i:=1 to m do
    begin
      read(x,y,z1,z2);
      flo[i]:=z1;
      su[x]:=su[x]-z1;
      su[y]:=su[y]+z1;
      tot:=tot+1;a[tot]:=y;c[tot]:=z2-z1;next[tot]:=b[x];b[x]:=tot;anti[tot]:=tot+1;
      tot:=tot+1;a[tot]:=x;c[tot]:=0;next[tot]:=b[y];b[y]:=tot;anti[tot]:=tot-1;
    end;
  s:=n+1;t:=n+2;
  for i:=1 to n do
    if su[i]>0 then
      begin
        tot:=tot+1;a[tot]:=i;c[tot]:=su[i];next[tot]:=b[s];b[s]:=tot;anti[tot]:=tot+1;
        tot:=tot+1;a[tot]:=s;c[tot]:=0;next[tot]:=b[i];b[i]:=tot;anti[tot]:=tot-1;
        tmp:=tmp+su[i];
      end
    else
      begin
        tot:=tot+1;a[tot]:=t;c[tot]:=-su[i];next[tot]:=b[i];b[i]:=tot;anti[tot]:=tot+1;
        tot:=tot+1;a[tot]:=i;c[tot]:=0;next[tot]:=b[t];b[t]:=tot;anti[tot]:=tot-1;
      end;
  for i:=1 to n+2 do
    di[i]:=b[i];
  vh[0]:=n+2;
  fillchar(dis,sizeof(dis),0);
  s:=n+1;t:=n+2;
  i:=s;flow:=maxlongint;
  while dis[s]<=(n+1) do
    begin
      flag:=false;his[i]:=flow;p:=di[i];
      while p<>0 do
        begin
          j:=a[p];z:=c[p];
          if ((dis[j]+1)=dis[i]) and (z>0) then
            begin
              if z<flow then flow:=z;
              path[j]:=p;pre[j]:=i;
              di[i]:=p;flag:=true;i:=j;
              if i=t then
                begin
                  ans:=ans+flow;
                  while i<>s do
                    begin
                      p:=path[i];c[p]:=c[p]-flow;
                      c[anti[p]]:=c[anti[p]]+flow;
                      i:=pre[i];
                    end;
                  flow:=maxlongint;
                end;
              break;
            end;
          p:=next[p];
        end;
      if flag then continue;
      min:=t;p:=b[i];
      while p<>0 do
        begin
          j:=a[p];
          if (dis[j]<min) and (c[p]>0) then
            begin
              min:=dis[j];lo:=p;
            end;
          p:=next[p];
        end;
      di[i]:=lo;
      vh[dis[i]]:=vh[dis[i]]-1;
      if vh[dis[i]]=0 then break;
      dis[i]:=min+1;inc(vh[min+1]);
      if i<>s then begin i:=pre[i];flow:=his[i];end;
    end;
  if ans<tmp then writeln('NO') else begin  writeln('YES');
  for i:=1 to m do
    begin
      flo[i]:=flo[i]+c[i*2];
      writeln(flo[i]);
    end;end;
end.


独立储能的现货电能量与调频辅助服务市场出清协调机制(Matlab代码实现)内容概要:本文围绕“独立储能的现货电能量与调频辅助服务市场出清协调机制”展开,提出了一种基于Matlab代码实现的优化模型,旨在协调独立储能系统在电力现货市场与调频辅助服务市场中的联合出清问题。文中结合鲁棒优化、大M法和C&CG算法处理不确定性因素,构建了多市场耦合的双层或两阶段优化框架,实现了储能资在能量市场和辅助服务市场间的最优分配。研究涵盖了市场出清机制设计、储能运行策略建模、不确定性建模及求解算法实现,并通过Matlab仿真验证了所提方法的有效性和经济性。; 适合人群:具备一定电力系统基础知识和Matlab编程能力的研究生、科研人员及从事电力市场、储能调度相关工作的工程技术人员。; 使用场景及目标:①用于研究独立储能在多电力市场环境下的协同优化运行机制;②支撑电力市场机制设计、储能参与市场的竞价策略分析及政策仿真;③为学术论文复现、课题研究和技术开发提供可运行的代码参考。; 阅读建议:建议读者结合文档中提供的Matlab代码与算法原理同步学习,重点关注模型构建逻辑、不确定性处理方式及C&CG算法的具体实现步骤,宜在掌握基础优化理论的前提下进行深入研读与仿真调试。
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值