# 【电动车】电动汽车两阶段优化调度策略（Matlab代码实现）

1 概述

2 数学模型

3 运行结果

4 Matlab代码实现

5 结论

6 全文阅读

详细数学模型及求解见全文阅读。

## 4 Matlab代码实现

``````%%%完全竞争市场%%%
%%%价格接受者%%%
%%%日前调度，价格采用联合(独立)报价模式下的出清价格%%%
clear
clc
%决策变量
Pch=sdpvar(4,96);%各充电站充电电量
Pdis=sdpvar(4,96);%各充电站放电电量
S=sdpvar(4,96);%广义储能设备电量
%基本参数
Pchmax=[Forecast_CS1(1,1:96);Forecast_CS2(1,1:96);Forecast_CS3(1,1:96);Forecast_CS4(1,1:96)];%充电站充电报量上限
Pdismax=[Forecast_CS1(2,1:96);Forecast_CS2(2,1:96);Forecast_CS3(2,1:96);Forecast_CS4(2,1:96)];%充电站放电报量上限
Smin=[Forecast_CS1(3,1:96);Forecast_CS2(3,1:96);Forecast_CS3(3,1:96);Forecast_CS4(3,1:96)];%充电站电量下限;
Smax=[Forecast_CS1(4,1:96);Forecast_CS2(4,1:96);Forecast_CS3(4,1:96);Forecast_CS4(4,1:96)];%充电站电量上限;
deltaS=[Forecast_CS1(5,1:96);Forecast_CS2(5,1:96);Forecast_CS3(5,1:96);Forecast_CS4(5,1:96)];%充电站电量变化量;
lastS=[Forecast_CS1(5,97);Forecast_CS2(5,97);Forecast_CS3(5,97);Forecast_CS4(5,97)];%第96个时段必须完成的充电量
price=[1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1.10000000000000,1,1,1,1,0.900000000000000,1,0.900000000000000,0.900000000000000,1,1,1,1,1,1,1,1,1,1,1,1,0.900000000000000,0.900000000000000,0.900000000000000,0.900000000000000,0.800000000000000,0.800000000000000,0.800000000000000,0.800000000000000,0.800000000000000,0.800000000000000,0.800000000000000,0.800000000000000,0.700000000000000,0.700000000000000,0.700000000000000,0.700000000000000,0.500000000000000,0.500000000000000,0.500000000000000,0.500000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.400000000000000,0.500000000000000,0.500000000000000,0.500000000000000,0.500000000000000,0.700000000000000,0.700000000000000,0.700000000000000,0.700000000000000,0.900000000000000,0.900000000000000,0.900000000000000,0.900000000000000];
%约束条件
Constraints=[0<=Pch<=Pchmax,0<=Pdis<=Pdismax,Smin<=S<=Smax,S(:,1)==0.25*0.95*Pch(:,1)-0.25*Pdis(:,1)/0.95+deltaS(:,1),
S(:,2:96)==S(:,1:95)+0.25*0.95*Pch(:,2:96)-0.25*Pdis(:,2:96)/0.95+deltaS(:,2:96),
0==S(:,96)+lastS];%充电站约束
%目标函数
Obj=sum(0.25*(Pch-Pdis)*price');%充电站各自目标
%求解模型
ops=sdpsettings('solver','gurobi','gurobi.OptimalityTol',1e-8,'gurobi.FeasibilityTol',1e-8,'gurobi.IntFeasTol',1e-8);
ops.gurobi.MIPGap=1e-8;
solvesdp(Constraints,Obj,ops);
result_DA_pricetaken.Pch=double(Pch);
result_DA_pricetaken.Pdis=double(Pdis);
result_DA_pricetaken.S=double(S);
save('result_DA_pricetaken','result_DA_pricetaken');``````

## 5 结论

1)闵可夫斯基求和能够将电刭汽十养t心凤河广义储能设备,降低了模型的维度但1休田J文量 的约束关系,能保证充电站允以电划Hy1E 可靠性。
2)两阶段市场投标模式能够在保证充电站电能需求的同时发挥充电站的市场力,同时能通过价

3)独立投标模式缺乏协调性,导致了额外的电能费用。联合投标模式虽然能够进一步提高充电站整体的收益,但需要设计公平的利益分配机制以确保各主体的均衡,避免联盟关系的破裂。