필터 지우기
필터 지우기

variable declaration for optimization

조회 수: 2 (최근 30일)
Soumili Sen
Soumili Sen 2020년 10월 31일
댓글: Soumili Sen 2020년 11월 12일
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일
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일
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
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개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by