variable declaration for optimization

hello,
I am writing a code where I need to declare two variables which will be used for optimization in further, i.e,
a,b -----> variable(a=complex, b=real)
x=h1*a^2+h2*b^2+h3;------>h1,h2,h3 are constants
x=objective of optimization problem
what will be the code to declare 'a' and 'b';?

4 件のコメント

Walter Roberson
Walter Roberson 2020 年 10 月 31 日
Are you doing Problem Based Optimization?
Soumili Sen
Soumili Sen 2020 年 10 月 31 日
no,solver based...
Walter Roberson
Walter Roberson 2020 年 10 月 31 日
You do not define variables for solver based optimization: you define a function that accepts a vector of values.
Soumili Sen
Soumili Sen 2020 年 11 月 12 日
okk.. thanks

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

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日

0 投票

Only specify them as input of function handle. Normal procedure is something like this
h1 = 2;
h2 = 3;
h3 = 1;
x = @(a, b) h1*a^2+h2*b^2+h3;
objFun = @(p) x(p(1),p(2));
MATLAB optimization functions expect that the function handle only accepts one multi-dimensional input. Therefore, we converted 'x' with two scalar inputs to objFun with a single 2-dimensional input vector. Then use an optimization solver, such as fmincon()
sol = fmincon(objFun, rand(2,1))

10 件のコメント

Soumili Sen
Soumili Sen 2020 年 10 月 31 日
Thanks... But what about the complex value of the variable?
Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
What do you mean by the complex value of variable? Is one of the variable complex number?
Soumili Sen
Soumili Sen 2020 年 10 月 31 日
yes,one veriable is complex number
Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
Can you show your optimization problem?
Soumili Sen
Soumili Sen 2020 年 10 月 31 日
This is my code-
hr = sqrt ( .5/ 2 ) .* (randn(1)+j*randn(1));
hr = sqrt ( .3/ 2 ) .* (randn(1)+j*randn(1));
n1 = sqrt ( .1/ 2 ) .* (randn(1)+j*randn(1));
constellation = sqrt(1/2)*[1+1i*1 1-1i*1 -1-1i*1 -1+1i*1];
cons_size = size(constellation);
x = constellation(randi([1 4],1,100));
r=@(b) (hr*x+hr1*b+n1); % output ------> b is optimization variable with real value
r1=@(a, b) a*r;------> a is optimization variable with complex value
rr =r1;
rr(1:2:end) = 0; % odd data of the symbol-----> objective
Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
The objective function must return a scalar number for the minimization algorithm to work. Instead of code, can you attach an image showing the mathematical formulation of your problem?
Soumili Sen
Soumili Sen 2020 年 10 月 31 日
yahh u are right,matlab shows an error like.............. "Supplied objective function must return a scalar value." how I can solve that.
Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
Can you show the mathematical formulation of your objective function. Currently I don't understand how is it defined.
Walter Roberson
Walter Roberson 2020 年 10 月 31 日
Separate the real part of the complex variables from the imaginary part. Return the norm of the expression.
Soumili Sen
Soumili Sen 2020 年 11 月 12 日
Thank you both of you.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProblem-Based Optimization Setup についてさらに検索

質問済み:

2020 年 10 月 31 日

コメント済み:

2020 年 11 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by