# [SciPy-user] lagrange multipliers in python

fdu.xiaojf@gmai... fdu.xiaojf@gmai...
Sun Jun 17 09:41:38 CDT 2007

Hi all,

First, I have to say thanks to so many kind people.

fdu.xiaojf@gmail.com wrote:
> Hi all,
>
> So much thanks for so many kind people.
>
> fdu.xiaojf@gmail.com wrote:
>> Hi all,
>>
>> Sorry for the cross-posting.
>>
>> I'm trying to find the minimum of a multivariate function F(x1, x2, ...,
>> xn) subject to multiple constraints G1(x1, x2, ..., xn) = 0, G2(...) =
>> 0, ..., Gm(...) = 0.
>
>    I'm sorry that I haven't fully stated my question correctly. There are
> still inequality constraints for my problem. All the variables(x1, x2, ...,
> xn) should be equal or bigger than 0.
>
>> The conventional way is to construct a dummy function Q,
>>
>> $$Q(X, \Lambda) = F(X) + \lambda_1 G1(X) + \lambda_2 G2(X) + ... + \lambda_m >> Gm(X)$$
>>
>> and then calculate the value of X and \Lambda when the gradient of function Q
>> equals 0.
>>
>> I think this is a routine work, so I want to know if there are available
>> functions in python(mainly scipy) to do this? Or maybe there is already
>> a better way in python?
>>
>>
>> Thanks a lot.
>

My last email was composed in a hurry, so let me describe my problem in
detail to make it clear.

I have to minimize a multivariate function F(x1, x2, ..., xn) subject to
multiple inequality constraints and equality constraints.

The number of variables(x1, x2, ..., xn) is 10 ~ 20, the number of
inequality constraints is the same with the number of variables( all
variables should be no less than 0). The number of equality constraints
is less than 8(mainly 4 or 5), and the equality constraints are linear.

My function is too complicated to get the expression of derivate easily, so
according to Joachim Dahl(dahl.joachim@gmail.com)'s post, it is probably
non-convex. But I think it's possible to calculate the first derivate
numerically.

I have tried scipy.optimize.fmin_l_bfgs_b(), which can handle bound constraints
but seems cannot handle equality constraints.

Mr. Markus Amann has kindly sent me a script written by him, which can
handle equality constraints and is easy to use. The method used by
Markus involves the calculation of Jacobian, which I don't
understand.(Sorry for my ignorance in this filed. My major is chemistry,
and I'm trying to learn some knowledge about numerical optimization.)
However, it seems that the script cannot handle inequality constraints.
(sorry if I was wrong).

I hope my bad English have described my problem clearly.

Any help will be greatly appreciated.

Best regards,

Xiao Jianfeng