problem using caseformat

2017-07-15 Thread Roshani Thapa
i am using matpower in matlab to determine optimal switching schedule for
feeder capacitors using GA optimisation based on 24 hours dayahead
forecasted load profile for every bus load. the objective fxn is
minimisation of I2R loss, subjected to voltage constraint (ie bus voltage
should lie within a dead band) and the switching operation should be less
than 7 times a day for each capacitor.load profile is a 30*48 (bus hourly
active,reactive load) read from xlsx file. my network has 6
capacitors,hence my decision variable should be a string of 6*24=144 switch
status, representing 24 status of switch for each capacitor in each hour of
a day.

To test the code i am supposing 100% loading of all the bus loads
throughout the day thus imposing a constant load on the substation
transformer all day. this means the result of optimisation should be
theoritically constant switch status of all feeder capacitors all day (as
load hasn't changed). after running the GA optimisation the result shows
change in switch status of capacitors (though within the constraint) which
i beieve should be same all day as the loading is constant at every bus
throughout the day.

I even tried all loads operating at pf 1 all day; still it shows several
switchings of capacitors which i beleive should have been at status '0' for
pf 1.

Has the caseformat i used contained any bug? Please suggest. I have also
attached the the zip file with this post.

%%case30bus
function mpc = case30original(hr, cap1, cap2, cap3, cap4, cap5, cap6)
if cap1==1
  c1=0.6;
else c1=0;
end
if cap2==1
  c2=0.6;
else c2=0;
end
if cap3==1
  c3=0.6;
else c3=0;
end
if cap4==1
  c4=0.3;
else c4=0;
end
if cap5==1
  c5=0.9;
else c5=0;
end
if cap6==1
  c6=0.9;
else c6=0;
end
%% Read Load Profile
global lp;
%% MATPOWER Case Format : Version 2
mpc.version = '2';
%%-  Power Flow Data  -%%
%% system MVA base
mpc.baseMVA = 100;
%% bus data
%   bus_i   typePd  Qd  Gs  Bs  areaVm  Va  
baseKV  zoneVmaxVmin
mpc.bus = [
1 2 0 0 0 0 1 1 0 23 1 1.2 0.6;
  2 1 lp(2,2*hr-1) lp(2,2*hr)-c1 0 0 1 1 0 23 1 1.2 0.6;
  3 1 0 0 0 0 1 1 0 23 1 1.2 0.6;
  4 1 lp(4,2*hr-1) lp(4,2*hr) 0 0 1 1 0 23 1 1.2 0.6;
  5 1 0 0 0 0 1 1 0 23 1 1.2 0.6;
  6 1 0 0 0 0 1 1 0 23 1 1.2 0.6;
  7 1 0 0 0 0 1 1 0 23 1 1.2 0.6;
  8 1 0 0 0 0 1 1 0 23 1 1.2 0.6;
  9 1 lp(9,2*hr-1) lp(9,2*hr) 0 0 1 1 0 23 1 1.2 0.6;
  10 1 0 0 0 0 3 1 0 23 1 1.2 0.6;
  11 1 lp(11,2*hr-1) lp(11,2*hr) 0 0 1 1 0 23 1 1.2 0.6;
  12 1 lp(12,2*hr-1) lp(12,2*hr) 0 0 2 1 0 23 1 1.2 0.6;
  13 1 lp(13,2*hr-1) lp(13,2*hr)-c2 0 0 2 1 0 23 1 1.2 0.6;
  14 1 lp(14,2*hr-1) lp(14,2*hr) 0 0 2 1 0 23 1 1.2 0.6;
  15 1 lp(15,2*hr-1) lp(15,2*hr)-c3 0 0 2 1 0 23 1 1.2 0.6;
  16 1 lp(16,2*hr-1) lp(16,2*hr) 0 0 2 1 0 23 1 1.2 0.6;
  17 1 lp(17,2*hr-1) lp(17,2*hr) 0 0 2 1 0 23 1 1.2 0.6;
  18 1 lp(18,2*hr-1) lp(18,2*hr) 0 0 2 1 0 23 1 1.2 0.6;
  19 1 lp(19,2*hr-1) lp(19,2*hr)-c4 0 0 2 1 0 23 1 1.2 0.6;
  20 1 lp(20,2*hr-1) lp(20,2*hr) 0 0 2 1 0 23 1 1.2 0.6;
  21 1 lp(21,2*hr-1) lp(21,2*hr) 0 0 3 1 0 23 1 1.2 0.6;
  22 1 lp(22,2*hr-1) lp(22,2*hr) 0 0 3 1 0 23 1 1.2 0.6;
  23 1 0 0-c5 0 0 2 1 0 23 1 1.2 0.6;
  24 1 lp(24,2*hr-1) lp(24,2*hr) 0 0 3 1 0 23 1 1.2 0.6;
  25 1 lp(25,2*hr-1) lp(25,2*hr)-c6 0 0 3 1 0 23 1 1.2 0.6;
  26 1 lp(26,2*hr-1) lp(26,2*hr) 0 0 3 1 0 23 1 1.2 0.6;
  27 1 lp(27,2*hr-1) lp(27,2*hr) 0 0 3 1 0 23 1 1.2 0.6;
  28 1 lp(28,2*hr-1) lp(28,2*hr) 0 0 1 1 0 23 1 1.2 0.6;
  29 1 lp(29,2*hr-1) lp(29,2*hr) 0 0 3 1 0 23 1 1.2 0.6;
  30 1 lp(30,2*hr-1) lp(30,2*hr) 0 0 3 1 0 23 1 1.2 0.6
  ];
%% generator data
%   bus Pg  Qg  QmaxQminVg  mBase   status  Pmax
PminPc1 Pc2 Qc1min  Qc1max  Qc2min  Qc2max  ramp_agcramp_10 
ramp_30 ramp_q  apf
  mpc.gen=[
  1 15 0 0 0 1 100 1 1 0 0 0 0 0 0 0 0 0 0 0 0;
  %22 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
  %28 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
  %27 26.91 0 48.7 -15 1 100 0 55 0 0 0 0 0 0 0 0 0 0 0 0;
  %23 19.2 0 40 -10 1 100 0 30 0 0 0 0 0 0 0 0 0 0 0 0;
  %13 37 0 44.7 -15 1 100 0 40 0 0 0 0 0 0 0 0 0 0 0 0;
  ];
%% branch data
%   fbustbusr   x   b   rateA   rateB   rateC   ratio   
angle   status  angmin  angmax
mpc.branch=[
  1 2 0.11 0.32 0 130 130 130 1 0 1 -360 360;
 2 3 0.07 0.07 0 130 130 130 0 0 1 -360 360;
 3 4 0.22 0.19 0 65 65 65 0 0 1 -360 360;
 4 5 0.10 0.09 0 130 130 130 0 0 1 -360 360;
 5 6 0.31 0.18 0 130 130 130 0 0 1 -360 360;
 6 7 0.26 0.14 0 65 65 65 0 0 1 -360 360;
 7 8 0.26 0.14 0 90 90 90 0 0 1 -360 360;
 8 9 0.25 0.14 0 70 70 70 0 0 1 -360 360;
 9 10 0.25 0.14 0 130 130 130 0 0 1 -360 360;
 10 11 0.75 0.42 0 32 32 32 0 0 1 -360 360;
 11 12 0.35 0.2 0 65 65 65 0 0 1 -360 360;
 12 13 0.14 0.08 0 32 32 32 0 0 1 -360 360;
 13 14 0.29 0.16 0 65 65 65 0 0 1 -360 360;
 8 15 0.09 0.08 0 65 65 65 0 0 1 -360 360;
 15 16 0.14 0.08 0 65 65 65 0 0 1 -360 360;
 16 17 0.25 0.14 0 65 65 65 0 0 1 -360 360;
 6 18 0.09 0.14 0 32 32 32 0 

Re: Objective Functions

2017-07-15 Thread Abhyankar, Shrirang G.
MATPOWER supports two types of generator cost curves: quadratic and piece-wise 
linear. I don’t think there is support for user-defined cost curves, Ray would 
be able to provide a more definitive answer. So, I think there is an no easy 
way to implement the objective you need. You’ll need to modify the MATPOWER 
code in order to implement what you want and there may be substantial coding 
you may need to do.

Shri

From:  on behalf of Akash Tyagi 

Reply-To: MATPOWER discussion forum 
Date: Saturday, July 15, 2017 at 8:10 AM
To: MATPOWER discussion forum 
Subject: Re: Objective Functions

Yeah,
Thanks so much sir.
Do you have any idea of how of to add valve point effect in the mpc.gencost 
data?
Presently, our Objective function is mainly a*P^2+b*P+c.
But if we want to include the valve point effect i.e. 
a*P(i)^2+b*P(i)+c+abs(e(i)*sin(f(i)(Pmin(i)-P(i))).
Can this be added in the MATPOWER??

On Sat, Jul 15, 2017 at 6:25 PM, Sarmad Hanif 
mailto:sarmad.ha...@tum-create.edu.sg>> wrote:
I would not say real power minimization, I think it is better to say active 
power cost minimization.
From: 
bounce-121659167-74036...@list.cornell.edu
 
[mailto:bounce-121659167-74036...@list.cornell.edu]
 On Behalf Of Akash Tyagi
Sent: Saturday, 15 July, 2017 8:51 PM

To: MATPOWER discussion forum
Subject: Re: Objective Functions

Thanks a lot.
It is working now.
The last thing I want to ask is if we don't add reactive cost data to case, 
then it is considering only the real power minimization??

On Sat, Jul 15, 2017 at 6:01 PM, Sarmad Hanif 
mailto:sarmad.ha...@tum-create.edu.sg>> wrote:
From Generator Cost Data table of the MATPOWER manual:
“If gen has ng rows, then the first ng rows of gencost contain the costs for 
active power produced by the
corresponding generators. If gencost has 2ng rows, then rows ng + 1 through 2ng 
contain the reactive
power costs in the same format.”

Since there are only active power cost terms in the case file and you have put 
all active power cost terms to zero, your cost function will evaluate to zero.
First add reactive power cost term rows and then specify their marginal values 
to be able for MATPOWER to consider them.
Hope it helps.
Sarmad

From: 
bounce-121659136-74036...@list.cornell.edu
 
[mailto:bounce-121659136-74036...@list.cornell.edu]
 On Behalf Of Akash Tyagi
Sent: Saturday, 15 July, 2017 7:46 PM

To: MATPOWER discussion forum
Subject: Re: Objective Functions

After putting the cost term of the real power to zero in the mpc.gencost field, 
as attached the case below-
Then after running the optimal power flow by using the following code-
clc
clear
close all;
define_constants;
mpc=loadcase(newcase5);
results=runopf(mpc);
The objective function is coming zero.??
I am not getting this??

On Sat, Jul 15, 2017 at 10:19 AM, Sarmad Hanif 
mailto:sarmad.ha...@tum-create.edu.sg>> wrote:
Hi,
Mr. Kardos already gave the references for you to explore the cost functions in 
detail.
A quick fix:
If you just want to minimize reactive power, then just put cost terms of the 
real power to zero in its approriate mpc.gencost field ☺

Btw, minimizing objective function can mean anything, as it depends on your 
“function”. It cannot always mean considering only the reactive power, as you 
mentioned in your previous email.

Thanks,
Sarmad

From: 
bounce-121652404-74036...@list.cornell.edu
 
[mailto:bounce-121652404-74036...@list.cornell.edu]
 On Behalf Of Akash Tyagi
Sent: Wednesday, 12 July, 2017 4:59 PM
To: MATPOWER discussion forum
Subject: Re: Objective Functions

Hello,
The obj_func mainly minimizes the cost including the real and reactive power.
But I have to only minimize objective function i.e. cost considering only the 
reactive power.
I tried the way explained by you above but I am not able to do this.?
Can you help?
basically, my goal is to change the objective function.
Thanks

On Wed, Jul 12, 2017 at 1:49 PM, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:
ok, thanks

On Wed, Jul 12, 2017 at 1:40 PM, Kardoš Juraj 
mailto:juraj.kar...@usi.ch>> wrote:
Try to have a look in the code in opf_costfcn.m and compare it with the 
objective function definition in the manual 
(http://www.pserc.cornell.edu/matpower/manual.pdf) section 6.1 equation (6.6). 
You will find the function implemented in the code, as well as its gradient and 
Hessian w.r.t. vector x (equation 6.5). If you have problems with derivatives, 
have a look at section 6 in this document 
http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf. It describes how 
the first and second derivatives can be computed. Good luck!
==
Juraj Kardos
Advanced Computing Laboratory
Institute of Computational S

Re: Get_losses

2017-07-15 Thread Abhyankar, Shrirang G.
dloss_dv is the partial derivative of the losses w.r.t. voltage angle. It is an 
optional output argument. If you do not need it then don’t use it.

FYI: MATPOWER has an online function 
reference where you can see 
the usage of all of its functions. Suggest going through this first and then 
sending questions to the list if something is not clear. Here’s the reference 
for the 
get_losses
 function.

Shri

From:  on behalf of Akash Tyagi 

Reply-To: MATPOWER discussion forum 
Date: Saturday, July 15, 2017 at 2:04 AM
To: MATPOWER discussion forum 
Subject: Get_losses

Hello everyone, I am trying to use get_losses command and it's quite easy but i 
am not getting one thing in that command,
mpc=loadcase(case5);
results=runpf(mpc);
[loss,fchg,tchg,dloss_dv]=get_losses(results);
what is 'dloss_dv' given means??



Re: Compare case

2017-07-15 Thread Abhyankar, Shrirang G.
compare_case() cannot be used on two different networks. It compares the 
runpf() (or runopf()) outputs for two different scenarios on the “same” network.

For example,
mpc1 = runpf(‘case9’);% run power flow on 9-bus network
mpc2 = loadcase(‘case9’);% load 9-bus network
mpc2.branch(8,11) = 0;  % Turn off branch 8-9
mpc2 = runpf(mpc2);   % run power flow on the modified 9-bus network
compare_case(mpc1,mpc2);   TCL MERGE ERROR ( 07/15/2017 11:42:22 ): "invalid 
command name "compare""
OutmailID: 121659301, List: 'matpower-l', MemberID: 75174736
SCRIPT: "compare the power flow outputs
 
   --  --  --  -
 matrix / col case 1  case 2difference row
   --  --  --  -
 bus
   VM  0.9576210.890468   0.0671533  9
   VA   9.66874 31.9688 22.3001  2 *
 
 gen
   PG   71.9547 81.1538 9.19907  1
   QG24.069 84.4959 60.4269  1 *
 
 branch
   BR_STATUS  1   0   1  8
   PF   86.5044   0 86.5044  8 *
   QF24.069 84.4959 60.4269  1
   PT   76.4956 163 86.5044  6
   QT   -20.753  -76.59 55.8369  1
 
 compare_case() results show the non-zero differences in the bus, gen, and 
branch arrays.
 
 Shri
 
 From:  on behalf of Akash Tyagi 

 Reply-To: MATPOWER discussion forum 
 Date: Saturday, July 15, 2017 at 1:33 AM
 To: MATPOWER discussion forum 
 Subject: Compare case
 
 hello to everyone,
 I am studying the compare_case function and while I am comparing the two case 
i.e. case5 and case9 by using the following command-
 mpc1=loadcase(case5);
 mpc2=loadcase(case9);
 compare_case(mpc1,mpc2)
 It is giving the following error-
 Error using  -
 Matrix dimensions must agree.
 
 Error in compare_case (line 127)
 [temp, i] = max(abs(bus1(:, 1:Nb) - bus2(:, 1:Nb)));
 
 How this function used??
 
  --_000_0C01F930478B4F6EB4E7AE908094027Canlgov_ Content-Type: text/html;   
charset="utf-8" Content-ID: 
 
Content-Transfer-Encoding: base64  http://schemas.microsoft.com/office/2004/12/omml"; 
xmlns="http://www.w3.org/TR/REC-html40";>
 
 
 
 
 
 
 
 
 
 compare_case() cannot be used 
on two different networks. It compares the runpf() (or runopf()) outputs for 
two different scenarios on the “same” network.
  
 For 
example,
 mpc1 = runpf(‘case9’);  
  % run power flow on 9-bus 
network
 mpc2 = loadcase(‘case9’);  
  % load 9-bus network
 mpc2.branch(8,11) = 0;  % 
Turn off branch 8-9
 
 mpc2 = runpf(mpc2); 
  % run power flow on the modified 9-bus network
 compare_case(mpc1,mpc2); 
  "
 compare the power flow outputs
 
  
--  --  --  
-
matrix / 
col case 
1  case 
2    difference 
row

  
--  --  --  
-
bus
  
VM 
 0.957621    
0.890468   
0.0671533  9
  
VA  
 9.66874    
 31.9688 
22.3001  2 *
 
gen
  
PG  
 71.9547 
81.1538 
9.19907  1
  
QG   
 24.069 
84.4959 
60.4269  1 *
 
branch
  
BR_STATUS 
 
1  
 
0  
 1  8
  
PF  
 
86.5044  
 0 
86.5044  8 *
  
QF   
 24.069 
84.4959 
60.4269  1
  
PT  
 
76.4956 
163 
86.5044  6
  
QT  
 -20.753  
-76.59

Re: multi-period AC Power Flow (not OPF)

2017-07-15 Thread Abhyankar, Shrirang G.
Using a loop would be the easiest way. Alternately, you could concatenate all 
the mpc bus, gen, etc. arrays into one giant mpc case and then solve it via a 
single runpf(). However, this is more complicated (changing of bus,gen, branch 
numbers for the later time-steps) compared to using a loop.

Shri

From:  on behalf of Sarmad Hanif 

Reply-To: MATPOWER discussion forum 
Date: Friday, July 14, 2017 at 11:52 PM
To: "matpowe...@list.cornell.edu" 
Subject: multi-period AC Power Flow (not OPF)

Dear all,
Just a quick question, I am running a simple loop to run an AC power flow with 
changing P,Q (loads) and (P,V) generator values at each step.
Is there a procedure to do it in one shot ?

Best,
Sarmad

M.Sc. Sarmad Hanif
Research Associate, ESTL – Electrification Suite and Test Lab
TUM CREATE Ltd.
1 CREATE Way, #10-02, CREATE Tower, Singapore 138602
T: +65 905 333 25
W: www.tum-create.edu.sg






Re: Objective Functions

2017-07-15 Thread Akash Tyagi
Yeah,
Thanks so much sir.
Do you have any idea of how of to add valve point effect in the mpc.gencost
data?
Presently, our Objective function is mainly a*P^2+b*P+c.
But if we want to include the valve point effect i.e.
a*P(i)^2+b*P(i)+c+abs(e(i)*sin(f(i)(Pmin(i)-P(i))).
Can this be added in the MATPOWER??

On Sat, Jul 15, 2017 at 6:25 PM, Sarmad Hanif <
sarmad.ha...@tum-create.edu.sg> wrote:

> I would not say real power minimization, I think it is better to say
> active power cost minimization.
>
> *From:* bounce-121659167-74036...@list.cornell.edu [mailto:
> bounce-121659167-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Saturday, 15 July, 2017 8:51 PM
>
> *To:* MATPOWER discussion forum
> *Subject:* Re: Objective Functions
>
>
>
> Thanks a lot.
>
> It is working now.
>
> The last thing I want to ask is if we don't add reactive cost data to
> case, then it is considering only the real power minimization??
>
>
>
> On Sat, Jul 15, 2017 at 6:01 PM, Sarmad Hanif <
> sarmad.ha...@tum-create.edu.sg> wrote:
>
> From Generator Cost Data table of the MATPOWER manual:
>
> “If gen has ng rows, then the first ng rows of gencost contain the costs
> for active power produced by the
>
> corresponding generators. If gencost has 2ng rows, then rows ng + 1
> through 2ng contain the reactive
>
> power costs in the same format.”
>
>
>
> Since there are only active power cost terms in the case file and you have
> put all active power cost terms to zero, your cost function will evaluate
> to zero.
>
> First add reactive power cost term rows and then specify their marginal
> values to be able for MATPOWER to consider them.
>
> Hope it helps.
>
> Sarmad
>
>
>
> *From:* bounce-121659136-74036...@list.cornell.edu [mailto:
> bounce-121659136-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Saturday, 15 July, 2017 7:46 PM
>
>
> *To:* MATPOWER discussion forum
> *Subject:* Re: Objective Functions
>
>
>
> After putting the cost term of the real power to zero in the mpc.gencost
> field, as attached the case below-
>
> Then after running the optimal power flow by using the following code-
>
> clc
>
> clear
>
> close all;
>
> define_constants;
>
> mpc=loadcase(newcase5);
>
> results=runopf(mpc);
>
> The objective function is coming zero.??
>
> I am not getting this??
>
>
>
> On Sat, Jul 15, 2017 at 10:19 AM, Sarmad Hanif <
> sarmad.ha...@tum-create.edu.sg> wrote:
>
> Hi,
>
> Mr. Kardos already gave the references for you to explore the cost
> functions in detail.
>
> A quick fix:
>
> If you just want to minimize reactive power, then just put cost terms of
> the real power to zero in its approriate mpc.gencost field J
>
>
>
> Btw, minimizing objective function can mean anything, as it depends on
> your “function”. It cannot always mean considering only the reactive power,
> as you mentioned in your previous email.
>
>
>
> Thanks,
>
> Sarmad
>
>
>
> *From:* bounce-121652404-74036...@list.cornell.edu [mailto:
> bounce-121652404-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Wednesday, 12 July, 2017 4:59 PM
> *To:* MATPOWER discussion forum
> *Subject:* Re: Objective Functions
>
>
>
> Hello,
>
> The obj_func mainly minimizes the cost including the real and reactive
> power.
>
> But I have to only minimize objective function i.e. cost considering only
> the reactive power.
>
> I tried the way explained by you above but I am not able to do this.?
>
> Can you help?
>
> basically, my goal is to change the objective function.
>
> Thanks
>
>
>
> On Wed, Jul 12, 2017 at 1:49 PM, Akash Tyagi 
> wrote:
>
> ok, thanks
>
>
>
> On Wed, Jul 12, 2017 at 1:40 PM, Kardoš Juraj  wrote:
>
> Try to have a look in the code in opf_costfcn.m and compare it with the
> objective function definition in the manual (http://www.pserc.cornell.edu/
> matpower/manual.pdf) section 6.1 equation (6.6). You will find the
> function implemented in the code, as well as its gradient and Hessian
> w.r.t. vector x (equation 6.5). If you have problems with derivatives, have
> a look at section 6 in this document http://www.pserc.
> cornell.edu/matpower/TN2-OPF-Derivatives.pdf. It describes how the first
> and second derivatives can be computed. Good luck!
>
> ==
> Juraj Kardos
> Advanced Computing Laboratory
> Institute of Computational Science
> Universita della Svizzera italiana
> Via Giuseppe Buffi 13
> Lugano 6904
> Switzerland
> http://www.ics.inf.usi.ch
> ===
>
>
>
> On 12 Jul 2017, at 09:46, Akash Tyagi  wrote:
>
>
>
> Can you explain me through simple example.?
>
>
>
> On Wed, Jul 12, 2017 at 1:09 PM, Kardoš Juraj  wrote:
>
> Hello,
>
>
>
> as far as I know, you can define arbitrary objective function by modifying
> the following source file: opf_costfcn.m. Don’t forget that you need to
> provide gradient and Hessian w.r.t. OPF control variables as well. These
> derivations are used in optimizers to find the optimal solution.
>
>
>
> Best regards,
>
>
>
> ==

RE: Objective Functions

2017-07-15 Thread Sarmad Hanif
I would not say real power minimization, I think it is better to say active 
power cost minimization.
From: bounce-121659167-74036...@list.cornell.edu 
[mailto:bounce-121659167-74036...@list.cornell.edu] On Behalf Of Akash Tyagi
Sent: Saturday, 15 July, 2017 8:51 PM
To: MATPOWER discussion forum
Subject: Re: Objective Functions

Thanks a lot.
It is working now.
The last thing I want to ask is if we don't add reactive cost data to case, 
then it is considering only the real power minimization??

On Sat, Jul 15, 2017 at 6:01 PM, Sarmad Hanif 
mailto:sarmad.ha...@tum-create.edu.sg>> wrote:
From Generator Cost Data table of the MATPOWER manual:
“If gen has ng rows, then the first ng rows of gencost contain the costs for 
active power produced by the
corresponding generators. If gencost has 2ng rows, then rows ng + 1 through 2ng 
contain the reactive
power costs in the same format.”

Since there are only active power cost terms in the case file and you have put 
all active power cost terms to zero, your cost function will evaluate to zero.
First add reactive power cost term rows and then specify their marginal values 
to be able for MATPOWER to consider them.
Hope it helps.
Sarmad

From: 
bounce-121659136-74036...@list.cornell.edu
 
[mailto:bounce-121659136-74036...@list.cornell.edu]
 On Behalf Of Akash Tyagi
Sent: Saturday, 15 July, 2017 7:46 PM

To: MATPOWER discussion forum
Subject: Re: Objective Functions

After putting the cost term of the real power to zero in the mpc.gencost field, 
as attached the case below-
Then after running the optimal power flow by using the following code-
clc
clear
close all;
define_constants;
mpc=loadcase(newcase5);
results=runopf(mpc);
The objective function is coming zero.??
I am not getting this??

On Sat, Jul 15, 2017 at 10:19 AM, Sarmad Hanif 
mailto:sarmad.ha...@tum-create.edu.sg>> wrote:
Hi,
Mr. Kardos already gave the references for you to explore the cost functions in 
detail.
A quick fix:
If you just want to minimize reactive power, then just put cost terms of the 
real power to zero in its approriate mpc.gencost field ☺

Btw, minimizing objective function can mean anything, as it depends on your 
“function”. It cannot always mean considering only the reactive power, as you 
mentioned in your previous email.

Thanks,
Sarmad

From: 
bounce-121652404-74036...@list.cornell.edu
 
[mailto:bounce-121652404-74036...@list.cornell.edu]
 On Behalf Of Akash Tyagi
Sent: Wednesday, 12 July, 2017 4:59 PM
To: MATPOWER discussion forum
Subject: Re: Objective Functions

Hello,
The obj_func mainly minimizes the cost including the real and reactive power.
But I have to only minimize objective function i.e. cost considering only the 
reactive power.
I tried the way explained by you above but I am not able to do this.?
Can you help?
basically, my goal is to change the objective function.
Thanks

On Wed, Jul 12, 2017 at 1:49 PM, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:
ok, thanks

On Wed, Jul 12, 2017 at 1:40 PM, Kardoš Juraj 
mailto:juraj.kar...@usi.ch>> wrote:
Try to have a look in the code in opf_costfcn.m and compare it with the 
objective function definition in the manual 
(http://www.pserc.cornell.edu/matpower/manual.pdf) section 6.1 equation (6.6). 
You will find the function implemented in the code, as well as its gradient and 
Hessian w.r.t. vector x (equation 6.5). If you have problems with derivatives, 
have a look at section 6 in this document 
http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf. It describes how 
the first and second derivatives can be computed. Good luck!
==
Juraj Kardos
Advanced Computing Laboratory
Institute of Computational Science
Universita della Svizzera italiana
Via Giuseppe Buffi 13
Lugano 6904
Switzerland
http://www.ics.inf.usi.ch
===

On 12 Jul 2017, at 09:46, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:

Can you explain me through simple example.?

On Wed, Jul 12, 2017 at 1:09 PM, Kardoš Juraj 
mailto:juraj.kar...@usi.ch>> wrote:
Hello,

as far as I know, you can define arbitrary objective function by modifying the 
following source file: opf_costfcn.m. Don’t forget that you need to provide 
gradient and Hessian w.r.t. OPF control variables as well. These derivations 
are used in optimizers to find the optimal solution.

Best regards,

==
Juraj Kardos
Advanced Computing Laboratory
Institute of Computational Science
Universita della Svizzera italiana
Via Giuseppe Buffi 13
Lugano 6904
Switzerland
http://www.ics.inf.usi.ch
===

On 12 Jul 2017, at 08:02, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:

Hello everyone,
I am working on congestion management and running optimal power flow.
The Obj

Re: Objective Functions

2017-07-15 Thread Akash Tyagi
Thanks a lot.
It is working now.
The last thing I want to ask is if we don't add reactive cost data to case,
then it is considering only the real power minimization??

On Sat, Jul 15, 2017 at 6:01 PM, Sarmad Hanif <
sarmad.ha...@tum-create.edu.sg> wrote:

> From Generator Cost Data table of the MATPOWER manual:
>
> “If gen has ng rows, then the first ng rows of gencost contain the costs
> for active power produced by the
>
> corresponding generators. If gencost has 2ng rows, then rows ng + 1
> through 2ng contain the reactive
>
> power costs in the same format.”
>
>
>
> Since there are only active power cost terms in the case file and you have
> put all active power cost terms to zero, your cost function will evaluate
> to zero.
>
> First add reactive power cost term rows and then specify their marginal
> values to be able for MATPOWER to consider them.
>
> Hope it helps.
>
> Sarmad
>
>
>
> *From:* bounce-121659136-74036...@list.cornell.edu [mailto:
> bounce-121659136-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Saturday, 15 July, 2017 7:46 PM
>
> *To:* MATPOWER discussion forum
> *Subject:* Re: Objective Functions
>
>
>
> After putting the cost term of the real power to zero in the mpc.gencost
> field, as attached the case below-
>
> Then after running the optimal power flow by using the following code-
>
> clc
>
> clear
>
> close all;
>
> define_constants;
>
> mpc=loadcase(newcase5);
>
> results=runopf(mpc);
>
> The objective function is coming zero.??
>
> I am not getting this??
>
>
>
> On Sat, Jul 15, 2017 at 10:19 AM, Sarmad Hanif <
> sarmad.ha...@tum-create.edu.sg> wrote:
>
> Hi,
>
> Mr. Kardos already gave the references for you to explore the cost
> functions in detail.
>
> A quick fix:
>
> If you just want to minimize reactive power, then just put cost terms of
> the real power to zero in its approriate mpc.gencost field J
>
>
>
> Btw, minimizing objective function can mean anything, as it depends on
> your “function”. It cannot always mean considering only the reactive power,
> as you mentioned in your previous email.
>
>
>
> Thanks,
>
> Sarmad
>
>
>
> *From:* bounce-121652404-74036...@list.cornell.edu [mailto:
> bounce-121652404-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Wednesday, 12 July, 2017 4:59 PM
> *To:* MATPOWER discussion forum
> *Subject:* Re: Objective Functions
>
>
>
> Hello,
>
> The obj_func mainly minimizes the cost including the real and reactive
> power.
>
> But I have to only minimize objective function i.e. cost considering only
> the reactive power.
>
> I tried the way explained by you above but I am not able to do this.?
>
> Can you help?
>
> basically, my goal is to change the objective function.
>
> Thanks
>
>
>
> On Wed, Jul 12, 2017 at 1:49 PM, Akash Tyagi 
> wrote:
>
> ok, thanks
>
>
>
> On Wed, Jul 12, 2017 at 1:40 PM, Kardoš Juraj  wrote:
>
> Try to have a look in the code in opf_costfcn.m and compare it with the
> objective function definition in the manual (http://www.pserc.cornell.edu/
> matpower/manual.pdf) section 6.1 equation (6.6). You will find the
> function implemented in the code, as well as its gradient and Hessian
> w.r.t. vector x (equation 6.5). If you have problems with derivatives, have
> a look at section 6 in this document http://www.pserc.
> cornell.edu/matpower/TN2-OPF-Derivatives.pdf. It describes how the first
> and second derivatives can be computed. Good luck!
>
> ==
> Juraj Kardos
> Advanced Computing Laboratory
> Institute of Computational Science
> Universita della Svizzera italiana
> Via Giuseppe Buffi 13
> Lugano 6904
> Switzerland
> http://www.ics.inf.usi.ch
> ===
>
>
>
> On 12 Jul 2017, at 09:46, Akash Tyagi  wrote:
>
>
>
> Can you explain me through simple example.?
>
>
>
> On Wed, Jul 12, 2017 at 1:09 PM, Kardoš Juraj  wrote:
>
> Hello,
>
>
>
> as far as I know, you can define arbitrary objective function by modifying
> the following source file: opf_costfcn.m. Don’t forget that you need to
> provide gradient and Hessian w.r.t. OPF control variables as well. These
> derivations are used in optimizers to find the optimal solution.
>
>
>
> Best regards,
>
>
>
> ==
> Juraj Kardos
> Advanced Computing Laboratory
> Institute of Computational Science
> Universita della Svizzera italiana
> Via Giuseppe Buffi 13
> Lugano 6904
> Switzerland
> http://www.ics.inf.usi.ch
> ===
>
>
>
> On 12 Jul 2017, at 08:02, Akash Tyagi  wrote:
>
>
>
> Hello everyone,
>
> I am working on congestion management and running optimal power flow.
>
> The Objective function after running the OPF is the cost, but I want to
> include my own objective function.
>
> Can you please let me know how to remove the existing objective function
> and include my own objective function.
>
> Thanks in advance
>
>
>
>
>
>
>
>
>
>
>
>
>


RE: Objective Functions

2017-07-15 Thread Sarmad Hanif
From Generator Cost Data table of the MATPOWER manual:
“If gen has ng rows, then the first ng rows of gencost contain the costs for 
active power produced by the
corresponding generators. If gencost has 2ng rows, then rows ng + 1 through 2ng 
contain the reactive
power costs in the same format.”

Since there are only active power cost terms in the case file and you have put 
all active power cost terms to zero, your cost function will evaluate to zero.
First add reactive power cost term rows and then specify their marginal values 
to be able for MATPOWER to consider them.
Hope it helps.
Sarmad

From: bounce-121659136-74036...@list.cornell.edu 
[mailto:bounce-121659136-74036...@list.cornell.edu] On Behalf Of Akash Tyagi
Sent: Saturday, 15 July, 2017 7:46 PM
To: MATPOWER discussion forum
Subject: Re: Objective Functions

After putting the cost term of the real power to zero in the mpc.gencost field, 
as attached the case below-
Then after running the optimal power flow by using the following code-
clc
clear
close all;
define_constants;
mpc=loadcase(newcase5);
results=runopf(mpc);
The objective function is coming zero.??
I am not getting this??

On Sat, Jul 15, 2017 at 10:19 AM, Sarmad Hanif 
mailto:sarmad.ha...@tum-create.edu.sg>> wrote:
Hi,
Mr. Kardos already gave the references for you to explore the cost functions in 
detail.
A quick fix:
If you just want to minimize reactive power, then just put cost terms of the 
real power to zero in its approriate mpc.gencost field ☺

Btw, minimizing objective function can mean anything, as it depends on your 
“function”. It cannot always mean considering only the reactive power, as you 
mentioned in your previous email.

Thanks,
Sarmad

From: 
bounce-121652404-74036...@list.cornell.edu
 
[mailto:bounce-121652404-74036...@list.cornell.edu]
 On Behalf Of Akash Tyagi
Sent: Wednesday, 12 July, 2017 4:59 PM
To: MATPOWER discussion forum
Subject: Re: Objective Functions

Hello,
The obj_func mainly minimizes the cost including the real and reactive power.
But I have to only minimize objective function i.e. cost considering only the 
reactive power.
I tried the way explained by you above but I am not able to do this.?
Can you help?
basically, my goal is to change the objective function.
Thanks

On Wed, Jul 12, 2017 at 1:49 PM, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:
ok, thanks

On Wed, Jul 12, 2017 at 1:40 PM, Kardoš Juraj 
mailto:juraj.kar...@usi.ch>> wrote:
Try to have a look in the code in opf_costfcn.m and compare it with the 
objective function definition in the manual 
(http://www.pserc.cornell.edu/matpower/manual.pdf) section 6.1 equation (6.6). 
You will find the function implemented in the code, as well as its gradient and 
Hessian w.r.t. vector x (equation 6.5). If you have problems with derivatives, 
have a look at section 6 in this document 
http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf. It describes how 
the first and second derivatives can be computed. Good luck!
==
Juraj Kardos
Advanced Computing Laboratory
Institute of Computational Science
Universita della Svizzera italiana
Via Giuseppe Buffi 13
Lugano 6904
Switzerland
http://www.ics.inf.usi.ch
===

On 12 Jul 2017, at 09:46, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:

Can you explain me through simple example.?

On Wed, Jul 12, 2017 at 1:09 PM, Kardoš Juraj 
mailto:juraj.kar...@usi.ch>> wrote:
Hello,

as far as I know, you can define arbitrary objective function by modifying the 
following source file: opf_costfcn.m. Don’t forget that you need to provide 
gradient and Hessian w.r.t. OPF control variables as well. These derivations 
are used in optimizers to find the optimal solution.

Best regards,

==
Juraj Kardos
Advanced Computing Laboratory
Institute of Computational Science
Universita della Svizzera italiana
Via Giuseppe Buffi 13
Lugano 6904
Switzerland
http://www.ics.inf.usi.ch
===

On 12 Jul 2017, at 08:02, Akash Tyagi 
mailto:akashtyagi0...@gmail.com>> wrote:

Hello everyone,
I am working on congestion management and running optimal power flow.
The Objective function after running the OPF is the cost, but I want to include 
my own objective function.
Can you please let me know how to remove the existing objective function and 
include my own objective function.
Thanks in advance









Re: Objective Functions

2017-07-15 Thread Akash Tyagi
After putting the cost term of the real power to zero in the mpc.gencost
field, as attached the case below-
Then after running the optimal power flow by using the following code-
clc
clear
close all;
define_constants;
mpc=loadcase(newcase5);
results=runopf(mpc);
The objective function is coming zero.??
I am not getting this??

On Sat, Jul 15, 2017 at 10:19 AM, Sarmad Hanif <
sarmad.ha...@tum-create.edu.sg> wrote:

> Hi,
>
> Mr. Kardos already gave the references for you to explore the cost
> functions in detail.
>
> A quick fix:
>
> If you just want to minimize reactive power, then just put cost terms of
> the real power to zero in its approriate mpc.gencost field J
>
>
>
> Btw, minimizing objective function can mean anything, as it depends on
> your “function”. It cannot always mean considering only the reactive power,
> as you mentioned in your previous email.
>
>
>
> Thanks,
>
> Sarmad
>
>
>
> *From:* bounce-121652404-74036...@list.cornell.edu [mailto:
> bounce-121652404-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Wednesday, 12 July, 2017 4:59 PM
> *To:* MATPOWER discussion forum
> *Subject:* Re: Objective Functions
>
>
>
> Hello,
>
> The obj_func mainly minimizes the cost including the real and reactive
> power.
>
> But I have to only minimize objective function i.e. cost considering only
> the reactive power.
>
> I tried the way explained by you above but I am not able to do this.?
>
> Can you help?
>
> basically, my goal is to change the objective function.
>
> Thanks
>
>
>
> On Wed, Jul 12, 2017 at 1:49 PM, Akash Tyagi 
> wrote:
>
> ok, thanks
>
>
>
> On Wed, Jul 12, 2017 at 1:40 PM, Kardoš Juraj  wrote:
>
> Try to have a look in the code in opf_costfcn.m and compare it with the
> objective function definition in the manual (http://www.pserc.cornell.edu/
> matpower/manual.pdf) section 6.1 equation (6.6). You will find the
> function implemented in the code, as well as its gradient and Hessian
> w.r.t. vector x (equation 6.5). If you have problems with derivatives, have
> a look at section 6 in this document http://www.pserc.
> cornell.edu/matpower/TN2-OPF-Derivatives.pdf. It describes how the first
> and second derivatives can be computed. Good luck!
>
> ==
> Juraj Kardos
> Advanced Computing Laboratory
> Institute of Computational Science
> Universita della Svizzera italiana
> Via Giuseppe Buffi 13
> Lugano 6904
> Switzerland
> http://www.ics.inf.usi.ch
> ===
>
>
>
> On 12 Jul 2017, at 09:46, Akash Tyagi  wrote:
>
>
>
> Can you explain me through simple example.?
>
>
>
> On Wed, Jul 12, 2017 at 1:09 PM, Kardoš Juraj  wrote:
>
> Hello,
>
>
>
> as far as I know, you can define arbitrary objective function by modifying
> the following source file: opf_costfcn.m. Don’t forget that you need to
> provide gradient and Hessian w.r.t. OPF control variables as well. These
> derivations are used in optimizers to find the optimal solution.
>
>
>
> Best regards,
>
>
>
> ==
> Juraj Kardos
> Advanced Computing Laboratory
> Institute of Computational Science
> Universita della Svizzera italiana
> Via Giuseppe Buffi 13
> Lugano 6904
> Switzerland
> http://www.ics.inf.usi.ch
> ===
>
>
>
> On 12 Jul 2017, at 08:02, Akash Tyagi  wrote:
>
>
>
> Hello everyone,
>
> I am working on congestion management and running optimal power flow.
>
> The Objective function after running the OPF is the cost, but I want to
> include my own objective function.
>
> Can you please let me know how to remove the existing objective function
> and include my own objective function.
>
> Thanks in advance
>
>
>
>
>
>
>
>
>
>
>


newcase5.m
Description: Binary data


Re: Error using Case5

2017-07-15 Thread Akash Tyagi
Thanks.
Now it is working good-:)

On Sat, Jul 15, 2017 at 5:03 PM, Sarmad Hanif <
sarmad.ha...@tum-create.edu.sg> wrote:

> Does the AC/DC power flow run ? If yes, then use these values to
> initialize the optimal power flow.
>
> On another note, which solver are you using ? See the range of solvers in
> MATPOWER manual.
>
>
>
> *From:* bounce-121659116-74036...@list.cornell.edu [mailto:
> bounce-121659116-74036...@list.cornell.edu] *On Behalf Of *Akash Tyagi
> *Sent:* Saturday, 15 July, 2017 7:12 PM
> *To:* MATPOWER discussion forum
> *Subject:* Error using Case5
>
>
>
> I am trying to run optimal power flow for  case5 using the following
> commands,
>
> clc
>
> clear
>
> close all;
>
> define_constants;
>
> mpc=loadcase(case5);
>
> mpopt=mpoption('pf.nr.max_it',1000);
>
> results=runopf(mpc,mpopt);
>
>
>
> After running the program it is showing the error-
>
>
>
> Numerically Failed
>
>
>
> Did not converge in 8 iterations.
>
>
>
> What would i do??
>


RE: Error using Case5

2017-07-15 Thread Sarmad Hanif
Does the AC/DC power flow run ? If yes, then use these values to initialize the 
optimal power flow.
On another note, which solver are you using ? See the range of solvers in 
MATPOWER manual.

From: bounce-121659116-74036...@list.cornell.edu 
[mailto:bounce-121659116-74036...@list.cornell.edu] On Behalf Of Akash Tyagi
Sent: Saturday, 15 July, 2017 7:12 PM
To: MATPOWER discussion forum
Subject: Error using Case5

I am trying to run optimal power flow for  case5 using the following commands,
clc
clear
close all;
define_constants;
mpc=loadcase(case5);
mpopt=mpoption('pf.nr.max_it',1000);
results=runopf(mpc,mpopt);

After running the program it is showing the error-

Numerically Failed

Did not converge in 8 iterations.

What would i do??



Error using Case5

2017-07-15 Thread Akash Tyagi
I am trying to run optimal power flow for  case5 using the following
commands,
clc
clear
close all;
define_constants;
mpc=loadcase(case5);
mpopt=mpoption('pf.nr.max_it',1000);
results=runopf(mpc,mpopt);

After running the program it is showing the error-

Numerically Failed

Did not converge in 8 iterations.

What would i do??


Get_losses

2017-07-15 Thread Akash Tyagi
Hello everyone, I am trying to use get_losses command and it's quite easy
but i am not getting one thing in that command,
mpc=loadcase(case5);
results=runpf(mpc);
[loss,fchg,tchg,dloss_dv]=get_losses(results);
what is 'dloss_dv' given means??