内容发布更新时间 : 2024/11/18 17:54:17星期一 下面是文章的全部内容请认真阅读。
{ if (x <= 100) { return 100 + 10*x;
} else { return 14*x - 300; }
}
// 机组2成本 double cost2(double x) { if (x <= 60) { return 12*x + 200; } else { return 15*x + 20;
}
}
// 总成本 int get_total_price() { 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++) {
price += state[i][j]*cost2(power[i][j])
+ state[i][j]*(1-state[i][j-1])*start[i]; }
minprice = (minprice > price ? price: minprice);
//cout << minprice << \ \
20
fout << minprice << \ \ return 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;
}
// 机组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) { state[0][i] = 1; } else
{
21
state[0][i] = 0; }
// 机组2状态 if (power[1][i] > 0) { state[1][i] = 1;
} else { state[1][i] = 0; }
// 系统备用约束 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
{
\
\
22
}
}
}
// 继续递归求解 fun(i + 1);
23