ga function Input data

1 回表示 (過去 30 日間)
Daniel Grebler
Daniel Grebler 2018 年 7 月 6 日
コメント済み: Stephen23 2018 年 7 月 6 日
Hey, I wish to use ga optimization for a given function.
I want to send an "extra" variable to the function that is not part of the optimized variables
basically: I have a function
function f=FindAC(x,val)
X is a 2X1 vector that I want to find the optimized value val is just a long array of input data
I tried:
ga(@(x,val)FindAC,2,[],[],[],[],lb,ub,[],intcon)
but I get error message
Not enough input arguments.
needless to say that without the ga optimization :
f=FindAC(x,val)
the function runs without errors
how can I send "val" to the function while asking the ga to optimize x
  1 件のコメント
Stephen23
Stephen23 2018 年 7 月 6 日
How to do this is explained in the MATLAB documentation:

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

採用された回答

Star Strider
Star Strider 2018 年 7 月 6 日
Try making ‘FindAC’ a function only of ‘x’ for ga:
ga(@(x)FindAC(x,val),2,[],[],[],[],lb,ub,[],intcon)
This a guess, since I am not certain what the problem is.
  2 件のコメント
Daniel Grebler
Daniel Grebler 2018 年 7 月 6 日
Thank you!
Star Strider
Star Strider 2018 年 7 月 6 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by