How to maximize a constrained convex problem

I want find a positive semi-definite matrix whose maximum eigen value is maximized, subjected to diagonal entries begin 1 and some entries constrained to zero.

I’m getting an exception:
Disciplined convex programming error:
Cannot maximize a(n) convex expression.

Below is my code:

cvx_begin sdp
  variable Z(n,n) symmetric
  maximize (lambda_max(Z))
  subject to
    Z == semidefinite( n );
    for i=1:n

Thanks you.

As clearly stated in the CVX User’s Guide, lambda_max is convex. Given that you are trying to maximize a convex objective function, which is equivalent to minimizing a concave objective function, and your constraints are convex, your optimization problem is a (non-convex) concave programming problem, and hence can not be solved using CVX.

This can be a difficult problem to solve, and especially to provable global optimality. The non-smoothness of eigenvalue at eigenvalues with multiplicity > 1 can add to the challenge. Nevertheless, you might have success using something like a Quasi-Newton algorithm with SR1 updating (not constraining Hessian to be positive semi-definite). Having good starting values will help.