I have a convex function that would be written in matlab as
f(x) = sum( a.*exp(b.*x) );
where a is a vector of non-negative reals, b is a vector of reals (more often than not negative), and x is a vector of reals. From the composition rules, this is convex, as it is the sum of positive scalars times convex functions.
I would like to minimize f subject to the constraint
c(x) - C <= 0
c(x) = c_0 * sum( exp( x) );
where c_0 and C are specified positive constants. My question is related to syntax, how can I write element wise multiplication like I have for f?
I have been using fmincon for this, but would like to move away from requiring the optimization toolbox, both because I have convexity I should be able to exploit and because I want something open source.
I have a minimal working example, which shows fmincon beating CVX, and given the problem is convex, I don’t think this should be the case, thus I suspect I have gotten something wrong syntactically.
One note: this is a toy version, in practice x is much larger, and I don’t know its length in advance, I only receive a and b which are of the same length and obey the rules I mentioned previously. So for any final solution i could not write something like
sum( a(1)*exp(b(1)*x(1)) + a(2)*exp(b(2)*x(2)) )
a = 1.0e-04 * [0.9, 0.05, 0.04];
b = [ -11.1 -5.11 -5.05 ];
n = numel(a);
c_0 = 2; C = 2;
minimize sum( aexp(bx) )
c_0 * sum(exp(x)) - C <= 0
x_cvx = x’;
f = @(x) fM(x,a,b);
c = @(x) cM(x,c_0,C);
[x,fval] = fmincon( f, zeros(size(a)),,,,,,,c);
x_fmincon = x;
f(x_cvx) % This gives 0.153158
f(x_fmincon) % This gives 0.05774
% functions for passing anonymously to fmincon
function [f,fx] = fM(x,a,b)
f = sum( a.* exp(b.*x) );
if nargout >1
fx = a .b . exp( b.*x);
function [c,ceq] = cM(x,c0,C)
c = c0 * sum( exp( x) ) - C;
ceq = ;