ClearAll["Global`*"];

n=3;
costCoefficients={{100,0.1,0.01},{50,0.15,0.015},{150,0.08,0.006}};
minMaxPowers={{100,400},{50,200},{200,1000}};

fCost[power_,{a_,b_,c_}]:=a+b*power+c*(power^2);

fCost[P,{1,2,3}]

powers=(Subscript[P, #])&/@Range[n]
cost=Plus@@MapThread[fCost,{powers,costCoefficients}]

fPowerConstrains[power_,{a_,b_}]:=a≤power≤b;
powerConstrains=MapThread[fPowerConstrains,{powers,minMaxPowers}]

desiredPower=500;
conditionOfDesiredPower={desiredPower==Plus@@powers}

condionsTogether=Union[powerConstrains,conditionOfDesiredPower]

NMinimize[Join[{cost},condionsTogether],powers]//Timing

Join[{cost},condionsTogether]

Plot[(((x-1.5))^2)*(2-(Tanh[(x-1)*300]-Tanh[(x-2)*300])),{x,0,3}]

slope=15;
ClearAll[fPenale]
fPenale[x_,{a_,b_}]:=(2+(-Tanh[slope*(x-a)]+Tanh[slope*(x-b)]))*(((x-0.5*(a+b)))^2);

Plot[fPenale[x,{20,40}],{x,10,50},PlotRange->All,PlotStyle->Thick,AxesLabel->{"x","penale"}]

penaltyTotalPower=100*(((desiredPower-Plus@@powers))^2);
penaltyPossiblePowers=Plus@@MapThread[fPenale,{powers,minMaxPowers}];

penaltyTotalPower

Fmin=cost+penaltyTotalPower+penaltyPossiblePowers

startOfTheSearch=minMaxPowers/.{a_,b_}:>((a+b)/2.)
start=Thread[{powers,startOfTheSearch}]
Quiet@FindMinimum[Fmin,start]//Timing