Call a PowerModels' function in Matlab

Hi All,

I want to call the bound tightening code in the PowerModels (i.e. following function) in Matlab.

run_obbt_opf(case, upper_bound, solver, model_constructor= QCWRTriPowerModel)

I tried to call “bound_tightening_call_from_matlab” script in which it calls and runs the “run_obbt_opf” function by the following command. For whatever reason the following code doesn’t recognize the test case. I use Julia v.06. Can you please let me know how I can fix this?

jl_command = ['julia -e "include("""C:\\Users\\Rasoul\\.julia\\v0.6\\bound_tightening_call_from_matlab.jl"""); run_obbt_opf(casename,' num2str(upper_bound) ',' solver ',' model ')"'];
[cmdstatus,out] = system(jl_command);

My second question is about saving the output of the bound tightening code. Is there any function that can save the output for the bound tightening code as test_case.m? Thanks in advance!

All the best,

I don’t know Matlab that well, so I can’t speak to how one would call Julia. I can recommend this workflow to export the bound information as a Matpower data file, which may serve your needs,

using Ipopt; using PowerModels

solver = optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-6, "print_level"=>0)

case, stats = run_obbt_opf!("pglib_opf_case5_pjm.m", solver)

open("pglib_opf_case5_pjm-bt.m", "w") do io
    export_matpower(io, case)

Why? Is it because of GitHub - MatlabCompat/MatlabCompat.jl: Source of MatlabCompat.jl ?

There’s GitHub - JuliaInterop/MATLAB.jl: Calling MATLAB in Julia through MATLAB Engine to call, and I’ve also been calling (through Oct2Py in Python) to Octave, MATLAB clone, but it may bot have the functions you want, e.g. toolboxes.

I don’t know about your case, I’ve been translating MATLAB code myself to Julia, and there are some similar packages that actually work in Julia 1.0, to help with compatibility maybe with some overlap with the one above, that probably someone should update. There’s also a Matlab-to-Julia syntax “transpiler”/compiler, it can be helpful, just note it’s not perfect, and may mistranslate, introduce bugs, extra ’ that is transpose, is the only major issue…