Barrier Method#
[1]:
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
import numpy as np
[2]:
mpl.rcParams['text.usetex'] = True
mpl.rcParams['text.latex.preamble'] = r'\usepackage{amsmath}'
plt.rcParams["font.size"] = 16
The log barrier function is defined as
\[\frac{1}{t}\log(-h_i(x))\]
[3]:
fig, ax = plt.subplots(1, 1, figsize=(6, 5))
ts = [1, 5, 10]
xs = np.linspace(-5, -1e-10, 1000)
colors = ["cornflowerblue", "darkorange", "thistle"]
for i in range(3):
ax.plot(xs, -(1/ts[i])*np.log(-xs), linewidth=3, color=colors[i], label=f"$t={ts[i]}$")
ax.set_ylim([-2, 3])
ax.set_xlim([-5, 0.1])
ax.legend(frameon=False)
ax.xaxis.set_major_locator(MultipleLocator(1.0))
ax.xaxis.set_minor_locator(MultipleLocator(0.2))
ax.yaxis.set_major_locator(MultipleLocator(1.0))
ax.yaxis.set_minor_locator(MultipleLocator(0.2))
ax.grid(True, "minor", color="0.85", linewidth=0.50, zorder=-20)
ax.grid(True, "major", color="0.65", linewidth=0.75, zorder=-10)
ax.tick_params(which="both", bottom=False, left=False)
ax.set_xlabel(r"$h_i(x)$")
ax.set_ylabel("Log\n Barrier\n Value", rotation=0, horizontalalignment='right')
ax.yaxis.set_label_coords(-0.10, 0.5)
plt.savefig("../images/log_barrier_functions.png", dpi=200, transparent=False, bbox_inches="tight")
plt.show()
[ ]: