0

I have a main program called loadflowthat computes quantities a,b,c and d using nested functions. I have to minimize loadflowusing 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.

K. Rmth
  • 217
  • 4
  • 12
  • [This](http://stackoverflow.com/questions/2730029/passing-functions-as-arguments-in-matlab) will tell you how to pass functions as arguments to other functions in MATLAB. – Roney Michael Mar 19 '13 at 07:48
  • this is for general cases but the GUI for GA only has a field where the function handle to the constraint is put. When I put @nestedfunction matlab gives me an "undefined function" error message. – K. Rmth Mar 19 '13 at 09:51
  • Sorry, but it's difficult to say much more without a glimpse at the code. – Roney Michael Mar 19 '13 at 09:59
  • on top of that GA usually has constraints for x when minimizing f(x) but here i'm minimizing f(x) and my constraints are in the form of g(x). – K. Rmth Mar 19 '13 at 10:20

0 Answers0