フィルターのクリア

i have function file i want put limit in variables

3 ビュー (過去 30 日間)
Pratik Anandpara
Pratik Anandpara 2017 年 3 月 17 日
コメント済み: Steven Lord 2017 年 3 月 17 日
function y=myfitness(x)
y= x(1)+x(2)+x(3);
end
this is function file and i want 2<x1<11 ,3<x2<12, 4<x3<12 in this range and want y minimum answer in this range with help of genetic algorithm, i use 'ga' instruction also
fitfcn=@myfitness;
nvars=3;
[x fval]= ga(fitfcn,nvars);
i want minimize the function output value with this range with the help of Genetic algorithm

回答 (1 件)

Jan
Jan 2017 年 3 月 17 日
編集済み: Jan 2017 年 3 月 17 日
You can limit the values using inputs for ga() - see doc ga:
x = ga(fitnessfcn,nvars,A,b) finds a local minimum x to fitnessfcn,
subject to the linear inequalities A*x ≤ b. ga evaluates the matrix
product A*x as if x is transposed (A*x').
Or better use the lower and upper bounds:
x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB) defines a set of lower and
upper bounds on the design variables, x, so that a solution is found
in the range LB ≤ x ≤ UB.
  3 件のコメント
Pratik Anandpara
Pratik Anandpara 2017 年 3 月 17 日
2<x1<11 ,3<x2<12, 4<x3<12 for this three unknown variables..how to write instruction for this
Steven Lord
Steven Lord 2017 年 3 月 17 日
See the first Example on the documentation page to which Jan linked. It constrains the two variables to be greater than 0 using the variable lb. Just specify a three element vector for lb instead of a two element vector and specify a three element vector for ub as well. [The example didn't have an upper bound on the variable value, so it didn't need to specify ub and didn't specify it.]

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

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by