| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from matplotlib import rc |
| 5 |
|
| 6 |
rc("text", usetex=True) |
| 7 |
rc("font", family="serif") |
| 8 |
|
| 9 |
|
| 10 |
def plot_interval(a, c, x_left, x_right, i, fbound): |
| 11 |
lh = c * (1 - a[0]) |
| 12 |
rh = c * (1 + a[1]) |
| 13 |
x = arange(x_left, x_right + 1) |
| 14 |
y = 0 * x |
| 15 |
arrow_r = Arrow(c, 0, c * a[1], 0, 0.2) |
| 16 |
arrow_l = Arrow(c, 0, -c * a[0], 0, 0.2) |
| 17 |
plot(x, y) |
| 18 |
text( |
| 19 |
(x_left + lh) / 2.0, |
| 20 |
0.1, |
| 21 |
"freebound interval [%s, %s] is penalty-free" % (lh, rh), |
| 22 |
) |
| 23 |
text((x_left + lh) / 2.0, 0.2, "rhs=%s, %s" % (c, fbound)) |
| 24 |
cur_ax = gca() |
| 25 |
cur_ax.add_patch(arrow_l) |
| 26 |
cur_ax.add_patch(arrow_r) |
| 27 |
axis([x_left, x_right, -0.1, 0.3]) |
| 28 |
yticks([]) |
| 29 |
title("Elasticized constraint\_%s $C(x)= %s $" % (i, c)) |
| 30 |
|
| 31 |
|
| 32 |
figure() |
| 33 |
subplots_adjust(hspace=0.5) |
| 34 |
|
| 35 |
fbound = "proportionFreeBound" |
| 36 |
i = 1 |
| 37 |
subplot(2, 1, i) |
| 38 |
a = [0.01, 0.01] |
| 39 |
c = 200 |
| 40 |
x_left = 0.97 * c |
| 41 |
x_right = 1.03 * c |
| 42 |
fb_string = "%s%s = %s" % (fbound, "", a[0]) |
| 43 |
plot_interval(a, c, x_left, x_right, i, fb_string) |
| 44 |
|
| 45 |
i += 1 |
| 46 |
subplot(2, 1, i) |
| 47 |
a = [0.02, 0.05] |
| 48 |
c = 500 |
| 49 |
x_left = 0.9 * c |
| 50 |
x_right = 1.2 * c |
| 51 |
fb_string = "%s%s = [%s,%s]" % (fbound, "List", a[0], a[1]) |
| 52 |
plot_interval(a, c, x_left, x_right, i, fb_string) |
| 53 |
savefig("freebound.jpg") |
| 54 |
savefig("freebound.pdf") |
| 55 |
|
| 56 |
|