如何解决在Python中使用scipy.odeint方法进行多次返回
我正在尝试使用scipy.odeint()
方法来解决二阶偏导函数。
我可以针对常数k的单个值执行此操作,常数k是我具有的函数的常数。
但是我想对k的许多值尝试这种解决方案。
为此,我将所需的值包含在列表k中,并经历了一个循环,我希望将这些值作为参数插入最终解决方案中。
但是,出现错误
import numpy as np
from scipy.integrate import odeint
### Code with a single value of K.THAT WORKS FINE!!!! ###
k = 1 #attributes to be changed
t = [0.1,0.2,0.3] #Data
init = [45,0] #initial values
#Function to apply an integration
def f(init,t,args=(k,)):
dOdt = init[1]
dwdt = -np.cos(init[0]) + k*dOdt
return [dOdt,dwdt]
#integrating function that returns a list of 2D numpy arrays
zCH = odeint(f,init,t)
################################################################
### Code that DOES NOT WORK!###
k = [1,2,3] #attributes to be changed
t = [0.1,dwdt]
solutions = []
for i in k:
#integrating function that returns a list of 2D numpy arrays
zCH = odeint(f,(k[i-1]))
solutions.append(zCH)```
解决方法
这与您将<!DOCTYPE html>
<html>
<body>
<div id="trigger">Click to test</div>
</body>
</html>
传递到函数(defrule unable-to-diagnose
(name ?name)
(age ?age)
(gender ?gender)
(temperature ?C)
(or
(or (high-fever-days ?days)
(and (vomiting no)
(abdominal-pain-or-diarrhea no)
(muscle-joint-pain no)
(sore-muscles-and-joints no)
(mild-conjunctival-congestion no))
(and (shock no)
(respiratoty-failure no)
(hemoptysis-or-purulent-sputum no)
(shortness-of-breath)
(rales-can-be-heard-in-the-lungs no)))
(abnormal-sneezing-or-runny-nose no))
=>
(assert (diagnosis-result: unable-to-diagnose))
(printout t crlf "=======================================================================" crlf)
(printout t crlf "Diagnosis Result of " ?name " : unable-to-diagnose " crlf)
(printout t crlf "Treatment Suggestion to You :" crlf)
(printout t crlf " " crlf)
(printout t crlf "=======================================================================" crlf))
中的方式有关。
以下内容在每次迭代中更改k
的值
f()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。