沐昭. 2022-11-01 14:46
浏览 15
已结题

matlab如何计算轨道交通的碳排放,具体需要什么数据

我在网上搜到的是使用节约算法计算的只是材料运输产生的碳排放量

clc
clear all
p1=0.9;
customer=xlsread('customer.xlsx');           %需求点信息
facility=xlsread('facility.xlsx');           %设施点信息
facilityposition=facility(:,2:3);               %设施坐标
customerposition=customer(:,2:3);               %需求点坐标
position=[facilityposition;customerposition];   
xlswrite('position.xlsx',position)
position1=[position(:,1) position(:,2)];
distMatrix=dists(position1);                    %计算得出的两点之间的距离
xlswrite('distMatrix.xlsx',distMatrix)

ttimeu=fix(distMatrix);                         %两点之间的距离
%%%%%%%%%%%%%%%%%%%%%%%%%固定数据%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Qofcar=200;                                     %车辆容量
costofallcar=5000;                               %车辆固定成本
costofunitdistance=9;                            %单位距离成本
tanpaifangyinzi=1;                               %车辆碳排放因子
danweiyouhao=1;                                  %车辆单位油耗
%%%%%%%%%%%%%%%%%%%%%%%计算出来的数据%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Numberofpoints=size(customer,1);                %需求点数量
Numberoffacilities=size(facility,1);            %设施点数量
quantity=[customer(:,1) customer(:,4) customer(:,4)];     %需求点需求量
Qoffacilities=[facility(:,1) facility(:,4)];    %设施容量
timewindow=[customer(:,1) customer(:,6:7)];     %需求点时间窗
countfacility=facility(:,5);                    %建立设施固定成本
codeofpicture=1;


timewindow

assignofpoint=[2 1 2 1 3 3 1 2 1 1 2 3 2];
[outcome1,outcome2,outcome3]=cw(Numberoffacilities,assignofpoint,ttimeu,timewindow,distMatrix,quantity,Qofcar,p1);
%outcome1=[1 1 2 1 2 3 3 4 4 3 5 5 5];
%outcome2=[9 2 10 4 7 13 1 11 8 3 12 5 6];
[outcome1,outcome2,outcome3]=tabu(outcome1,outcome2,outcome3,distMatrix,ttimeu,Numberoffacilities,timewindow);

[Picture]=picture(codeofpicture,outcome1,outcome2,outcome3,customer,facility);
    function [outcome1,outcome2,outcome3]=cw(Numberoffacilities,assignofpoint,ttimeu,timewindow,distMatrix,quantity,Qofcar,p1)    
    H=1;
    outcome3=zeros(1,Numberoffacilities);%与设施点的伪编号是一一对应的   
    %%%%%%%找到实际分配的设施点,因为之前的chrom中为1的点,可能%%%%%%%%%%%%%
    facilitypop=zeros(1:Numberoffacilities);
    facilitypop(assignofpoint)=1;
    trueSelectefacilities=find(facilitypop(1,:)==1);     %被选择的设施编号    
    trueselectNumberoffacilities=size(trueSelectefacilities,2);
    outcome1=cell(1,trueselectNumberoffacilities);
    outcome2=cell(1,trueselectNumberoffacilities);    
    for i=1:trueselectNumberoffacilities%此时的设施为i
        a=trueSelectefacilities(i);%设施的伪编号        
        pointofsubroute=find(assignofpoint==a);%属于该设施点的所有需求点的伪编号
        Numberofpointsofsubroute=size(pointofsubroute,2);%该设施点的需求点数量           
        judge=zeros(1,Numberofpointsofsubroute);                           %判断需求点的位置情况       
        chrom1=zeros(1,Numberofpointsofsubroute);%最后输入的是伪编号        
        chrom2=sort(pointofsubroute);                                      %需求点伪编号从小到大排序        
        originalchrom2=chrom2;
        
        %%对关键节点先分配一个车辆给它?????????????????????对不对?
        %for j=1:Numberofpointsofsubroute            
            %if timewindow(chrom2(j),2)==timewindow(chrom2(j),3)                  
                %chrom1(j)=H;
                %H=H+1;                
            %end
        %end      
        %%%%%%%%计算到达时间%%%%%%%%%%%%%%%%%%%%        
        arrivetime=zeros(1,Numberofpointsofsubroute);%需求点的到达时间,与当前的originalchrom2位置一一对应,与分配给该设施点的需求点一一对应        
        for j=1:Numberofpointsofsubroute            
            if ttimeu(chrom2(j)+Numberoffacilities,a)<timewindow(chrom2(j),2)                
                arrivetime(j)=timewindow(chrom2(j),2);                
            else
                arrivetime(j)=ttimeu(chrom2(j)+Numberoffacilities,a);                
            end
        end        
        %%%%%%%%%%%%%%%%%%%%%%%%%路径节约值列表%%%%%%%%%%%%%%%%%%%%%%        
        savingnumber=zeros(Numberofpointsofsubroute);%与分配给该设施的需求点的伪编号一一对应        
        for j=1:Numberofpointsofsubroute            
            for z=1:Numberofpointsofsubroute                
                if j~=z                       
                    savingnumber(j,z)=distMatrix(chrom2(j)+Numberoffacilities,a)+distMatrix(chrom2(z)+Numberoffacilities,a)-distMatrix(chrom2(j)+Numberoffacilities,chrom2(z)+Numberoffacilities);                    
                end
            end
        end        
        [a b]=max(savingnumber);%a输入值,b中对应的数字为行,对应的列数为列        
        [c d]=max(a);%c输入具体的当前节约值,d为列数         
        e=b(d);%e为行 
        %%%在节约值列表中e行d列是当前最大的节约量
        E=chrom2(e);%此时的E为节约量最大的需求点伪编号之一
        D=chrom2(d);%此时的D为节约量最大的需求点伪编号之1       
        done=1;            
        while(done<2)                
            if judge(e)==0&&judge(d)==0                 
                PD=0;                
                a=quantity(E,2)+quantity(D,2);
                aa=quantity(E,3)+quantity(D,3);
                pp1=normcdf(Qofcar,a,sqrt(aa));
                a2=find(chrom2==D);                
                b2=find(chrom2==E);
                if pp1>p1                       
                    EFj=arrivetime(e)+ttimeu(E+Numberoffacilities,D+Numberoffacilities)-arrivetime(d);                      
                    if EFj<0                             
                        aheadtime=arrivetime(d)-timewindow(D,2);                           
                        if aheadtime>=-EFj                                
                            PD=1;                                 
                        end
                    elseif EFj==0
                        PD=1;                        
                    elseif EFj>0                          
                        delaytime=timewindow(D,3)-arrivetime(d);                            
                        if delaytime>=EFj                             
                            PD=1;                               
                        end
                    end
                    if PD==1                        
                        chrom1(e)=H;                            
                        chrom1(d)=H;%H为车辆编号                          
                        judge(e)=1;%与设施直接相连的起点为1                          
                        judge(d)=2;%与设施直接相连的终点为2                           
                        H=H+1;                            
                        arrivetime(d)=arrivetime(d)+EFj;
                        if b2>a2
                            chrom2(a2)=E;
                            chrom2(b2)=D;
                        end
                    end
                end
                savingnumber(e,d)=0;                
            elseif judge(e)==0&&judge(d)==1;                 
                a2=find(chrom2==D);                
                b2=find(chrom2==E);                
                a=find(chrom1==chrom1(a2));                
                b=sum(quantity(chrom2(a),2))+quantity(E,2);
                bb=sum(quantity(chrom2(a),3))+quantity(E,3);                
                pp1=normcdf(Qofcar,b,sqrt(bb)); 
                c=size(a,2);
                if pp1>p1                       
                    EFj=arrivetime(e)+ttimeu(E+Numberoffacilities,D+Numberoffacilities)-arrivetime(d);                    
                    if EFj<0                          
                        a1=10000;                            
                        for j=1:c                            
                            b1=find(originalchrom2==chrom2(a(j)));                            
                            Aheadtime=arrivetime(b1)-timewindow(chrom2(a(j)),2);                             
                            if Aheadtime<a1                                     
                                aheadtime=Aheadtime;                                   
                                a1=Aheadtime;                                 
                            end
                        end
                        if aheadtime>=-EFj                            
                            PD=1;                             
                        end
                    elseif EFj==0                        
                        PD=1;                             
                    elseif EFj>0                           
                        a1=10000;                         
                        for j=1:c                               
                            b1=find(originalchrom2==chrom2(a(j)));                            
                            Delaytime=timewindow(chrom2(a(j)),3)-arrivetime(b1);                              
                            if Delaytime<a1                                       
                                delaytime=Delaytime;                                     
                                a1=Delaytime;                                     
                            end
                        end
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 11月9日
    • 专家修改了标签 11月2日
    • 创建了问题 11月1日

    悬赏问题

    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题