How to solve optimization with a decision variables (they are elements in vector )?
3 views (last 30 days)
Show older comments
Hi,Everyone!! I have a problem of Optimization.
My code is following:
Total= SAR(weight,phase,Amplitude)
Total=0;
for i=1:4
Total=Total+weight(i).*Amplitude(:,i)*exp(1j*phase(i));
end
end
where weight is [weight1 weight2 weight3 weight4].
My Objective function is a summation by 4 parts : Total = element1+element2+element3+element4,I use a for loop to sum them up. Each element is presented by weight*Amplitude*exp(1j*phase).
As the last statement, I use for loop, and use weight equal to [weight1 weight2 weight3 weight4] to present weight1 to weight4, now I want to optimize my Objective function - Total and decision variable is only weight (equal to [weight1 weight2 weight3 weight4]),others(Amplitude and Phase are fixed),
both of them (weight1 ~ weight4)from 0~2,but when I run it,there are 2 errors showed on the command Window -
"Error using fminbnd (line 110) Argument 4 must be an options structure."
"Error in Optimization (line 38) [weight,fval]=fminbnd(@SAR,0,2,weight,options);"
Mainly,I am not sure of the problems of the options structure now,I am studying for MATLAB options structure now, but I want to discuss with my optimization work at the same time, so I ask the question here.
If anyone find out my problems,tell me,please.
Thanks a lot.
0 Comments
Answers (1)
Matt J
on 16 May 2018
Edited: Matt J
on 16 May 2018
You have multiple problems.
First, fminbnd can only be used on problems with a single unknown, whereas you have four. You could consider a different solver, e.g. fmincon orlsqnonlin, which handles multiple unknowns.
Second, your objective function is complex valued. Perhaps you meant to take its norm^2.
Third, your call to fminbnd
[weight,fval]=fminbnd(@SAR,0,2,weight,options)
does not follow the syntax rules in the fminbnd documentation. You have "options" as the fifth input argument, whereas it should be the fourth (as the error message is telling you). It is not clear why you are passing "weight" as the fourth argument and where it comes from.
And finally, you have fixed known parameters for SAR (phase and Amplitude) which should be passed using nested or anonymous functions.
4 Comments
Matt J
on 17 May 2018
Edited: Matt J
on 17 May 2018
fminsearch won't be the best option if you have access to the full optimization toolbox. It isn't theoretically guaranteed to work for more than one unknown variable, even if empirically it often does well for small multi-variable problems. It also doesn't let you specify bound constraints, although you could get around that by downloading fminsearchbnd.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!