run_case(case_dir::String;
u_start=nothing, u_end=nothing,
μ=1e-5, μ_large=0.0125, K=9, rng::MersenneTwister=MersenneTwister(),
print_str=false, print_K=false, disable_msgs=false);
This function compues the shortest path between two feasible points of the MATPOWER OPF test case with file address specified by the String case_dir, and outputs the tuple (max_violation, max_violation_after, path_diff_pc, fobj_diff_pc, total_time) with values corresponding to the metrics used in out paper. Keyword arguments u_start and u_end are the starting and ending points of the desired path, respectively. If the endpoints are not provided, u_start is taken as the solution of the minimum losss problem, and u_end is taken as the solution of the ACOPF problem. Keyword arguments μ and μ_large are the barrier parameters for the shorest path step and feasible path step of the algorithm, respectively; they should not be changed unless you know what you are doing. Keywrod argument K is the number of breakpoints used to compute the shortest path. Keyword argument rng (deprecated, not in use) specifies a Mersenne Twister RNG object, in case seed control is needed for replicability (defaults to MersenneTwister() a standard, uncontrolled instance of type MersenneTwister). Keyword argument disable_msgs disables warning messages if set to true. Keyword arguments print_str and print_K are not for public use and should be left as false.
If the dependencies are not installed we can use the sample project provided in Project.toml (it is not clean though):
]activate .
instantiate
After instantiating the sample project, or if all dependencies are already installed, we can run the code directly. For example:
include("barrier_case_time_v2.jl");
max_violation, max_violation_after, path_diff_pc, fobj_diff_pc, total_time = run_case("MATPOWER/case9mod.m");
Or if you want to provide the endpoints manually you could write, for example:
include("barrier_case_time_v2.jl");
u_start = [0.5; 0.5];
u_end = [1.5; 1.3];
max_violation, max_violation_after, path_diff_pc, fobj_diff_pc, total_time = run_case("MATPOWER/case9dongchan.m"; u_start=u_start, u_end=u_end);
On top of the shortest-path machinery, this repository contains an empirical
convexity-metric pipeline for AC-OPF feasible sets (paper draft: draft.tex).
Layout:
convexity_metric.jl— module entry point: the two convexity kernels (shortest-path ratioC, segment-containmentC2), disconnection-aware aggregation (statuses, union-find components,p_connected), andanalyze_case(the one-call workflow).hit_and_run.jl— full-line interval-union Hit-and-Run kernel (scan kernel).convexity_relax_sampler.jl— Metropolized Hit-and-Run over a convex polytope relaxation (relax kernel; certifies higher-dimensional cases).convexity_sampling.jl— feasibility oracle, preconditioner, seeds, single-/multi-chain drivers with a connectivity ledger.convexity_diagnostics.jl— rank-normalized split R-hat, bulk/tail ESS, trust verdicts, two-sample comparators.convexity_validation.jl— validation harness: synthetic analytic-set checks, 2-D grid ground truth (Dijkstra), uniformity vs rejection sampling.scripts/— batch drivers (run from the repo root, e.g.julia --project=. -t 8 scripts/convexity_batch.jl); results append iteratively toresults/convexity_batch_results.csvand completed cases are skipped on restart.results/— batch results (CSV) and run notes;docs/— working notes.
Quick self-tests:
include("convexity_metric.jl"); using .ConvexityMetric
run_hitandrun_validation(); run_diagnostics_selftest()
run_dongchan_validation(); run_uniformity_validation()
@misc{turizo2025discreteshortestpathsoptimal,
title={Discrete Shortest Paths in Optimal Power Flow Feasible Regions},
author={Daniel Turizo and Diego Cifuentes and Anton Leykin and Daniel K. Molzahn},
year={2025},
eprint={2408.02172},
archivePrefix={arXiv},
primaryClass={math.OC},
url={https://arxiv.org/abs/2408.02172},
}