フィルターのクリア

How I can use binary variable (0,1) for charge and discharge of battery in genetic algorithm.

4 ビュー (過去 30 日間)
Usman Taya
Usman Taya 2020 年 10 月 15 日
回答済み: Ameer Hamza 2020 年 10 月 15 日
Hi,
I want use binary discusion variable for charge and discharge of batter using genetic algorithm or particle swarm optimization (PSO). I want to know how I can you it in PSO algorithm.

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 15 日
You can use Intcon input argument to tell MATLAB that you only want integer values for these variables and then specify lower and upper bound to be 0 and 1, respectively. For example.
a = randi([0 1], 1, 5);
objFun = @(x) sum((x-a).^2); % assume is 5 dimensional vector
sol = ga(objFun, 5, [], [], [], [], [0 0 0 0 0], [1 1 1 1 1], [], 1:5)
Result
>> sol
sol =
0 1 0 1 1

カテゴリ

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