0

Hi I have the following code which I believe have indexed wrongly and so Im not getting the answer I am looking for

Diesel_matrix = xlsread('test_diesel.xlsx','Sheet2');

Diesel_supply = Diesel_matrix(:,1); % Power output of diesel generator

hourly_cost = Diesel_matrix(:,2);  % Diesel cost of running genreator at that output




 for z = 1:21

 A    = [-PV_supply -WT_supply -Diesel_supply(z)*ones(24,1)];

   f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(1:z))]  ;


 b = -Demand;

 [x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)
 end

I am trying to loop only for the third column of matrix A. I would like to loop for all the rows in "Diesel_supply" per row of matrix A

at the moment, the code works for 21 sets of x outputs but column 3 is either row 1,2,3 etc up to row 21 of "Diesel_supply". Wheras I am trying to get it for row 1 and 2 and 3 and 4 etc up to row 21 of "Diesel_supply". This will allow me to examine all the elements in "Diesel_Supply"

4

1 に答える 1

0

@ user643469との会話(コメントセクションのリンクを参照)とその後のlinprogのドキュメントを見ると、各z反復の結果をデータ構造に保存してから、次の中で最適なものを選択する必要があると思います。ループが終了しました。

私が理解しているように、ジェネレーターには21の異なるモードがあり、実行することができ、24の異なる制約があります。各モードは、内容を少し変更します。

それ以外の

[x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)

使用する

val = linprog(f,A,b,[],[],lb,ub)
results(z) = val;

ループが終了すると、次元4x21の結果マトリックスが残ります。最初の列にはx値が含まれ、2番目の列にはfval値が含まれ、3番目の列にはexitflag値が含まれます。次に、この「結果」マトリックスを調べて、ジェネレーターを実行するために使用できる21のモードのどれかを判別できます。

于 2012-07-12T04:14:26.650 に答える