The latest MATPOWER (v7.1) uses 
MP-Opt-Model<https://github.com/MATPOWER/mp-opt-model> to build and solve the 
mathematical model, so it would probably be helpful to familiarize yourself 
with that by having a look at the MP-Opt-Model User’s 
Manual<https://matpower.org/docs/MP-Opt-Model-manual-3.0.pdf>. However, I 
realize that as we have abstracted and generalized the OPF design over time to 
more cleanly separate problem formulation from solvers, this structure is not 
as transparent as it once was, which calls for a bit more documentation to make 
this clear. I expect this will be addressed when we integrate the new 
generalized network and element modeling layer, 
MP-Element<https://github.com/MATPOWER/mp-element/> into the documentation.

But in the mean time, here is the basic calling structure of the main functions 
involved in setting up and solving the OPF, in the case of an AC OPF solved by 
fmincon.

runopf()
    opf()
        
opf_setup()<https://matpower.org/docs/ref/matpower7.1/lib/opf_setup.html> - 
builds the mathematical model (om)
            om.add_var()
            om.add_lin_constraint()
            om.add_nln_constraint()
            om.add_quad_cost()
            ...
        
opf_execute()<https://matpower.org/docs/ref/matpower7.1/lib/opf_execute.html> - 
solves the mathematical model (om)
            
om.solve()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/@opt_model/solve.html>
                
@nlp_costfcn()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/nlp_costfcn.html>
                    om.eval_quad_cost()
                    om.eval_nln_cost()
                
@nlp_consfcn()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/nlp_consfcn.html>
                    om.eval_nln_constraint()
                
@nlp_hessfcn()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/nlp_hessfcn.html>
                    om.eval_nln_constraint_hess()
                nlps_master()
                    nlps_fmincon()
                        fmincon()

So the building of the model for the OPF occurs in 
opf_setup()<https://matpower.org/docs/ref/matpower7.1/lib/opf_setup.html>, Then 
opf_execute()<https://matpower.org/docs/ref/matpower7.1/lib/opf_execute.html> 
calls the 
solve()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/@opt_model/solve.html>
 method for the model, where you can see the definitions of the function 
handles used to evaluate the costs, constraints and hessians, namely 
nlp_costfcn()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/nlp_costfcn.html>,
 
nlp_consfcn()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/nlp_consfcn.html>,
 and 
nlp_hessfcn()<https://matpower.org/docs/ref/matpower7.1/mp-opt-model/lib/nlp_hessfcn.html>,
 respectively. Each of these uses the appropriate evaluation functions on the 
mathematical model object to compute the cost, constraint or hessian function 
values.

I hope this helps,

    Ray



On Nov 4, 2020, at 1:53 AM, yangyang 
<[email protected]<mailto:[email protected]>> wrote:

Dear all,

I am learning how matpower implements OPF using fmincon(). This matlab 
optimization function requires a bunch of numerical input arguments to start 
the optimization, like start point of the variable vector, equality, 
constraints, etc. The examples on matlab website also shows how to implement 
optimization using fmincon(). However, I really cant find which is the m file 
to convert a matpower case to a bunch of numerical things to start fmincon(). I 
have searched the matpower folder and the online function reference and I still 
cannot find how it is implemented. It seems that matpower uses a lot of 
function handles for implementation; and even setting breakpoints in fmincon.m 
will not show the intermediate variables during the optimization! Can some one 
show me the key m files to convert a matpower case into formats compatible with 
fmincon? Thank you for your patience!

Best Regards,
Yang Yang



Reply via email to