I want to pass my optimization variable to a Matlab function to evaluate the objective that I want to minimize. For example
cvx_begin
variable x(n) % My vaiable
Energy = Calculate(x,...) % Mttlab function to evaluate the objective function to be evaluated based on the variable x
minimize(Energy)
subject to
0 <= x <= 1
cvx_end
I read the two topics topic1topic2 but is not exactly what I want to do. I appreciate if you can help. Thanks.
Thanks so much for your help. This is what I want. I need to modify my function to match the CVX rules. Now I have an exponential term to be calculated based on the value of x inside the function. How I should write it p_n = b_n*exp(\frac{a*B_n*f_n}{(t_n*f_n - (A_n*x*C_n)) - 1});
Should I write the expression inside a cvx_begin cvx_end as an unconstrainted optimization?
Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {positive constant} ./ {real affine}
Error in ./ (line 19)
z = times( x, y, ‘./’ );
Error in * (line 36)
z = feval( oper, x, y );
Error in / (line 15)
z = mtimes( x, y, ‘rdivide’ );
Thanks for your help. I have other assumptions on the values so I am sure it is convex. I used your suggestion inv_pos and it works but I have another expression
For the first term, I have a,B_n,f_n,t_n,f_n,A_n,x,C_n >0 and the term t_n f_n - A_n x C_n > 0.
For the second term I have a,B_{n'},f_{n'},t_{n'},f_{n'},A_{n'},x,C_{n'} >0 and the term t_{n'} f_{n'} - A_{n'} x C_{n'}> 0 and the term \exp(\frac{aB_{n'}f_{n'}}{t_{n'} f_{n'}- (A_{n'}xC_{n'})} ) - 1 represents the power in my formulation and I have a constraint that it is greater than zero. I wrote the complete proof for the convexity.
I can’t understand your proof. I don’t know how to express even when it is covex. Let’s consider some very simple cases, try express exp(1/x)*(exp(1/x)-1) first, then exp(1/x)*(exp(1/(x+1))-1).
I meaned I can’t even figure out how to express something simple like exp(1/x)*(exp(1/x)-1), let alone b_{n'}*\exp(\frac{a*B_n*f_n}{(t_n*f_n - (A_n*x*C_n))})*(\exp(\frac{a*B_{n'}*f_{n'}}{(t_{n'}*f_{n'} - (A_{n'}*x*C_{n'}))}) - 1)