0

为了解决这个问题,我们使用以下代码:

R_H, R_L, g_H, g_L, x, R_0 = Reals('R_H R_L g_H g_L x R_0')
R_HH = R_H*g_H
R_HL = R_L*g_H
R_LH = R_H*g_L
R_LL = R_L*g_L
eq1 = R_HH*x+R_HL*(1-x)
eq2 = R_LH*x+R_LL*(1-x)
equations = [
             eq1 == R_0*x, eq2 == R_0*(1-x)
                                           ]
print "epidemiological equations:"
print equations
problem = [
g_H == 0.31, g_L == 0.69,
R_H == 3.93,
R_L == 0.18, x >0 , R_0 >0]
print "Problem:"
print problem 
print "Solution:"
set_option(rational_to_decimal=True)
solve(equations + problem)

输出是

epidemiological equations:
[R_H·g_H·x + R_L·g_H·(1 - x) = R_0·x, R_H·g_L·x + R_L·g_L·(1 - x) = R_0·(1 - x)]
Problem:
[g_H = 31/100, g_L = 69/100, R_H = 393/100, R_L = 9/50, x > 0, R_0 > 0]
Solution:
[x = 0.31,
R_0 = 1.3425,
R_L = 0.18,
R_H = 3.93,
g_L = 0.69,
g_H = 0.31]

在此处在线运行此示例

请让我知道你的想法。非常感谢。

4

1 回答 1

0

其他具有三类性活动的示例:高、中、低。

代码:

R_H, R_M, R_L, g_H, g_M, g_L, x, y, R_0 = Reals('R_H R_M R_L g_H g_M g_L x y R_0')
R_HH = R_H*g_H
R_HL = R_L*g_H
R_LH = R_H*g_L
R_LL = R_L*g_L
R_HM = R_M*g_H
R_MH = R_H*g_M
R_MM = R_M*g_M
R_ML = R_L*g_M
R_LM = R_M*g_L
eq1 = R_HH*x+R_HM*y+R_HL*(1-x-y)
eq2 = R_MH*x+R_MM*y+R_ML*(1-x-y)
eq3 = R_LH*x + R_LM*y + R_LL*(1-x-y)
equations = [
            eq1 == R_0*x, eq2 == R_0*y, eq3 == R_0*(1-x-y)
            ]
print "epidemiological equations:"
print equations
problem = [
           g_H == 0.31, g_M == 0.45 , g_L == 0.69,
           R_H == 3.93, R_M == 1.86,
           R_L == 0.18, x >0 , y >0,  R_0 >0]
print "Problem:"
print problem 
print "Solution:"
set_option(rational_to_decimal=True)
solve(equations + problem)

输出:

epidemiological equations:
[R_H·g_H·x + R_M·g_H·y + R_L·g_H·(1 - x - y) = R_0·x, R_H·g_M·x + R_M·g_M·y + R_L·g_M·(1 - x - y) = R_0·y, R_H·g_L·x + R_M·g_L·y + R_L·g_L·(1 - x - y) =
R_0·(1 - x - y)]
Problem:
[g_H = 31/100, g_M = 9/20, g_L = 69/100, R_H = 393/100, R_M = 93/50, R_L = 9/50, x > 0, y > 0,  R_0 > 0]
Solution:
[R_0 = 2.1795,
 y = 0.3103448275?,
 R_L = 0.18,
 R_M = 1.86,
 R_H = 3.93,
 g_L = 0.69,
 g_M = 0.45,
 g_H = 0.31,
 x = 0.2137931034?]

在此处在线运行此示例

于 2013-08-07T02:20:37.383 回答