Hi MATPOWER developers,

I wanted to let you know about some of my recent work on the internals of 
MATPOWER. I’ve been working on a major overhaul and generalization of the 
network modeling in MATPOWER that will allow for much easier customization and 
implementation of new device models, etc, as well as, unbalanced 3-phase 
modeling. More on that to come in the future.

But in the process, I found myself refactoring and enhancing some of the code 
used for building and solving the mathematical model for the OPF and I decided 
that it made sense to pull out this code, document it more thoroughly and 
release it as a separate package called 
MP-Opt-Model<https://github.com/MATPOWER/mp-opt-model>  to be included in 
future MATPOWER versions, but in its own subdirectory, like MP-Test, MIPS and 
MOST.

So, what is MP-Opt-Model? It consists of the opt_model class for building the 
model for an arbitrary optimization problem plus all of the code related to 
interfacing to 3rd party solvers and a few utility functions.

To build and solve a model using MP-Opt-Model, you simply create an opt_model 
object …

  om = opt_model;

Add some optimization variables ...

  om.add_var('theta', ...);
  om.add_var('V', ...);
  om.add_var('Pg', ...);
  om.add_var('Qg', ...);

... some constraints ...

  om.add_nln_constraint('Pmismatch', ...);
  om.add_nln_constraint('Qmismatch', ...);
  om.add_lin_constraint('branch_angle_diff', ...);

... and some costs ...

  om.add_quad_cost('genCost', ...);
  om.add_nln_cost('customCost', ...);

... then call the solve method.

  [x, f, success] = om.solve(opt);

The solver can be selected and its options controlled by the opt struct.

MP-Opt-Model currently handles linear (LP, MILP), quadratic (QP, MIQP) and 
general nonlinear (NLP) programming problems, depending on the solvers you have 
installed. It is not intended to be as comprehensive and flexible as a full 
modeling language like YALMIP or GAMS, but I suspect it is quite a bit faster.

MP-Opt-Model also includes a unified interface to all of the solvers for each 
class of problems, namely qps_master() (was qps_matpower()) for LP and QP 
problems, miqps_master() (was miqps_matpower()) for mixed-integer problems, and 
nlps_master() for general nonlinear optimization problems.

MP-Opt-Model<https://github.com/MATPOWER/mp-opt-model> is currently available 
on GitHub at https://github.com/MATPOWER/mp-opt-model, with the new User's 
Manual<https://matpower.org/docs/MP-Opt-Model-manual.pdf> at available at 
https://matpower.org/docs/MP-Opt-Model-manual.pdf. The current master branch of 
the MATPOWER repository<https://github.com/MATPOWER/matpower> has also been 
updated to include and use MP-Opt-Model.

There is still a lot that can be done to improve and extend MP-Opt-Model, and I 
hope this move will help make it easier for others to not only make use of it, 
but also help enhance it.

Let me know what you think!

   Ray


Reply via email to