variable declaration for optimization
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Soumili Sen
am 31 Okt. 2020
Kommentiert: Soumili Sen
am 12 Nov. 2020
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 Kommentare
Walter Roberson
am 31 Okt. 2020
You do not define variables for solver based optimization: you define a function that accepts a vector of values.
Akzeptierte Antwort
Ameer Hamza
am 31 Okt. 2020
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 Kommentare
Walter Roberson
am 31 Okt. 2020
Separate the real part of the complex variables from the imaginary part. Return the norm of the expression.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!