How can I define two variable in GA ?

I need write two variable in matlab global opt. toolbox.
First x(i,j,k) and another y(i,j)
x(i,j,k) is a binary variable and y(i,j) not binary.how can i define they ? for example, what should i write in nvars section?
and how can i write
sum(x(i,j,k))=<y(i,k)

 採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 13 日

0 投票

nvars should be number of elements in x plus number of elements in y.
use [reshape(x,1,[]),reshape(y,1,[])] as the vector of values. You can extract portions and reshape inside the objective function.
intcons 1:numel(x)

1 件のコメント

Baris Karakum
Baris Karakum 2019 年 2 月 14 日
Really thank so much .

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by