The easiest way to add the cost you want is by using direct specification of
legacy costs as described in Sections 6.3.3 and 7.1.3 in the User’s
Manual<https://matpower.org/docs/MATPOWER-manual-7.1.pdf>.
Something like …
define_constants;
mpc = loadcase('case33bw');
% -----Va------ ----Vm--- ---Pg---Qg---
mpc.N = [ sparse(33,33) speye(33) sparse(33, 2) ];
mpc.Cw = ones(33, 1);
% d rhat k m
mpc.fparm = ones(33, 1) * [ 1 1 0 1];
mpc.gencost(:, COST:COST+2) = 0; % zero out generator cost
r = runopf(mpc, mpopt);
I should also mention two other things:
* On a system with a single generator like this one, there are really no
available degrees of freedom for doing any dispatch optimization, so changing
the cost function may change the objective function value, but it will not
affect the dispatch.
* I suspect you actually want to minimize the square of the voltage
deviations from 1 (set d to 2), or at least minimize the negative of the cost
you indicate (set m to –10. Minimizing sum(v(i)-1) actually maximizes the
deviations of voltage from 1.
— Ray
On Nov 16, 2020, at 11:47 AM, Adjifack Nelson
<[email protected]<mailto:[email protected]>> wrote:
Good morning every body
I am trying to add a cost function to opf flow model minimizing voltage
difference. The added cost function is of the form sum(v(i)-1). I have tried to
impletent it using add_quad_cost but i have errors. I have included an image of
my matlab work space showing the error. With Q=[], c=-ones(33,1) and
k=ones(33,1).
Best regards
<Cap1.PNG>