r_zero = 1
# Functional Cost
#
b_1 = 1.0
b_2 = 100
b_3 = 1000
u_1_lower = 0.00
u_1_upper = 0.1
u_2_lower = 0.00
u_2_upper = 0.6

name_file_1 = 'figure_1_sir_log.eps'
name_file_2 = 'figure_2_sir_log.eps'
name_file_3 = 'figure_3_sir_log.eps'
#
fbsm = ForwardBackwardSweep()
fbsm.set_parameters(k, mu, delta, beta, gamma, omega, epsilon, m, b_1, b_2,
                    b_3, s_zero, i_zero, r_zero)

t = fbsm.t
x_wc = fbsm.runge_kutta_forward(fbsm.u)
#
[x, lambda_, u] = fbsm.forward_backward_sweep()

mpl.style.use('ggplot')
# plt.ion()
n_whole = fbsm.n_whole
ax1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2)
ax1.plot(t, x_wc[:, 1], label="Without control", color='darkgreen')
ax1.plot(t, x[:, 1], label="Optimal controlled", color='orange')
ax1.set_ylabel(r'Infected individuals')
Exemplo n.º 2
0
N_p = s_y_p_zero+ s_a_p_zero+ l_y_p_zero + l_a_p_zero+i_y_p_zero+i_a_p_zero
# Functional Cost
A_1 = 0.5
A_2 = 0.2
A_3 = 0.2
A_4 = 1.2
c_1 = 1.0
c_2 = 1.1
c_3 = 1.2
c_4 = 1.3

name_file_1 = 'New_System_four_control.pdf'

#

fbsm = ForwardBackwardSweep()
fbsm.set_parameters(beta_y_p, r_y_1, r_y_2, r_a, alpha, beta_a_p, b_y,
                       b_a, beta_y_v, beta_a_v, gamma, theta, mu,
                       A_1, A_2, A_3, A_4, c_1, c_2, c_3, c_4,
                       s_y_p_zero, s_a_p_zero, l_y_p_zero, l_a_p_zero, i_y_p_zero, i_a_p_zero, s_v_zero, i_v_zero)

t = fbsm.t

x_wc_1 = fbsm.runge_kutta_forward(fbsm.u)
#
[x, lambda_, u] = fbsm.forward_backward_sweep()
cost = fbsm.control_cost(fbsm.x,u)

########################################################################################################################
##############################################  R_0 Computation  #######################################################
########################################################################################################################
Exemplo n.º 3
0
from forward_backward_sweep import ForwardBackwardSweep
import matplotlib.pyplot as plt

a = 1.0
c = 4.0
x_zero = 1.0
m_1 = -1.0
m_2 = 2.0

fbsm = ForwardBackwardSweep()
fbsm.eps = 0.001
fbsm.set_parameters(a, c, x_zero, m_1, m_2)
t = fbsm.t

x_wc = fbsm.runge_kutta_forward(fbsm.u)
[x, lambda_, u] = fbsm.forward_backward_sweep()

plt.figure()
plt.plot(t,
         x_wc,
         '-',
         ms=3,
         lw=1,
         alpha=0.7,
         color='green',
         label='State without control')
plt.plot(t,
         x,
         '--',
         ms=3,
         lw=1,
n_whole = 30000.0
b_1 = 50.0
b_2 = 500.0
s_zero = 76.0 / 120.0
l_zero = 36.0 / 120.0
i_zero = 4.0 / 120.0
l_r_zero = 2.0 / 120.0
i_r_zero = 1.0 / 120.0
r_zero = 1.0 / 120.0
lambda_recruitment = n_whole * mu
name_file_1 = 'figure_1_two_strain_tbm.eps'
name_file_2 = 'figure_2_two_strain_tbm.eps'
name_file_3 = 'figure_3_two_strain_tbm.eps'

#
fbsm = ForwardBackwardSweep()
fbsm.set_parameters(beta_1, beta_2, beta_3, mu, d_1, d_2, k_1, k_2, r_1, r_2,
                    p, q, n_whole, lambda_recruitment, b_1, b_2, s_zero,
                    l_zero, i_zero, l_r_zero, i_r_zero, r_zero)

t = fbsm.t
x_wc = fbsm.runge_kutta_forward(fbsm.u)
[x, lambda_, u] = fbsm.forward_backward_sweep()
mpl.style.use('ggplot')
# plt.ion()
n_whole = fbsm.n_whole
ax1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2)
ax2 = plt.subplot2grid((2, 2), (0, 1))
ax3 = plt.subplot2grid((2, 2), (1, 1))
#
ax1.plot(t, (x_wc[:, 3] + x_wc[:, 4]) / n_whole,
Exemplo n.º 5
0
i_p_zero = 0.0008
s_v_zero = 0.84
i_v_zero = 0.16
# Functional Cost
A_1 = .5
A_2 = 0.3
A_3 = 0.0

c_3 = 0.1

name_file_1 = 'figure_1_sir_log.eps'
name_file_2 = 'figure_2_sir_log.eps'
name_file_3 = 'figure_3_sir_log.eps'
#

fbsm = ForwardBackwardSweep()
fbsm.set_parameters(beta, a, b, psi, gamma, theta, mu,
                       A_1, A_2, A_3, c_3,
                       s_p_zero, l_p_zero, i_p_zero, s_v_zero, i_v_zero)

t = fbsm.t
x_wc = fbsm.runge_kutta_forward(fbsm.u)
#
[x, lambda_, u] = fbsm.forward_backward_sweep()

mpl.style.use('ggplot')
# plt.ion()
# n_whole = fbsm.n_whole
ax1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2)
ax1.plot(t, x_wc[:, 2],
         label="Without control",
Exemplo n.º 6
0
t_f = 20.0
b = 0.525
d = 0.5
c = 0.00115
e = 0.5
g = 0.1
a = 0.2
a_w = 2.0
# Initial conditions
s_zero = 1000.0
e_zero = 100.0
i_zero = 50.0
r_zero = 15.0
n_zero = s_zero + e_zero + i_zero + r_zero

fbsm = ForwardBackwardSweep()
fbsm.set_parameters(t_0, t_f, b, d, c, e, g, a, a_w, s_zero, e_zero, i_zero,
                    r_zero, n_zero)

t = fbsm.t
n_max = fbsm.n_max
u = np.zeros(n_max)
x_wc = fbsm.runge_kutta_forward(u)
[x, lambda_, u] = fbsm.forward_backward_sweep()

# plotting
name_file_1 = 'epidemics_lenhart_lab7.eps'
mpl.style.use('ggplot')
# plt.ion()
plt.show()
Exemplo n.º 7
0
#
#
#
beta = 0.01
a = 0.1
b = 0.075
Lambda = 0.003
gamma = 0.06
theta = 0.2
mu = 0.3
#
#
# Initial conditions
s_p_zero = 0.9992
l_p_zero = 0.0
i_p_zero = 0.0008
s_v_zero = 0.84
i_v_zero = 0.16
# Functional Cost
#
A_1 = 1.0
A_2 = 1.0
A_3 = 1.0
c_1 = 0.1
#u_1_lower = 0.00
#u_1_upper = 0.1
#u_2_lower = 0.00
#u_2_upper = 0.6

fbsm = ForwardBackwardSweep()
[x, lambda_, u] = fbsm.forward_backward_sweep()
import matplotlib.pyplot as plt
import numpy as np
from forward_backward_sweep import ForwardBackwardSweep

a = 1.0
b = 1.0
c = 4.0
x_zero = 1.0
lambda_final = 0.0

fbsm = ForwardBackwardSweep()
fbsm.set_parameters(a, b, c, x_zero, lambda_final)
x_wc = fbsm.runge_kutta_forward(fbsm.u)
[x, lambda_, u] = fbsm.forward_backward_sweep()

t = fbsm.t
plt.plot(t, x_wc, '-', color='orange', label='state without control')
plt.plot(t, x, 'g-', label='controlled state')
plt.ylabel(r'x(t)')
plt.xlabel(r'$t$')
plt.legend(loc=0)
plt.show()
Exemplo n.º 9
0
i_v_zero = 0.16
# Functional Cost
#
b_1 = 1.0
b_2 = 100

u_1_lower = 0.00
u_1_upper = 0.1
u_2_lower = 0.00
u_2_upper = 0.6

name_file_1 = 'figure_1_sir_log.eps'
name_file_2 = 'figure_2_sir_log.eps'
name_file_3 = 'figure_3_sir_log.eps'
#
fbsm = ForwardBackwardSweep()
fbsm.set_parameters(beta, a, b, Lambda, g, theta, mu,
                    b_1, b_2,
                    s_p_zero, l_p_zero, i_p_zero, s_v_zero, i_v_zero)

t = fbsm.t
x_wc = fbsm.runge_kutta_forward(fbsm.u)
#
[x, lambda_, u] = fbsm.forward_backward_sweep()

mpl.style.use('ggplot')
# plt.ion()
n_whole = fbsm.n_whole
ax1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2)
ax1.plot(t, x_wc[:, 1],
         label="Without control",
Exemplo n.º 10
0
from forward_backward_sweep import ForwardBackwardSweep
import matplotlib.pyplot as plt

r = 1.0
a = 1.0
b = 12.0
c = 1.0
x_zero = 1.0

lambda_final = c

fbsm = ForwardBackwardSweep()
fbsm.eps = 0.001
fbsm.lambda_final = lambda_final
fbsm.set_parameters(r, a, b, c, x_zero)
t = fbsm.t

x_wc = fbsm.runge_kutta_forward(fbsm.u)
[x, lambda_, u] = fbsm.forward_backward_sweep()

plt.figure()
plt.plot(t,
         x_wc,
         '-',
         ms=3,
         lw=1,
         alpha=0.7,
         color='green',
         label='State without control')
plt.plot(t,
         x,
j_zero = 326
r_zero = 20
n_whole = s_zero + e_zero + q_zero + i_zero + j_zero + r_zero
# functional cost
b_1 = 1.0
b_2 = 1.0
b_3 = 1.0
b_4 = 1.0
c_1 = 300.0
c_2 = 600.0

name_file_1 = 'figure_1_sars.eps'
name_file_2 = 'figure_2_sars.eps'
name_file_3 = 'figure_3_sars.eps'
#
fbsm = ForwardBackwardSweep()
fbsm.set_parameters(beta, e_e, e_q, e_j, mu, p, k_1, k_2, d_1, d_2, sigma_1,
                    sigma_2, n_whole, b_1, b_2, b_3, b_4, c_1, c_2, s_zero,
                    e_zero, q_zero, i_zero, j_zero, r_zero)
#
t = fbsm.t
x_wcc = fbsm.runge_kutta_forward(fbsm.u)
constant_cost = fbsm.control_cost(x_wcc, fbsm.u)
#
[x, lambda_, u] = fbsm.forward_backward_sweep()
optimal_cost = fbsm.control_cost(x, u)
#
mpl.style.use('ggplot')
# plt.ion()
n_whole = fbsm.n_whole
ax1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2)
Exemplo n.º 12
0
import matplotlib as mpl

s = 10.0
m_1 = 0.02
m_2 = 0.5
m_3 = 4.4
r = 0.03
k = 0.000024
n_weight = 300.0
a = 0.2
t_cell_max = 1500
t_cell_zero = 806.4
t_cell_infected_zero = 0.04
virus_particle_zero = 1.5
name_file_1 = 'hiv_chemotherapy_fig_01.eps'
fbsm = ForwardBackwardSweep()
fbsm.set_parameters(s, m_1, m_2, m_3, r, k, n_weight, a, t_cell_max,
                    t_cell_zero, t_cell_infected_zero, virus_particle_zero)
t = fbsm.t
x_wc = fbsm.runge_kutta_forward(fbsm.u)
[x, lambda_, u] = fbsm.forward_backward_sweep()
mpl.style.use('ggplot')
# plt.ion()
plt.show()
ax1 = plt.subplot2grid((2, 2), (0, 0))
ax2 = plt.subplot2grid((2, 2), (0, 1))
ax3 = plt.subplot2grid((2, 2), (1, 0))
ax4 = plt.subplot2grid((2, 2), (1, 1))
"""
ax1.plot(t, x_wc[:, 0] + x_wc[:, 1], '-',
         ms=3,
from forward_backward_sweep import ForwardBackwardSweep
import matplotlib.pyplot as plt
import matplotlib as mpl

r = 0.1
k = 0.75
m_p = 0.1
m_f = 0.1
c_p = 10000.0
c_f = 1.0
# initial conditions
p_zero = 0.7
f_zero = 0.7
o_zero = 0.25

fbsm = ForwardBackwardSweep()
fbsm.set_parameters(r, k, m_p, m_f, c_p, c_f, p_zero, f_zero, o_zero)
t = fbsm.t

x_wc = fbsm.runge_kutta_forward(fbsm.u)
[x, lambda_, u] = fbsm.forward_backward_sweep()
mpl.style.use('ggplot')
# plt.ion()
plt.show()

ax1 = plt.subplot2grid((2, 3), (0, 0))
ax2 = plt.subplot2grid((2, 3), (0, 1))
ax3 = plt.subplot2grid((2, 3), (0, 2))
ax4 = plt.subplot2grid((2, 3), (1, 0))
ax5 = plt.subplot2grid((2, 3), (1, 1))