const int hour = 5; // 最大出力
int pmax[2] = {200, 100}; // 最大增出力 int pcmax[2] = {30, 40}; // 最大减出力 int pdmax[2] = {50, 60}; // 状态
int state[2][hour] = {{1}, {0}}; // 负荷
int demand[5] = {0, 100, 130, 170, 140}; // 启动费用
int start[2] = {350, 100}; // 机组各时段状态
int power[2][5] = {{100}, {0}};
// 系统备用要求
int b_power[hour] = {0, 20, 30, 50, 40}; // 最小费用
int minprice = 9999999;
int main() { fun(1); return 0;
}
// 机组1成本 double cost1(double x) { if (x <= 100) { return 100 + 10*x;
} else { return 14*x - 300;
}
}
// 机组2成本 double cost2(double x) {
20
}
if (x <= 60) { return 12*x + 200; } else { }
return 15*x + 20;
// 总成本
int get_total_price() { }
void fun(int i) { for (int j = -50; j <= 30; j+= 1)
{
// 机组1
power[0][i] = power[0][i-1] + j; // 机组1出力范围约束
if (power[0][i] < 0 || power[0][i] > 200) {
continue;
21
int i = 0, j;
double price = 0;
for (j = 1; j < hour; j++) { price += state[i][j]*cost1(power[i][j])
+ state[i][j]*(1-state[i][j-1])*start[i];
}
i = 1;
for (j = 1; j < hour; j++) { }
minprice = (minprice > price ? price: minprice); //cout << minprice << \ \fout << minprice << \ \return price;
price += state[i][j]*cost2(power[i][j])
+ state[i][j]*(1-state[i][j-1])*start[i];
}
// 机组1增出力和减出力约束
if ( ((power[0][i]-power[0][i-1]) > pcmax[0]) && (power[0][i] > power[0][i-1]) { }
|| ((power[0][i-1]-power[0][i]) > pdmax[0]) && (power[0][i-1] > power[0][i])) continue;
// 机组2 // 负荷平衡约束
power[1][i] = demand[i] - power[0][i]; // 机组2出力范围约束
if (power[1][i] < 0 || power[1][i] > 100) {
continue; }
// 机组2增出力和减出力约束
if ( ((power[1][i]-power[1][i-1]) > pcmax[1]) && (power[1][i] > power[1][i-1])
||((power[1][i-1]-power[1][i]) > pdmax[1]) && (power[1][i-1] > power[1][i])) { continue; }
// 机组1状态 if (power[0][i] > 0) { } else { }
state[0][i] = 0; state[0][i] = 1;
// 机组2状态 if (power[1][i] > 0) { state[1][i] = 1; } else
{ state[1][i] = 0; }
// 系统备用约束
22
int bei = 0; int k = 0;
for ( k = 0; k < 2; k++) {
bei += state[k][i] * (pmax[k] - power[k][i]);
}
if (bei < b_power[i]) { continue;
}
if (i == hour - 1) { // cout << get_total_price() << \ \
// for (k = 0; k < hour; k++)
// { // cout << power[0][k] << \ // }
// cout << endl;
fout << get_total_price() << \ \ for (k = 0; k < hour; k++) { fout << power[0][k] << \ }
fout << endl;
}
else { // 继续递归求解 fun(i + 1); }
}
}
附录2
2.1 初始化个参数
% IEEE118BusData 遗传算法计算 %分段增量总发电量 54*5 rp = [10 15 20 25 30 10 15 20 25 30 10 15 20 25 30
23
\\
180 210 240 270 300 140 180 220 260 300 14 18 22 26 30 40 55 70 85 100 10 15 20 25 30 10 15 20 25 30 140 180 220 260 300 150 200 250 300 350
12.4 16.8 21.2 25.6 30 12.4 16.8 21.2 25.6 3040 55 70 85 100
12.4 16.8 21.2 25.6 3040 55 70 85 100
12.4 16.8 21.2 25.6 3012.4 16.8 21.2 25.6 3040 55 70 85 100 90 130 170 210 250 90 130 170 210 250 40 55 70 85 100 40 55 70 85 100 80 110 140 170 200 80 110 140 170 200 40 55 70 85 100 164 228 292 356 420 164 228 292 356 420 124 168 212 256 300 40 50 60 70 80 14 18 22 26 30 10 15 20 25 30 8 11 14 17 20 40 55 70 85 100 40 55 70 85 100 180 210 240 270 300 40 55 70 85 100 14 18 22 26 30 140 180 220 260 300 80 110 140 170 200
10.4 12.8 15.2 17.6 2026 32 38 44 50 140 180 220 260 300 140 180 220 260 300 140 180 220 260 300
10.4 12.8 15.2 17.6 2040 55 70 85 100
24