Dear Jiazi I did something similar and the code is available, you can use and modify it for you propose. You can see all the information on this thread: https://www.mail-archive.com/[email protected]/msg03462.html
About your question, if you use a dummy generators, they will automatically become variables of the optimization problem and therefore it is possible to use them in the objective function. The thermal limit constraints are not easy to implement in the OPF formulation of MATPOWER. Best regards, Álvaro
