Variable in cost function should take only two values.

How can i set my objective function variable to take only 0 and 1 and not anything in between? I am using ga solver and my objective function is like min(f(x))= x(1) + x(2) + x(3) with constraint that (x(1) +x(2) + x(3))*0.2=0.4. Please help

6 件のコメント

John D'Errico
John D'Errico 2018 年 4 月 30 日
Use intlinprog instead.
Mondeep maz
Mondeep maz 2018 年 4 月 30 日
Thanks this would work for a single objective function. What if i had a multi objective problem?
sloppydisk
sloppydisk 2018 年 4 月 30 日
You must specify how the multiple objectives have to be used. Perhaps you want to minimize the sum of the objective functions? Or give each objective a weight?
Walter Roberson
Walter Roberson 2018 年 4 月 30 日
(x(1) +x(2) + x(3))*0.2=0.4 is the same constraint as (x(1) +x(2) + x(3))*2=4 which is the same as (x(1) +x(2) + x(3)) = 2 . Using the integer valued one avoids any issues of round-off due to 0.2 not being exactly representable as an integer.
John BG
John BG 2018 年 4 月 30 日
編集済み: John BG 2018 年 4 月 30 日
working in binary formay may come handy:
L=dec2bin(randi([0 100],1,1))
uint8(str2num(L(:))')
John BG
Mondeep maz
Mondeep maz 2018 年 5 月 5 日
Thank you for the help guys.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series についてさらに検索

タグ

質問済み:

2018 年 4 月 30 日

コメント済み:

2018 年 5 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by