简体   繁体   中英

Optimization using lsqnonneg function of MATLAB

I have to find value of x that minimizes norm of C*exp(2x)-d subject to x >= 0. I am trying to solve this problem in MATLAB. Both C and d are defined as vectors of dimension 1x180. Does anyone have any hint or suggestion on how to solve this problem using lsqnonneg function(or some other technique) in MATLAB? If it was just x instead of exp(2x) it could easily be solved by lsqnonneg ! But because of exponential term in the problem I am not able to proceed further. I would appreciate suggestions.

First some math: Define y = exp(2*x) then the constraint x >=0 is equivalent to y >= 1 . An equivalent minimization problem then is:

minimize(over y) norm(c.*y - d)
     subject to  y >= 1

There are a number of ways to do this in MATLAB. One cool way is to use CVX, if you download the cvx convex optimization package, the code would be:

n = 180;
cvx_begin
variable y(n)
minimize(norm(c .* y - d))
subject to:
1 <= y
cvx_end

Then of course you can do x = log(y) / 2 to get the final value of x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM