MATLAB: Optimization using fmincon where objective function includes the lagrange multiplier

fminconlagrange multiplierMATLAB

my objective function is to maximize sum_i(log(1-lambda(yi-xi*beta))) with respect to beta subject to the constraint sum_i(yi-xi*beta)=0. My problem is lambda in the objective function is the lagrange multiplier of the constraint. How can I set the fmincon optimization then?
whenever I call the objective function there comes an error asking for values of lambda.

Best Answer

It's not clear how lambda can be "the Lagrange multiplier of the constraint" when it is a parameter of your objective function. As this parameter changes, so does the required Lagrange multiplier, and there is no certainty those 2 values would ever coincide.
Possibly, you're trying to solve the following problem in the unknowns beta and c?
min.
f(beta,c) = -sum_i(log(1-c*(yi-xi*beta)))
s.t.
g(beta,c) = sum_i(yi-xi*beta)=0
grad_wrt_beta f(beta,c)+ c * grad_wrt_beta g(beta,c) =0
Anyway, this is sounding like one of those situations where it would be wise to explain why the heck you want to do this.
Related Question