Simulated annealing with equality constrainsts

I am trying to optimize objective function w1 profit(x) + w2 * risk(x)*, where x is decision variable and has an equality constraint like sum(x) = C. I have to use simulated annealing to solve this problem. I am curious if equality constraint can be implemented in CVX when using simulated annealing as Matlab only allow bound constraints in this case. I shall appreciate any help in this regard.

If you have to use simulated annealing, (I leave it to you why you “have to”), then CVX is not the right tool for you. CVX can handle linear (affine) equality constraints, but CVX does not do simulated annealing, and can only accept convex problems which follow its (DCP) rules.

Read Why isn’t CVX accepting my model? READ THIS FIRST! and the CVX Users’ Guide http://cvxr.com/cvx/doc/

Nevertheless, if sum(x) = C is your only constraint, perhaps you can reduce the dimension of x by 1 and solve for one of the x components in terms of the others.