MATPOWER / matpower

MATPOWER – steady state power flow simulation and optimization for MATLAB and Octave
https://matpower.org
Other
418 stars 150 forks source link

How to add linear constraints in the standard OPF? #176

Closed YHLjun closed 5 months ago

YHLjun commented 1 year ago

Hi,

I want to add additional constraints for Pg to original OPF. I use "add_constraints('name', A, l, u, varset)" to add. but the matlab always said there is no add_constraints function..... So how to add it? My version is is 7.1.

It would be appreciated thta a simple example can be provided, such as 80MW>=3*Pg+2MW>=15....

Kind Regards YHL

rdzman commented 1 year ago

See Section 6.3 and Chapter 7 of the MATPOWER User's Manual. To use the add_lin_constraint() method of the opt_model (om) object, you would need to use the callback function approach. The direct method, where you specify A, l, and u directly as additional fields in mpc is often much simpler. The only thing is that the columns of A must correspond to the full set of optimization variables. By default, that is [Va; Vm; Pg; Qg], that is bus voltage angles and magnitudes, followed by generator active and reactive injections.

FWIW, your example looks like simple bounds on the active generation, which you can accomplish with gen(:, PMIN) and gen(:, PMAX).

YHLjun commented 1 year ago

Thanks for your timely response razman,

I have one question about what kind of constraints can be added, is it possible to add mix integer varibles into standard OPF and solve it?

rdzman commented 1 year ago

Not in MATPOWER 7.1. With the new architecture of MATPOWER 8 it should be possible, but I don't have any examples yet of how to do that.