Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 586
zsha Avatar asked Oct 18 '25 11:10

zsha


1 Answers

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

like image 195
Matthew Gunn Avatar answered Oct 21 '25 05:10

Matthew Gunn