0

次のタイプの複数の出力で非線形の問題があります。

[F,out1,out2,out3] = f(x,a,b,c)

私は方法でLevenberg-Marquardtの方法でPythonでそれを解決しようとしています:

xSol = scipy.optimize.root(lambda x: f(x,a,b,c), x0, method='lm')

出力を指定しない場合、つまりF = f(x,a,b,c)メソッドは正しい解 x に収束しますが、他の解の値、つまり out1、out2、out3 を取得できません。

DOCによると、root 関数は複数の出力のオプションを提供しませんfull_output=True。たとえば、fsolve や bisec などです (これは私の問題に対する適切な解決策にはなりません)。

問題の簡単な例を次に示します。

    def root2d(x): 
        F = [np.exp(-np.exp(-(x[0] + x[1]))) - x[1] * (1 + x[0] ** 2)] 
        F.append(x[0] * np.cos(x[1]) + x[1] * np.sin(x[0]) - 0.5) 

        out = x[0]+x[1] # other results, which I would like to get too 
        return (F,out) # it yields error, but it works/converges with only "return F" 

    # --- run the test code with the root solver 
    x0 = [0,0] 
    x = root(root2d, x0) # how could I get also value of "out"? 
    print(x)
4

0 に答える 0