フィルターのクリア

genetic algorithm 'too many input arguments'

1 回表示 (過去 30 日間)
Ali Meghdadi
Ali Meghdadi 2013 年 12 月 1 日
コメント済み: Ali Meghdadi 2013 年 12 月 2 日
I want to minimize a function with a constraint which has 8 inputs. The problem is I cannot call the by x(1), x(2),etc because they are generated in another program in each loop and thos variables are used in other places. Does anyone have suggestion?
  2 件のコメント
Walter Roberson
Walter Roberson 2013 年 12 月 1 日
Please show your code attempt, and show how the functions are being generated.
Ali Meghdadi
Ali Meghdadi 2013 年 12 月 2 日
編集済み: Walter Roberson 2013 年 12 月 2 日
this is my constraint:
function NLPS = LPS(Nwt, Nbat, Npv, tilt, TArray, KtArray, LArray, WindArray)
EBatMax = 6.936*2*Nbat;
EBatMin = 0.5*EBatMax;
Ebat = EBatMax;
NLPS = 0;
for i=1:8760
T = TArray(i);
Kt = KtArray(i);
L = LArray(i);
Wind = WindArray(i);
[B0, delta, w0, ws] = daily_beam(i,tilt);
Epv = out_PV(Kt, Npv, T, B0, tilt, delta, w0, ws);
Ewt = out_wt(Wind, Nwt);
Generate = Epv + Ewt;
[EBatNew, Gbat] = out_bat(Ebat, EBatMin, EBatMax, Generate, L);
Ebat = EBatNew;
Generate = Generate + Gbat;
Net = L - Generate*0.9;
if Net < 0
NLPS = NLPS + 1;
end
end
end
this is the function to be minimized:
C=cost(Nbat,Nwt,Npv)
the inputs of NLPS are generated in other functions. genetic is supposed to generate some numbers for Nbat,Npv,Nbat and tilt in a way that minimizes the cost and also satisfies the constraint function.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 12 月 2 日
Something like,
constraint_function = @(x) LPS(x(1), x(2), x(3), tilt, TArray, KtArray, LArray, WindArray);
??
  2 件のコメント
Ali Meghdadi
Ali Meghdadi 2013 年 12 月 2 日
yes exactly. I tried and I get 'too many input arguments". Do you have any idea what is wrong here?
Ali Meghdadi
Ali Meghdadi 2013 年 12 月 2 日
I tried to simplify the issue optimizing this function `function z=f(x) f=(x(1)-2)^2+(x(2)-1)^2`. I input this in command window: [x fval]=ga(@f,2). But still I get same error!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by