1. The problem statement I'm stuck with this problem which does not yield a solution. I feel as if I'm not formulating it correctly. Here it is described below. I've also written down the equations as they're easier to be read (attachment) This is something that I was doing with batteries and thought of using Lagrange multipliers. I have N energy cell or some sort (fuel cell, battery etc.) with different capacities. The basic problem is how to control a multitude of energy sources to meet the power demand. e.g. cell 1, 2, and 3 can each provide 50 Watts each but the cost of each cell is $1/Watt, $3/Watt, and $1.5/Watt and a total power demand of 120 Watts is needs which can fluctuate over time. Assume that I can control the cells using an internal switch of some sort and I use a control variable alpha where 0 <= alpha<= 1 (unitless) which can control the output power of each cell. At the end I need to find the Total cost and the values of alpha_i Generalizing: The i_th energy cell capable of providing a total power of Pi. Power_demand= alpha1*P1 + alpha2*P2 + ...+ alphaN*PN where 0 <= alpha_i <= 1.0 (unitless) The cost needs to be minimized where: Total_cost= C1*alpha1*P1 + C2*alpha2*P2 + ... + CN*alphaN*PN where Ci= Dollars/ Watt 2. Relevant equations Minimize cost function 'Total_cost' subject to constraint Power_demand Define Lagrangian as L= (C1*alpha1*P1 + C2*alpha2*P2 + ... + CN*alphaN*PN) + LAMBDA*(alpha1*P1 + alpha2*P2 + ...+ alphaN*PN ) 3. The attempt at a solution partial_L/partial_alpha_i = Pi+ LAMBDA*Pi partial_L/partial_LAMBDA = alpha1*P1 + alpha2*P2 + ...+ alphaN*PN - Power_demand Set first derivatives to zero: Pi= 0 or LAMBDA= -Ci and alpha1*P1 + alpha2*P2 + ...+ alphaN*PN - Power_demand This does not yield any meaningful result as power can't be 0. Can anyone help with this? Am I not formulating the problem correctly?