求解约束 BVP,奇异雅可比行列式

计算科学 matlab Python 边界条件 约束优化
2021-12-02 15:04:40

边值问题是

{x˙i={(0.5D1ψ)i, if (0.5D1ψ)i00, otherwiseψ˙=2Σxx(0)=x0x(T)=0

这里x0>0,T给出,D>0是对角矩阵,Σ>0是一个对称矩阵。实际上约束是x(t)0t, 相当于x˙(t)0.

对于二维情况,我尝试用这段代码在 MATLAB 中解决它

function [tint, traj] = liq2mon_v3(x0, D, sigma, T)

  tlow = 0;
  thigh = T;
  L = length(x0); % L=2 in this example
  nsegm = 100; % I know it is for final calc only, not for the mesh
  solinit = bvpinit(linspace(tlow, thigh, nsegm), @guess);
  sol = bvp5c(@bvp4ode, @bvp4bc, solinit);
  tint = linspace(tlow, thigh);
  z = deval(sol, tint);
  traj = z(1:L, :);

  function xpsi = guess(t)
    xpsi = zeros(1, L*2);
    xpsi(1:L) = (x0*(1.0 - 1.0/T*t))';
  end

  function dydt = bvp4ode(t, y)
    xcomp = y(1:L); % L=2 in this example
    psicomp = y(L+1:end);
    u    = D \ psicomp / 2.0;
    dx   = min(u, 0); 
    dpsi = 2.0 * sigma * xcomp;
    dydt = [dx' dpsi']; 
  end

  function res = bvp4bc(ya, yb)
    xcompa = ya(1:2);
    xcompb = yb(1:2);
    res = [(xcompa - x0)' (xcompb)'];
  end

end

我得到一个错误

*Unable to solve the collocation equations -- a singular Jacobian  encountered
Error in ==> liq2mon_v3 at 13
sol = bvp5c(@bvp4ode, @bvp4bc, solinit)*

但是,如果我换行

dx = min(u, 0);

u(u>0) = 1e-13;
dx = u;

我确实得到了解决方案min(min(x))8×1014对于相同的x0

问题:

  1. 有没有办法在 MATLAB(或其他应用程序)中解决这个系统,以免违反约束?
  2. 也许这可以在 Python 中解决,即使当前违反了约束?
  3. 在这种情况下,为什么在 MATLAB 求解器中某处出现雅可比奇异数?
0个回答
没有发现任何回复~