I have a main program called loadflow
that computes quantities a,b,c and d
using nested functions. I have to minimize loadflow
using the simple GA in matlab. How can I pass the nested functions that compute a,b,c and d
as constraint to the GA?
function [ main ] = cost( DGvect )
%load variables like cap_factor,puload1 etc here
DGmat=reshape(10000*DGvect,6,[]);
CDG=sum((100*500*[1 2 3 7 9 10])*DGmat);
ODG=sum(87600*[4.5 4 5 5 1 0.5]*(DGmat.*repmat([.35 .55 .35 .4 .2 .25]',1,32)));
[Vbus,Il,Ploss]=loadflow((1.04^10)*puload1,cap_factor(2,:),DGmat);
CPE=CPV*abs(real(Il(1,1)))*8760*10.4e3;
CEL=Ploss*(10.4e3)*CPV*8760;
main=CDG+ODG+CPE+CEL;
end
There is a function with input arguments (Vbus,Il,Ploss) which return RIv,RIloss,RIflow and RIscc. I need that the RI's be <1 (constraint) for a candidate DGvect be a valid solution.